Re: [Qemu-devel] [PATCH for-2.9 v2] virtio-crypto: zeroize the key material before free

2016-12-09 Thread Gonglei (Arei)
>
> 
> On 09.12.2016 02:42, Gonglei (Arei) wrote:
> > Hi,
> >
> >>
> >> Subject: Re: [Qemu-devel] [PATCH for-2.9 v2] virtio-crypto: zeroize the key
> >> material before free
> >>
> >> On 08.12.2016 16:23, Eric Blake wrote:
> >>> On 12/07/2016 08:28 PM, Gonglei (Arei) wrote:
> >>>
> > As far as I'm aware, other projects usually have a special memset
> > variation for doing this. That is because compilers may choose to
> > "optimize" memset(p, ...) + free(p) to just the free(p). Having a
> 
>  Actually, I googled this, but I didn't find a definite answer. And
> 
>  The Linux kernel uses kzfree instead of memset + kfree
> >> (mm/slab_common.c).
> >>
> >> Well, I personally don't mind whether we use a custom zfree() or a
> >> custom memset_s() + free(). I only mind that this patch actually always
> >> does what it is intended to do.
> >>
> > Yes, but why linux kernel to think about the compiler optimization for
> > memset for sensitive data?
> 
> I'm afraid I don't quite (syntactically) understand this question. Do
> you mean to ask why the Linux kernel would have to think about this
> optimization? My answer to that would be because the optimization of
> memset() + free() is known, and they probably want to protect against
> the compiler optimizing it even with -ffreestanding and differently
> called functions -- you never know.
> 
Sorry, that's my typo. ;) 

My question is why not linux kernel to think about the compiler optimization
on the code layer. Because the realization of kzfree is just memset + kfree, 
it didn't add any memory barrier to prevent memset is optimized, or use
secure_memset, or whatever.

So you answer means they maybe use some compiler options to avoid
the compiler optimizing?

> Related example: gcc detects code that basically does a memset() and
> replaces it with a call to memset(). There were a couple of versions
> where it did that even with -ffreestanding or -fno-builtin, which is bad
> if you want to actually write a memset(). They fixed it by now (so that
> -ffreestanding and -fno-builtin will imply
> -fno-tree-loop-distribute-patterns, which will disable that optimization.
> 
> Now imagine the same case here: Maybe at some point gcc is able to
> detect that kfree() is basically free() and will then optimize the
> memset() before kfree() away. A couple of versions later, somebody will
> notice that -- but at that point, the damage has been done already and
> there are compiled versions out which leak sensitive data somewhere.
> 
> I think this is why the Linux kernel decides to be proactive and use
> kzfree() from the start, and this is also why I'm proposing to not delay
> this issue in qemu until some compiler actually makes it a real issue.
> 
> >>> If we're worried about cleaning things without allowing the compiler a
> >>> chance to optimize, then writing our own qemu_zfree() wrapper may
> indeed
> >>> make sense.  But that won't cover the case in Daniel's earlier patch
> >>> (referenced elsewhere in this thread), as that was zeroizing stack
> >>> memory (before it went out of scope) rather than heap memory (before
> >>> free).  So you'd still need some sort of 'write this memory no matter
> >>> what' primitive that would be directly usable on stack memory and
> >>> indirectly used as part of the qemu_zfree() wrapper.
> >>>
> > If we wrap a secure_memset(), then both stack memory and heap
> > memory can use it.
> >
> > Pls see:
> >
> > http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1381.pdf
> >
> > But the secure_memset() is not as efficient as possible due to the nature of
> the volatile
> > type qualifier preventing the compiler from optimizing the code at all.
> >
> > It will cause huge performance regression at hot path of data plane...
> 
> I would suggest we implement an own secure_memset() or secure_bzero()
> which falls back on what we have:
> - memset_s(), if that is available;
> - explizit_bzero() if we have libbsd;
> - SecureZeroMemory() on Windows
> 
> Or we have to write it ourselves:
> https://sourceware.org/ml/libc-alpha/2014-12/msg00506.html suggests that
> putting a full memory barrier after the memset() should be enough.
> 
I like this approach.

> >>> But I wouldn't worry about it for now, unless someone proves we actually
> >>> have a compiler optimizing away the cleanups.
> >>
> >> It's true that we don't have to worry about it *now*, but the approach
> >> of waiting until the compiler breaks it does not seem right to me.
> >>
> >> If at some point some compiler recognizes g_free() as being the same
> >> function as free() and thus optimizes memset() + g_free(), we simply
> >> won't notice because nobody will keep track of the generated assembly
> >> output all the time.
> >>
> >> There is a reason C11 introduced memset_s(), and it is this.
> >>
> > ...does it make sense if we introduce secure_memset() now ?
> >
> > Waiting for your feedback. Thanks!
> 
> I would propose so; or better something like secure_bzero() or
> 

Re: [Qemu-devel] [PATCH v6 1/2] sparc: fix a building error reported by kbuild

2016-12-09 Thread Sam Ravnborg
Hi Gonglei.

On Thu, Dec 08, 2016 at 12:37:08PM +0800, Gonglei wrote:
> >> arch/sparc/include/asm/topology_64.h:44:44:
> error: implicit declaration of function 'cpu_data'
> [-Werror=implicit-function-declaration]
> 
>  #define topology_physical_package_id(cpu) (cpu_data(cpu).proc_id)
>^
> Let's include cpudata.h in topology_64.h.
> 
> Cc: Sam Ravnborg 
> Cc: David S. Miller 
> Cc: sparcli...@vger.kernel.org
> Suggested-by: Sam Ravnborg 
> Signed-off-by: Gonglei 
Acked-by: Sam Ravnborg 

> ---
>  arch/sparc/include/asm/topology_64.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/sparc/include/asm/topology_64.h 
> b/arch/sparc/include/asm/topology_64.h
> index 7b4898a..2255430 100644
> --- a/arch/sparc/include/asm/topology_64.h
> +++ b/arch/sparc/include/asm/topology_64.h
> @@ -4,6 +4,7 @@
>  #ifdef CONFIG_NUMA
>  
>  #include 
> +#include 

Nitpick - if you are going to resend this patch, then please
order the two includes in alphabetic order.

For two includes this looks like bikeshedding, but when we add
more having them in a defined arder prevents merge conflicts.
And makes it readable too.

We also sometimes order the includes with the longest lines topmost,
and lines with the ame length are ordered alphabetically.
But this is not seen so often.

Sam



Re: [Qemu-devel] [PATCH 3/8] 9pfs: fix P9_NOTAG and P9_NOFID macros

2016-12-09 Thread Eric Blake
On 12/09/2016 03:28 AM, Greg Kurz wrote:
> The u16 and u32 types don't exist in QEMU common headers. It never broke
> build because these two macros aren't use by the current code, but this
> is about to change with the future addition of functional tests for 9P.
> 
> This patch convert the types to uintXX_t.
> 
> Signed-off-by: Greg Kurz 
> ---
>  hw/9pfs/9p.h |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
> index 3976b7fe3dcd..89c904bdb7e7 100644
> --- a/hw/9pfs/9p.h
> +++ b/hw/9pfs/9p.h
> @@ -99,8 +99,8 @@ enum p9_proto_version {
>  V9FS_PROTO_2000L = 0x02,
>  };
>  
> -#define P9_NOTAG(u16)(~0)
> -#define P9_NOFID(u32)(~0)
> +#define P9_NOTAG(uint16_t)(~0)
> +#define P9_NOFID(uint32_t)(~0)

Don't you want to write ((uint16_t)(~0)), to ensure that this expression
can be used as a drop-in in any other syntactical situation?

Or even write it as UINT16_C(~0) (using ), or as UINT16_MAX.
(Be aware: the type of (uint16_t)(~0) is uint16_t, while the type of
UINT16_MAX is int, due to the rules of integer promotion, if that matters)

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v3 1/1] migration: disallow migrate_add_blocker during migration

2016-12-09 Thread John Snow


On 12/09/2016 12:39 PM, Dr. David Alan Gilbert wrote:
> * John Snow (js...@redhat.com) wrote:
>> If a migration is already in progress and somebody attempts
>> to add a migration blocker, this should rightly fail.
>>
>> Add an errp parameter and a retcode return value to migrate_add_blocker.
>>
>> Signed-off-by: John Snow 
>> ---
>>  block/qcow.c  |  6 +-
>>  block/vdi.c   |  6 +-
>>  block/vhdx.c  | 24 ++--
>>  block/vmdk.c  |  7 ++-
>>  block/vpc.c   | 10 +++---
>>  block/vvfat.c | 20 
>>  hw/9pfs/9p.c  | 16 
>>  hw/display/virtio-gpu.c   | 29 -
>>  hw/misc/ivshmem.c | 11 +++
>>  hw/scsi/vhost-scsi.c  | 25 +++--
>>  hw/virtio/vhost.c |  8 +++-
>>  include/migration/migration.h |  6 +-
>>  migration/migration.c | 35 +--
>>  stubs/migr-blocker.c  |  3 ++-
>>  target-i386/kvm.c | 16 +---
>>  15 files changed, 163 insertions(+), 59 deletions(-)
>>
>> diff --git a/block/qcow.c b/block/qcow.c
>> index 7540f43..11526a1 100644
>> --- a/block/qcow.c
>> +++ b/block/qcow.c
>> @@ -252,7 +252,11 @@ static int qcow_open(BlockDriverState *bs, QDict 
>> *options, int flags,
>>  error_setg(>migration_blocker, "The qcow format used by node '%s' "
>> "does not support live migration",
>> bdrv_get_device_or_node_name(bs));
>> -migrate_add_blocker(s->migration_blocker);
>> +ret = migrate_add_blocker(s->migration_blocker, errp);
>> +if (ret < 0) {
>> +error_free(s->migration_blocker);
>> +goto fail;
>> +}
>>  
>>  qemu_co_mutex_init(>lock);
>>  return 0;
>> diff --git a/block/vdi.c b/block/vdi.c
>> index 96b78d5..2b56f52 100644
>> --- a/block/vdi.c
>> +++ b/block/vdi.c
>> @@ -471,7 +471,11 @@ static int vdi_open(BlockDriverState *bs, QDict 
>> *options, int flags,
>>  error_setg(>migration_blocker, "The vdi format used by node '%s' "
>> "does not support live migration",
>> bdrv_get_device_or_node_name(bs));
>> -migrate_add_blocker(s->migration_blocker);
>> +ret = migrate_add_blocker(s->migration_blocker, errp);
>> +if (ret < 0) {
>> +error_free(s->migration_blocker);
>> +goto fail_free_bmap;
>> +}
>>  
>>  qemu_co_mutex_init(>write_lock);
>>  
>> diff --git a/block/vhdx.c b/block/vhdx.c
>> index 0ba2f0a..d81941b 100644
>> --- a/block/vhdx.c
>> +++ b/block/vhdx.c
>> @@ -991,20 +991,24 @@ static int vhdx_open(BlockDriverState *bs, QDict 
>> *options, int flags,
>>  }
>>  }
>>  
>> -if (flags & BDRV_O_RDWR) {
>> -ret = vhdx_update_headers(bs, s, false, NULL);
>> -if (ret < 0) {
>> -goto fail;
>> -}
>> -}
>> -
>> -/* TODO: differencing files */
>> -
>>  /* Disable migration when VHDX images are used */
>>  error_setg(>migration_blocker, "The vhdx format used by node '%s' "
>> "does not support live migration",
>> bdrv_get_device_or_node_name(bs));
>> -migrate_add_blocker(s->migration_blocker);
>> +ret = migrate_add_blocker(s->migration_blocker, errp);
>> +if (ret < 0) {
>> +error_free(s->migration_blocker);
>> +goto fail;
>> +}
>> +
>> +if (flags & BDRV_O_RDWR) {
>> +ret = vhdx_update_headers(bs, s, false, NULL);
>> +if (ret < 0) {
>> +goto fail;
>> +}
>> +}
>> +
>> +/* TODO: differencing files */
>>  
>>  return 0;
>>  fail:
>> diff --git a/block/vmdk.c b/block/vmdk.c
>> index a11c27a..4a45a83 100644
>> --- a/block/vmdk.c
>> +++ b/block/vmdk.c
>> @@ -976,7 +976,12 @@ static int vmdk_open(BlockDriverState *bs, QDict 
>> *options, int flags,
>>  error_setg(>migration_blocker, "The vmdk format used by node '%s' "
>> "does not support live migration",
>> bdrv_get_device_or_node_name(bs));
>> -migrate_add_blocker(s->migration_blocker);
>> +ret = migrate_add_blocker(s->migration_blocker, errp);
>> +if (ret < 0) {
>> +error_free(s->migration_blocker);
>> +goto fail;
>> +}
>> +
>>  g_free(buf);
>>  return 0;
>>  
>> diff --git a/block/vpc.c b/block/vpc.c
>> index 8d5886f..299a8c8 100644
>> --- a/block/vpc.c
>> +++ b/block/vpc.c
>> @@ -422,13 +422,17 @@ static int vpc_open(BlockDriverState *bs, QDict 
>> *options, int flags,
>>  #endif
>>  }
>>  
>> -qemu_co_mutex_init(>lock);
>> -
>>  /* Disable migration when VHD images are used */
>>  error_setg(>migration_blocker, "The vpc format used by node '%s' "
>> "does not support live migration",
>> bdrv_get_device_or_node_name(bs));
>> -

[Qemu-devel] Reproducible crash on PCIe hotplug

2016-12-09 Thread Eduardo Habkost
Using latest qemu.git master:

  $ qemu-system-x86_64 -machine q35 -readconfig docs/q35-chipset.cfg -monitor 
stdio
  QEMU 2.7.93 monitor - type 'help' for more information
  (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=00
  (qemu) device_add e1000e,bus=ich9-pcie-port-4,addr=08
  Segmentation fault (core dumped)

It crashes at:

  #7  0x5598d7dc in do_pci_register_device (errp=0x7fffbfd0, 
devfn=64, name=0x565df340 "e1000e", bus=0x58487380, 
pci_dev=0x589cd000)
  at /home/ehabkost/rh/proj/virt/qemu/hw/pci/pci.c:983
  983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by 
%s,"
  (gdb) l
  978PCI_SLOT(devfn), PCI_FUNC(devfn), name,
  979bus->devices[devfn]->name);
  980 return NULL;
  981 } else if (dev->hotplugged &&
  982pci_get_function_0(pci_dev)) {
  983 error_setg(errp, "PCI: slot %d function 0 already ocuppied by 
%s,"
  984" new func %s cannot be exposed to guest.",
  985PCI_SLOT(devfn),
  986bus->devices[PCI_DEVFN(PCI_SLOT(devfn), 0)]->name,
  987name);

-- 
Eduardo



Re: [Qemu-devel] [RFC for-2.8] machine: Convert abstract typename on compat_props to subclass names

2016-12-09 Thread Eduardo Habkost
On Wed, Dec 07, 2016 at 02:39:25PM +0100, Greg Kurz wrote:
> On Tue, 6 Dec 2016 17:31:59 -0200
> Eduardo Habkost  wrote:
> > On Tue, Dec 06, 2016 at 05:19:52PM -0200, Eduardo Habkost wrote:
> > > On Tue, Dec 06, 2016 at 06:50:47PM +0100, Greg Kurz wrote:  
> > > > Since commit "9a4c0e220d8a hw/virtio-pci: fix virtio behaviour", passing
> > > > -device virtio-blk-pci.disable-modern=off has no effect on 2.6 machine
> > > > types because the internal virtio-pci.disable-modern=on compat property
> > > > always prevail.
> > > > 
> > > > This should ideally be fixed in the qdev properties core code, but it is
> > > > too late in the QEMU 2.8 schedule. So this patch fixes the issue by 
> > > > setting
> > > > the compat properties for every virtio-*-pci subtypes instead of the 
> > > > base
> > > > virtio-pci type.
> > > > 
> > > > Signed-off-by: Greg Kurz   
> > > 
> > > So, it looks like the bug is present in many other cases...
> > > 
> > > I have hacked QEMU to print a warning in case the driver name in
> > > compat_props refer to an abstract class or a class that have any
> > > subclasses. The results are below:
> > > 
[...]
> > > 
> > > I believe the cases where we are likely to cause real-world bugs
> > > are virtio-pci and the *-cpu classes (because -cpu is translated
> > > to -global).
> > > 
> > > I'm not sure what should be the right fix in 2.8. I am
> > > considering a temporary hack to translate abstract class names in
> > > compat_props to global properties for all subclasses, in case
> > > they refer to an abstract class. This way we fix the bug where
> > > -global doesn't override compat_props properly, but keep the
> > > rules for -global untouched.  
> > 
> > What about this?
> > 
> 
> Indeed that would have been a clever workaround but it is too late anyway. :)

Now my question is: what should we do in 2.8.1?

1) Change the rules and apply "[PATCH] qdev: fix the order compat
   and global properties are applied"
2) Fix only virtio-pci (apply a new version of "[PATCH] virtio:
   fix HW_COMPAT_2_6 macro for virtio-*-pci drivers")
3) Apply this hack so we fix all compat_props cases without
   changing ordering rules. (And then change the ordering rules
   in 2.9)

-- 
Eduardo



Re: [Qemu-devel] [PATCH 2/2] 9p: v9fs new readpages.

2016-12-09 Thread Edward Shishkin

Hello Alexander,

Thank you for the comments.
Please, find my answers below.


On 10/25/2016 04:13 PM, Alexander Graf wrote:

On 10/10/2016 07:24 PM, Edward Shishkin wrote:

Modify v9fs private ->readpages() method of address_space
operations for merging pages into long 9p messages.

Signed-off-by: Edward Shishkin 
---
  fs/9p/vfs_addr.c | 156 
++-

  1 file changed, 155 insertions(+), 1 deletion(-)

diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index e871886..4ad248e 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -34,6 +34,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -99,6 +100,148 @@ static int v9fs_vfs_readpage(struct file *filp, 
struct page *page)

  return v9fs_fid_readpage(filp->private_data, page);
  }
  +/*
+ * Context for "fast readpages"
+ */
+struct v9fs_readpages_ctx {
+struct file *filp;
+struct address_space *mapping;
+pgoff_t start_index; /* index of the first page with actual data */
+char *buf; /* buffer with actual data */
+int len; /* length of the actual data */
+int num_pages; /* maximal data chunk (in pages) that can be
+  passed per transmission */
+};
+
+static int init_readpages_ctx(struct v9fs_readpages_ctx *ctx,
+  struct file *filp,
+  struct address_space *mapping,
+  int num_pages)
+{
+memset(ctx, 0, sizeof(*ctx));
+ctx->buf = kmalloc(num_pages << PAGE_SHIFT, GFP_USER);


Doesn't this a) have potential information leak to user space



Yes, allocation with such flag is a mistake. Will be fixed in v2.



and b) allow user space to allocate big amounts of kernel memory?



Yes, I definitely missed a sanity check for the num_pages. Will be fixed 
in v2.




A limited page pool would probably be better here.

I also don't quite grasp yet what pattern you're actually optimizing.



reading/writing a large file in sequential/random manner.



Basically you're doing implicit read-ahead on behalf of the reader, right?



Yes. As you can see, we always read (ctx->num_pages) number of pages.



So why would that be faster in a random 4k read scenario?



You mean 41 MB/s vs 64 MB/s?
With such read-ahead it's more likely that an up-to-date page will be 
present in
the cache. So, why not? After all, our speedup of random 4K reads is not 
dramatic.



Also, have you compared tmpfs hosted files to only benchmark the 
transmission path?



No, I haven't. Only I/O speedup was a concern.
I can obtain such numbers, if interesting.





+if (!ctx->buf)
+return -ENOMEM;
+ctx->filp = filp;
+ctx->mapping = mapping;
+ctx->num_pages = num_pages;
+return 0;
+}
+
+static void done_readpages_ctx(struct v9fs_readpages_ctx *ctx)
+{
+kfree(ctx->buf);
+}
+
+static int receive_buffer(struct file *filp,
+  char *buf,
+  off_t offset, /* offset in the file */
+  int len,
+  int *err)
+{
+struct kvec kvec;
+struct iov_iter iter;
+
+kvec.iov_base = buf;
+kvec.iov_len = len;
+iov_iter_kvec(, READ | ITER_KVEC, , 1, len);
+
+return p9_client_read(filp->private_data, offset, , err);
+}
+
+static int fast_filler(struct v9fs_readpages_ctx *ctx, struct page 
*page)

+{
+int err;
+int ret = 0;
+char *kdata;
+int to_page;
+off_t off_in_buf;
+struct inode *inode = page->mapping->host;
+
+BUG_ON(!PageLocked(page));
+/*
+ * first, validate the buffer
+ */
+if (page->index < ctx->start_index ||
+ctx->start_index + ctx->num_pages < page->index) {
+/*
+ * No actual data in the buffer,
+ * so actualize it
+ */
+ret = receive_buffer(ctx->filp,
+ ctx->buf,
+ page_offset(page),
+ ctx->num_pages << PAGE_SHIFT,


Doesn't this potentially read beyond the end of the file?



POSIX doesn't prohibit to read beyond the end of a file. The only 
requirement is that

the supplement should be filled with zeros.
Full pages of such supplement are filled with zeros from the buffer: 
here we rely on
the local file system on the host. Partial pages are filled with zeros 
by us at the place

I have marked with (*) below.

Thanks,
Edward.



Alex


+ );
+if (err) {
+printk("failed to receive buffer off=%llu (%d)\n",
+   (unsigned long long)page_offset(page),
+   err);
+ret = err;
+goto done;
+}
+ctx->start_index = page->index;
+ctx->len = ret;
+ret = 0;
+}
+/*
+ * fill the page with buffer's data
+ */
+off_in_buf = (page->index - ctx->start_index) << PAGE_SHIFT;
+if (off_in_buf >= ctx->len) {
+/*
+ * No actual data to fill the page with
+ */
+ret = -1;
+goto done;
+}
+

Re: [Qemu-devel] [PATCH 1/2] 9p: v9fs add writepages.

2016-12-09 Thread Edward Shishkin

On 10/25/2016 04:01 PM, Alexander Graf wrote:

On 10/10/2016 07:24 PM, Edward Shishkin wrote:

Add a v9fs private ->writepages() method of address_space
operations for merging pages into long 9p messages.

Signed-off-by: Edward Shishkin 
---
  fs/9p/v9fs.c  |  46 +++
  fs/9p/v9fs.h  |  22 +++-
  fs/9p/vfs_addr.c  | 357 
++

  fs/9p/vfs_super.c |   8 +-
  4 files changed, 431 insertions(+), 2 deletions(-)

diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 072e759..3b49daf 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -32,6 +32,7 @@
  #include 
  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -309,6 +310,49 @@ static int v9fs_parse_options(struct 
v9fs_session_info *v9ses, char *opts)

  return ret;
  }
  +void put_flush_set(struct v9fs_flush_set *fset)
+{
+if (!fset)
+return;
+if (fset->pages)
+kfree(fset->pages);
+if (fset->buf)
+kfree(fset->buf);
+kfree(fset);
+}
+
+/**
+ * Allocate and initalize flush set
+ * Pre-conditions: valid msize is set
+ */
+int alloc_init_flush_set(struct v9fs_session_info *v9ses)
+{
+int ret = -ENOMEM;
+int num_pages;
+struct v9fs_flush_set *fset = NULL;
+
+num_pages = v9ses->clnt->msize >> PAGE_SHIFT;
+if (num_pages < 2)
+/* speedup impossible */
+return 0;
+fset = kzalloc(sizeof(*fset), GFP_KERNEL);
+if (!fset)
+goto error;
+fset->num_pages = num_pages;
+fset->pages = kzalloc(num_pages * sizeof(*fset->pages), 
GFP_KERNEL);

+if (!fset->pages)
+goto error;
+fset->buf = kzalloc(num_pages << PAGE_SHIFT, GFP_USER);
+if (!fset->buf)
+goto error;
+spin_lock_init(&(fset->lock));
+v9ses->flush = fset;
+return 0;
+ error:
+put_flush_set(fset);
+return ret;
+}
+
  /**
   * v9fs_session_init - initialize session
   * @v9ses: session information structure
@@ -444,6 +488,8 @@ void v9fs_session_close(struct v9fs_session_info 
*v9ses)

  kfree(v9ses->uname);
  kfree(v9ses->aname);
  +put_flush_set(v9ses->flush);
+
  bdi_destroy(>bdi);
spin_lock(_sessionlist_lock);
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index 6877050..d1092e4 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -23,6 +23,7 @@
  #ifndef FS_9P_V9FS_H
  #define FS_9P_V9FS_H
  +#include 
  #include 
/**
@@ -69,6 +70,13 @@ enum p9_cache_modes {
  CACHE_FSCACHE,
  };
  +struct v9fs_flush_set {
+struct page **pages;
+int num_pages;
+char *buf;
+spinlock_t lock;
+};
+
  /**
   * struct v9fs_session_info - per-instance session information
   * @flags: session options of type _session_flags
@@ -105,7 +113,7 @@ struct v9fs_session_info {
  char *cachetag;
  struct fscache_cookie *fscache;
  #endif
-
+struct v9fs_flush_set *flush; /* flush set for writepages */
  char *uname;/* user name to mount as */
  char *aname;/* name of remote hierarchy being mounted */
  unsigned int maxdata;/* max data for client interface */
@@ -158,6 +166,8 @@ extern const struct inode_operations 
v9fs_symlink_inode_operations_dotl;
  extern struct inode *v9fs_inode_from_fid_dotl(struct 
v9fs_session_info *v9ses,

struct p9_fid *fid,
struct super_block *sb, int new);
+extern int alloc_init_flush_set(struct v9fs_session_info *v9ses);
+extern void put_flush_set(struct v9fs_flush_set *fset);
/* other default globals */
  #define V9FS_PORT564
@@ -222,4 +232,14 @@ v9fs_get_new_inode_from_fid(struct 
v9fs_session_info *v9ses, struct p9_fid *fid,

  return v9fs_inode_from_fid(v9ses, fid, sb, 1);
  }
  +static inline int spin_trylock_flush_set(struct v9fs_flush_set *fset)
+{
+return spin_trylock(&(fset->lock));
+}
+
+static inline void spin_unlock_flush_set(struct v9fs_flush_set *fset)
+{
+spin_unlock(&(fset->lock));
+}
+
  #endif
diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
index 6181ad7..e871886 100644
--- a/fs/9p/vfs_addr.c
+++ b/fs/9p/vfs_addr.c
@@ -36,6 +36,7 @@
  #include 
  #include 
  #include 
+#include 
#include "v9fs.h"
  #include "v9fs_vfs.h"
@@ -209,6 +210,361 @@ static int v9fs_vfs_writepage(struct page 
*page, struct writeback_control *wbc)

  return retval;
  }
  +static void redirty_pages_for_writeback(struct page **pages, int nr,
+struct writeback_control *wbc)
+{
+int i;
+for (i = 0; i < nr; i++) {
+lock_page(pages[i]);
+redirty_page_for_writepage(wbc, pages[i]);
+unlock_page(pages[i]);
+}
+}
+
+static void set_pages_error(struct page **pages, int nr, int error)
+{
+int i;
+for (i = 0; i < nr; i++) {
+lock_page(pages[i]);
+SetPageError(pages[i]);
+mapping_set_error(pages[i]->mapping, error);
+unlock_page(pages[i]);
+}
+}
+
+#define V9FS_WRITEPAGES_DEBUG   (0)
+
+struct flush_context {
+struct 

[Qemu-devel] [PATCH v3 1/2] tests: check-qom-proplist: add checks for cmdline-created objects

2016-12-09 Thread Michael Roth
check-qom-proplist originally added tests for verifying that
object-creation helpers object_new_with_{props,propv} behaved in
similar fashion to the "traditional" method involving setting each
individual property separately after object creation rather than
via a single call.

Another similar "helper" for creating Objects exists in the form of
objects specified via -object command-line parameters. By that
rationale, we extend check-qom-proplist to include similar checks
for command-line-created objects by employing the same
qemu_opts_parse()-based parsing the vl.c employs.

This parser has a side-effect of parsing the object's options into
a QemuOpt structure and registering this in the global QemuOptsList
using the Object's ID. This can conflict with future Object instances
that attempt to use the same ID if we don't ensure this is cleaned
up as part of Object finalization, so we include a FIXME stub to test
for this case, which will then be resolved in a subsequent patch.

Suggested-by: Daniel Berrange 
Cc: "Dr. David Alan Gilbert" 
Cc: Markus Armbruster 
Cc: Eric Blake 
Cc: Daniel Berrange 
Signed-off-by: Michael Roth 
---
 tests/check-qom-proplist.c | 55 ++
 1 file changed, 55 insertions(+)

diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index a16cefc..e3f56ca 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -23,6 +23,9 @@
 #include "qapi/error.h"
 #include "qom/object.h"
 #include "qemu/module.h"
+#include "qemu/option.h"
+#include "qemu/config-file.h"
+#include "qom/object_interfaces.h"
 
 
 #define TYPE_DUMMY "qemu-dummy"
@@ -162,6 +165,10 @@ static const TypeInfo dummy_info = {
 .instance_finalize = dummy_finalize,
 .class_size = sizeof(DummyObjectClass),
 .class_init = dummy_class_init,
+.interfaces = (InterfaceInfo[]) {
+{ TYPE_USER_CREATABLE },
+{ }
+}
 };
 
 
@@ -320,6 +327,14 @@ static const TypeInfo dummy_backend_info = {
 .class_size = sizeof(DummyBackendClass),
 };
 
+static QemuOptsList qemu_object_opts = {
+.name = "object",
+.implied_opt_name = "qom-type",
+.head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
+.desc = {
+{ }
+},
+};
 
 
 static void test_dummy_createv(void)
@@ -388,6 +403,45 @@ static void test_dummy_createlist(void)
 object_unparent(OBJECT(dobj));
 }
 
+static void test_dummy_createcmdl(void)
+{
+QemuOpts *opts;
+DummyObject *dobj;
+Error *err = NULL;
+const char *params = TYPE_DUMMY \
+ ",id=dev0," \
+ "bv=yes,sv=Hiss hiss hiss,av=platypus";
+
+qemu_add_opts(_object_opts);
+opts = qemu_opts_parse(_object_opts, params, true, );
+g_assert(err == NULL);
+g_assert(opts);
+
+dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, ));
+g_assert(err == NULL);
+g_assert(dobj);
+g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss");
+g_assert(dobj->bv == true);
+g_assert(dobj->av == DUMMY_PLATYPUS);
+
+user_creatable_del("dev0", );
+g_assert(err == NULL);
+error_free(err);
+
+/* cmdline-parsing via qemu_opts_parse() results in a QemuOpts entry
+ * corresponding to the Object's ID to be added to the QemuOptsList
+ * for objects. To avoid having this entry conflict with future
+ * Objects using the same ID (which can happen in cases where
+ * qemu_opts_parse() is used to parse the object params, such as
+ * with hmp_object_add() at the time of this comment), we need to
+ * check for this in user_creatable_del() and remove the QemuOpts if
+ * it is present.
+ *
+ * FIXME: add an assert to verify that the QemuOpts is cleaned up
+ * once the corresponding cleanup code is added.
+ */
+}
+
 static void test_dummy_badenum(void)
 {
 Error *err = NULL;
@@ -525,6 +579,7 @@ int main(int argc, char **argv)
 
 g_test_add_func("/qom/proplist/createlist", test_dummy_createlist);
 g_test_add_func("/qom/proplist/createv", test_dummy_createv);
+g_test_add_func("/qom/proplist/createcmdline", test_dummy_createcmdl);
 g_test_add_func("/qom/proplist/badenum", test_dummy_badenum);
 g_test_add_func("/qom/proplist/getenum", test_dummy_getenum);
 g_test_add_func("/qom/proplist/iterator", test_dummy_iterator);
-- 
1.9.1




[Qemu-devel] [PATCH for-2.9] qom: Make all interface types abstract

2016-12-09 Thread Eduardo Habkost
"qom-list-types abstract=false" currently returns all interface
types, as if they were not abstract. Fix this by making sure all
interface types are abstract.

All interface types have instance_size == 0, so we can use
it to set abstract=true on

Signed-off-by: Eduardo Habkost 
---
 qom/object.c   |  4 +++
 tests/device-introspect-test.c | 61 +++---
 2 files changed, 62 insertions(+), 3 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index 7a05e35..3870c1b 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -272,6 +272,10 @@ static void type_initialize(TypeImpl *ti)
 
 ti->class_size = type_class_get_size(ti);
 ti->instance_size = type_object_get_size(ti);
+/* Any type with zero instance_size is implicitly abstract.
+ * This means interface types are all abstract.
+ */
+ti->abstract |= ti->instance_size == 0;
 
 ti->class = g_malloc0(ti->class_size);
 
diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c
index 37debc1..d1b0ea6 100644
--- a/tests/device-introspect-test.c
+++ b/tests/device-introspect-test.c
@@ -20,18 +20,24 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "qapi/qmp/qstring.h"
+#include "qapi/qmp/qbool.h"
+#include "qapi/qmp/qdict.h"
 #include "libqtest.h"
 
 const char common_args[] = "-nodefaults -machine none";
 
-static QList *device_type_list(bool abstract)
+static QList *qom_list_types(const char *implements, bool abstract)
 {
 QDict *resp;
 QList *ret;
+QDict *args = qdict_new();
 
+qdict_put(args, "abstract", qbool_from_bool(abstract));
+if (implements) {
+qdict_put(args, "implements", qstring_from_str(implements));
+}
 resp = qmp("{'execute': 'qom-list-types',"
-   " 'arguments': {'implements': 'device', 'abstract': %i}}",
-   abstract);
+   " 'arguments': %p }", args);
 g_assert(qdict_haskey(resp, "return"));
 ret = qdict_get_qlist(resp, "return");
 QINCREF(ret);
@@ -39,6 +45,11 @@ static QList *device_type_list(bool abstract)
 return ret;
 }
 
+static QList *device_type_list(bool abstract)
+{
+return qom_list_types("device", abstract);
+}
+
 static void test_one_device(const char *type)
 {
 QDict *resp;
@@ -110,6 +121,48 @@ static void test_device_intro_concrete(void)
 qtest_end();
 }
 
+static void test_abstract_interfaces(void)
+{
+QList *all_types;
+QList *obj_types;
+QListEntry *ae;
+
+qtest_start(common_args);
+/* qom-list-types implements=interface would return any type
+ * that implements _any_ interface (not just interface types),
+ * so use a trick to find the interface type names:
+ * - list all object types
+ * - list all types, and look for items that are not
+ *   on the first list
+ */
+all_types = qom_list_types(NULL, false);
+obj_types = qom_list_types("object", false);
+
+QLIST_FOREACH_ENTRY(all_types, ae) {
+QDict *at = qobject_to_qdict(qlist_entry_obj(ae));
+const char *aname = qdict_get_str(at, "name");
+QListEntry *oe;
+const char *found = NULL;
+
+QLIST_FOREACH_ENTRY(obj_types, oe) {
+QDict *ot = qobject_to_qdict(qlist_entry_obj(oe));
+const char *oname = qdict_get_str(ot, "name");
+if (!strcmp(aname, oname)) {
+found = oname;
+break;
+}
+}
+
+/* Using g_assert_cmpstr() will give more useful failure
+ * messages than g_assert(found) */
+g_assert_cmpstr(aname, ==, found);
+}
+
+QDECREF(all_types);
+QDECREF(obj_types);
+qtest_end();
+}
+
 int main(int argc, char **argv)
 {
 g_test_init(, , NULL);
@@ -119,5 +172,7 @@ int main(int argc, char **argv)
 qtest_add_func("device/introspect/abstract", test_device_intro_abstract);
 qtest_add_func("device/introspect/concrete", test_device_intro_concrete);
 
+qtest_add_func("qom/introspect/abstract-interfaces", 
test_abstract_interfaces);
+
 return g_test_run();
 }
-- 
2.7.4




Re: [Qemu-devel] [PATCH 19/20] xtensa: Move CPU files to target/ folder

2016-12-09 Thread Max Filippov
On Fri, Dec 9, 2016 at 4:17 AM, Thomas Huth  wrote:
> Signed-off-by: Thomas Huth 
> ---
>  MAINTAINERS   | 2 +-
>  {target-xtensa => target/xtensa}/Makefile.objs| 0
>  {target-xtensa => target/xtensa}/core-dc232b.c| 0
>  {target-xtensa => target/xtensa}/core-dc232b/core-isa.h   | 0
>  {target-xtensa => target/xtensa}/core-dc232b/gdb-config.c | 0
>  {target-xtensa => target/xtensa}/core-dc233c.c| 0
>  {target-xtensa => target/xtensa}/core-dc233c/core-isa.h   | 0
>  {target-xtensa => target/xtensa}/core-dc233c/gdb-config.c | 0
>  {target-xtensa => target/xtensa}/core-fsf.c   | 0
>  {target-xtensa => target/xtensa}/core-fsf/core-isa.h  | 0
>  {target-xtensa => target/xtensa}/cpu-qom.h| 0
>  {target-xtensa => target/xtensa}/cpu.c| 0
>  {target-xtensa => target/xtensa}/cpu.h| 0
>  {target-xtensa => target/xtensa}/gdbstub.c| 0
>  {target-xtensa => target/xtensa}/helper.c | 0
>  {target-xtensa => target/xtensa}/helper.h | 0
>  {target-xtensa => target/xtensa}/import_core.sh   | 0
>  {target-xtensa => target/xtensa}/monitor.c| 0
>  {target-xtensa => target/xtensa}/op_helper.c  | 0
>  {target-xtensa => target/xtensa}/overlay_tool.h   | 0
>  {target-xtensa => target/xtensa}/translate.c  | 0
>  {target-xtensa => target/xtensa}/xtensa-semi.c| 0
>  tests/tcg/xtensa/Makefile | 2 +-
>  23 files changed, 2 insertions(+), 2 deletions(-)

Acked-by: Max Filippov 

-- 
Thanks.
-- Max



[Qemu-devel] [PATCH v3 2/2] monitor: fix object_del for command-line-created objects

2016-12-09 Thread Michael Roth
Currently objects specified on the command-line are only partially
cleaned up when 'object_del' is issued in either HMP or QMP: the
object itself is fully finalized, but the QemuOpts are not removed.
This results in the following behavior:

  x86_64-softmmu/qemu-system-x86_64 -monitor stdio \
-object memory-backend-ram,id=ram1,size=256M

  QEMU 2.7.91 monitor - type 'help' for more information
  (qemu) object_del ram1
  (qemu) object_del ram1
  object 'ram1' not found
  (qemu) object_add memory-backend-ram,id=ram1,size=256M
  Duplicate ID 'ram1' for object
  Try "help object_add" for more information

which can be an issue for use-cases like memory hotplug.

This happens on the HMP side because hmp_object_add() attempts to
create a temporary QemuOpts entry with ID 'ram1', which ends up
conflicting with the command-line-created entry, since it was never
cleaned up during the previous hmp_object_del() call.

We address this by adding a check in user_creatable_del(), which
is called by both qmp_object_del() and hmp_object_del() to handle
the actual object cleanup, to determine whether an option group entry
matching the object's ID is present and removing it if it is.

Note that qmp_object_add() never attempts to create a temporary
QemuOpts entry, so it does not encounter the duplicate ID error,
which is why this isn't generally visible in libvirt.

Cc: "Dr. David Alan Gilbert" 
Cc: Markus Armbruster 
Cc: Eric Blake 
Cc: Daniel Berrange 
Cc: qemu-sta...@nongnu.org
Signed-off-by: Michael Roth 
Reviewed-by: Daniel P. Berrange 
---
 qom/object_interfaces.c| 7 +++
 tests/check-qom-proplist.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index ded4d84..b462a74 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -5,6 +5,7 @@
 #include "qapi-visit.h"
 #include "qapi/qobject-output-visitor.h"
 #include "qapi/opts-visitor.h"
+#include "qemu/config-file.h"
 
 void user_creatable_complete(Object *obj, Error **errp)
 {
@@ -209,6 +210,12 @@ void user_creatable_del(const char *id, Error **errp)
 error_setg(errp, "object '%s' is in use, can not be deleted", id);
 return;
 }
+
+/* if object was defined on the command-line, remove its corresponding
+ * option group entry
+ */
+qemu_opts_del(qemu_opts_find(qemu_find_opts_err("object", NULL), id));
+
 object_unparent(obj);
 }
 
diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
index e3f56ca..c5d4b60 100644
--- a/tests/check-qom-proplist.c
+++ b/tests/check-qom-proplist.c
@@ -437,9 +437,9 @@ static void test_dummy_createcmdl(void)
  * check for this in user_creatable_del() and remove the QemuOpts if
  * it is present.
  *
- * FIXME: add an assert to verify that the QemuOpts is cleaned up
- * once the corresponding cleanup code is added.
+ * The below check ensures this works as expected.
  */
+g_assert(qemu_opts_find(_object_opts, "dev0") == NULL);
 }
 
 static void test_dummy_badenum(void)
-- 
1.9.1




[Qemu-devel] [PATCH v3 0/2] Fixes/tests for hmp_object_del()

2016-12-09 Thread Michael Roth
hmp_object_del() followed by a subsequent hmp_object_add() can trigger a
duplicate ID error if the previous object shared the same ID and was added
via the command-line. Please see patch 2/2 for more details.

This patchset fixes the issue in question and adds some general unit tests
for object created via -object, which we later extend to verify the fix in
question.

Changes since v3:
  - Moved the generic unit tests ahead of the fix patch, with a FIXME
in place of the actual check for the failure addressed in patch
2/2 (Daniel/Markus)
  - Dropped check for existence of objects' QemuOptsList (Markus)
  - Dropped unintended whitespace removal in PATCH 1/2
  - Slight rewording of commit messages to reflect the changes and fix
minor grammar errors.

Changes since v2:

  - Moved QemuOpt cleanup out of {qmp,hmp}_object_del() and into common
user_creatable_del() path (Daniel, David)
  - Added corresponding test case in check-qom-proplist




Re: [Qemu-devel] [PATCH 15/21] qcow2: add .bdrv_can_store_dirty_bitmap

2016-12-09 Thread Vladimir Sementsov-Ogievskiy

09.12.2016 20:28, Max Reitz wrote:

On 22.11.2016 18:26, Vladimir Sementsov-Ogievskiy wrote:

Realize .bdrv_can_store_dirty_bitmap interface.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
  block/qcow2-bitmap.c | 40 
  block/qcow2.c|  1 +
  block/qcow2.h|  4 
  3 files changed, 45 insertions(+)

diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index a975388..55b1112 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1115,3 +1115,43 @@ fail:
  
  bitmap_list_free(bm_list);

  }
+
+bool qcow2_can_store_dirty_bitmap(BlockDriverState *bs,
+  const char *name,
+  uint32_t granularity,
+  Error **errp)
+{
+BDRVQcow2State *s = bs->opaque;
+const char *reason = NULL;
+bool found;
+Qcow2BitmapList *bm_list;
+
+if (check_constraints_on_bitmap(bs, name, granularity) != 0) {
+reason = "it doesn't satisfy the constraints";
+goto common_errp;
+}
+
+if (s->nb_bitmaps == 0) {
+return true;
+}
+
+bm_list = bitmap_list_load(bs, s->bitmap_directory_offset,
+   s->bitmap_directory_size, errp);

Maybe it would make sense to keep the bitmap list in memory...


+if (bm_list == NULL) {
+return false;
+}
+
+found = !!find_bitmap_by_name(bm_list, name);

You can omit the !!, storing it in a bool will do that for you.


+bitmap_list_free(bm_list);
+if (found) {
+reason = "bitmap with the same name is already stored";
+goto common_errp;
+}
+
+return true;
+
+common_errp:
+error_setg(errp, "Can't make bitmap '%s' persistent in '%s', as %s.",
+   name, bdrv_get_device_or_node_name(bs), reason);

Hm, so this function isn't for checking whether a bitmap can be stored,
but whether it can be made persistent. That's a difference; you can
store a bitmap of the same name in the file if you want to overwrite it
(i.e. it's an auto-load bitmap), but you cannot create a new bitmap with
the same name.

Maybe rename it from bdrv_can_store_dirty_bitmap to
bdrv_can_store_new_dirty_bitmap?


Yes, I'll rename it.



Max


+return false;
+}
diff --git a/block/qcow2.c b/block/qcow2.c
index 66c7f74..cb9c2a2 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3516,6 +3516,7 @@ BlockDriver bdrv_qcow2 = {
  
  .bdrv_load_autoloading_dirty_bitmaps = qcow2_load_autoloading_dirty_bitmaps,

  .bdrv_store_persistent_dirty_bitmaps = 
qcow2_store_persistent_dirty_bitmaps,
+.bdrv_can_store_dirty_bitmap = qcow2_can_store_dirty_bitmap,
  };
  
  static void bdrv_qcow2_init(void)

diff --git a/block/qcow2.h b/block/qcow2.h
index d9a7643..e7a44a1 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -616,5 +616,9 @@ void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, 
void **table);
  /* qcow2-bitmap.c functions */
  void qcow2_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error **errp);
  void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **errp);
+bool qcow2_can_store_dirty_bitmap(BlockDriverState *bs,
+  const char *name,
+  uint32_t granularity,
+  Error **errp);
  
  #endif







--
Best regards,
Vladimir




Re: [Qemu-devel] [PATCH 13/21] qcow2: add .bdrv_store_persistent_dirty_bitmaps()

2016-12-09 Thread Vladimir Sementsov-Ogievskiy

09.12.2016 20:05, Max Reitz wrote:

On 22.11.2016 18:26, Vladimir Sementsov-Ogievskiy wrote:

Realize block bitmap storing interface, to allow qcow2 images store
persistent bitmaps.

Signed-off-by: Vladimir Sementsov-Ogievskiy 
---
  block/qcow2-bitmap.c | 451 +++
  block/qcow2.c|   1 +
  block/qcow2.h|   1 +
  3 files changed, 453 insertions(+)

diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 81be1ca..a975388 100644
--- a/block/qcow2-bitmap.c


[...]


+return;
+}
+}
+
+/* check constraints and names */
+for (bitmap = bdrv_dirty_bitmap_next(bs, NULL); bitmap != NULL;
+bitmap = bdrv_dirty_bitmap_next(bs, bitmap)) {

Alignment to the opening parenthesis, please.


Hmm.. without an alignment it is not so simple to distinguish for-loop 
header from its body.



[...]


[1] What about bitmaps that have BME_FLAG_IN_USE set but do not have a
corresponding BDS bitmap?

If such a bitmap does not have BME_FLAG_AUTO set, we didn't set the
flag, so we should keep it unchanged. That's what this function is
currently doing.

However, if such a bitmap does have BME_FLAG_AUTO set, it was definitely
us who set the IN_USE flag (because otherwise we would have aborted
loading the bitmaps, and thus also aborted bdrv_open_common()).
Therefore, the only explanation is that the bitmap was deleted in the
meantime, and that means we should also delete it in the qcow2 file.


Right. Or, alternatively, these bitmaps may be deleted on corresponding 
BdrvDirtyBitmap deletion.



--
Best regards,
Vladimir




Re: [Qemu-devel] [PATCH 17/21] qmp: add autoload parameter to block-dirty-bitmap-add

2016-12-09 Thread Max Reitz
On 22.11.2016 18:26, Vladimir Sementsov-Ogievskiy wrote:
> Optional. Default is false.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> Signed-off-by: Denis V. Lunev 
> ---
>  blockdev.c| 18 --
>  docs/qmp-commands.txt |  4 
>  qapi/block-core.json  |  6 +-
>  3 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 3876d1d..3891d86 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1968,6 +1968,7 @@ static void 
> block_dirty_bitmap_add_prepare(BlkActionState *common,
>  qmp_block_dirty_bitmap_add(action->node, action->name,
> action->has_granularity, action->granularity,
> action->has_persistent, action->persistent,
> +   action->has_autoload, action->autoload,
> _err);
>  
>  if (!local_err) {
> @@ -2698,6 +2699,7 @@ out:
>  void qmp_block_dirty_bitmap_add(const char *node, const char *name,
>  bool has_granularity, uint32_t granularity,
>  bool has_persistent, bool persistent,
> +bool has_autoload, bool autoload,
>  Error **errp)
>  {
>  AioContext *aio_context;
> @@ -2731,6 +2733,15 @@ void qmp_block_dirty_bitmap_add(const char *node, 
> const char *name,
>  if (!has_persistent) {
>  persistent = false;
>  }
> +if (!has_autoload) {
> +autoload = false;
> +}
> +
> +if (has_autoload && !persistent) {
> +error_setg(errp, "Autoload flag must be used only for persistent "
> + "bitmaps");
> +goto out;
> +}
>  
>  if (persistent &&
>  !bdrv_can_store_dirty_bitmap(bs, name, granularity, errp)) {
> @@ -2738,10 +2749,13 @@ void qmp_block_dirty_bitmap_add(const char *node, 
> const char *name,
>  }
>  
>  bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp);
> -if (bitmap != NULL) {
> -bdrv_dirty_bitmap_set_persistance(bitmap, persistent);
> +if (bitmap == NULL) {
> +goto out;
>  }
>  
> +bdrv_dirty_bitmap_set_persistance(bitmap, persistent);
> +bdrv_dirty_bitmap_set_autoload(bitmap, autoload);
> +
>   out:
>  aio_context_release(aio_context);
>  }
> diff --git a/docs/qmp-commands.txt b/docs/qmp-commands.txt
> index c4ad1e4..dda2911 100644
> --- a/docs/qmp-commands.txt
> +++ b/docs/qmp-commands.txt
> @@ -1018,6 +1018,10 @@ Arguments:
>  - "persistent": bitmap will be saved to the corresponding block device image
>  file on its close. For now only Qcow2 disks support 
> persistent
>  bitmaps. (json-bool, optional, default false) (Since 2.8)
> +- "autoload": the bitmap will be automatically loaded when the image it is
> +  stored in is opened. This flag may only be specified for
> +  persistent bitmaps (json-bool, optional, default false)
> +  (Since 2.8)

*2.9

>  
>  Example:
>  
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index cec312c..648f94a 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -1235,11 +1235,15 @@
>  #  corresponding block device image file on its close. Default is
>  #  false. (Since 2.8)
>  #
> +# @autoload: #optional the bitmap will be automatically loaded when the image
> +#it is stored in is opened. This flag may only be specified for
> +#persistent bitmaps. Default is false. (Since 2.8)

*2.9

With both fixed:

Reviewed-by: Max Reitz 

> +#
>  # Since 2.4
>  ##
>  { 'struct': 'BlockDirtyBitmapAdd',
>'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32',
> -'*persistent': 'bool' } }
> +'*persistent': 'bool', '*autoload': 'bool' } }
>  
>  ##
>  # @block-dirty-bitmap-add
> 




signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH v3 0/1] migration: disallow migrate_add_blocker during migration

2016-12-09 Thread no-reply
Hi,

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

Subject: [Qemu-devel] [PATCH v3 0/1] migration: disallow migrate_add_blocker 
during migration
Type: series
Message-id: 20161209172547.31550-1-js...@redhat.com

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

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

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

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
Switched to a new branch 'test'
bebd3d0 migration: disallow migrate_add_blocker during migration

=== OUTPUT BEGIN ===
Checking PATCH 1/1: migration: disallow migrate_add_blocker during migration...
ERROR: do not use C99 // comments
#158: FILE: block/vvfat.c:1205:
+//assert(is_consistent(s));

total: 1 errors, 0 warnings, 394 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.

=== OUTPUT END ===

Test command exited with code: 1


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

Re: [Qemu-devel] [PATCH v3 1/1] migration: disallow migrate_add_blocker during migration

2016-12-09 Thread Dr. David Alan Gilbert
* John Snow (js...@redhat.com) wrote:
> If a migration is already in progress and somebody attempts
> to add a migration blocker, this should rightly fail.
> 
> Add an errp parameter and a retcode return value to migrate_add_blocker.
> 
> Signed-off-by: John Snow 
> ---
>  block/qcow.c  |  6 +-
>  block/vdi.c   |  6 +-
>  block/vhdx.c  | 24 ++--
>  block/vmdk.c  |  7 ++-
>  block/vpc.c   | 10 +++---
>  block/vvfat.c | 20 
>  hw/9pfs/9p.c  | 16 
>  hw/display/virtio-gpu.c   | 29 -
>  hw/misc/ivshmem.c | 11 +++
>  hw/scsi/vhost-scsi.c  | 25 +++--
>  hw/virtio/vhost.c |  8 +++-
>  include/migration/migration.h |  6 +-
>  migration/migration.c | 35 +--
>  stubs/migr-blocker.c  |  3 ++-
>  target-i386/kvm.c | 16 +---
>  15 files changed, 163 insertions(+), 59 deletions(-)
> 
> diff --git a/block/qcow.c b/block/qcow.c
> index 7540f43..11526a1 100644
> --- a/block/qcow.c
> +++ b/block/qcow.c
> @@ -252,7 +252,11 @@ static int qcow_open(BlockDriverState *bs, QDict 
> *options, int flags,
>  error_setg(>migration_blocker, "The qcow format used by node '%s' "
> "does not support live migration",
> bdrv_get_device_or_node_name(bs));
> -migrate_add_blocker(s->migration_blocker);
> +ret = migrate_add_blocker(s->migration_blocker, errp);
> +if (ret < 0) {
> +error_free(s->migration_blocker);
> +goto fail;
> +}
>  
>  qemu_co_mutex_init(>lock);
>  return 0;
> diff --git a/block/vdi.c b/block/vdi.c
> index 96b78d5..2b56f52 100644
> --- a/block/vdi.c
> +++ b/block/vdi.c
> @@ -471,7 +471,11 @@ static int vdi_open(BlockDriverState *bs, QDict 
> *options, int flags,
>  error_setg(>migration_blocker, "The vdi format used by node '%s' "
> "does not support live migration",
> bdrv_get_device_or_node_name(bs));
> -migrate_add_blocker(s->migration_blocker);
> +ret = migrate_add_blocker(s->migration_blocker, errp);
> +if (ret < 0) {
> +error_free(s->migration_blocker);
> +goto fail_free_bmap;
> +}
>  
>  qemu_co_mutex_init(>write_lock);
>  
> diff --git a/block/vhdx.c b/block/vhdx.c
> index 0ba2f0a..d81941b 100644
> --- a/block/vhdx.c
> +++ b/block/vhdx.c
> @@ -991,20 +991,24 @@ static int vhdx_open(BlockDriverState *bs, QDict 
> *options, int flags,
>  }
>  }
>  
> -if (flags & BDRV_O_RDWR) {
> -ret = vhdx_update_headers(bs, s, false, NULL);
> -if (ret < 0) {
> -goto fail;
> -}
> -}
> -
> -/* TODO: differencing files */
> -
>  /* Disable migration when VHDX images are used */
>  error_setg(>migration_blocker, "The vhdx format used by node '%s' "
> "does not support live migration",
> bdrv_get_device_or_node_name(bs));
> -migrate_add_blocker(s->migration_blocker);
> +ret = migrate_add_blocker(s->migration_blocker, errp);
> +if (ret < 0) {
> +error_free(s->migration_blocker);
> +goto fail;
> +}
> +
> +if (flags & BDRV_O_RDWR) {
> +ret = vhdx_update_headers(bs, s, false, NULL);
> +if (ret < 0) {
> +goto fail;
> +}
> +}
> +
> +/* TODO: differencing files */
>  
>  return 0;
>  fail:
> diff --git a/block/vmdk.c b/block/vmdk.c
> index a11c27a..4a45a83 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -976,7 +976,12 @@ static int vmdk_open(BlockDriverState *bs, QDict 
> *options, int flags,
>  error_setg(>migration_blocker, "The vmdk format used by node '%s' "
> "does not support live migration",
> bdrv_get_device_or_node_name(bs));
> -migrate_add_blocker(s->migration_blocker);
> +ret = migrate_add_blocker(s->migration_blocker, errp);
> +if (ret < 0) {
> +error_free(s->migration_blocker);
> +goto fail;
> +}
> +
>  g_free(buf);
>  return 0;
>  
> diff --git a/block/vpc.c b/block/vpc.c
> index 8d5886f..299a8c8 100644
> --- a/block/vpc.c
> +++ b/block/vpc.c
> @@ -422,13 +422,17 @@ static int vpc_open(BlockDriverState *bs, QDict 
> *options, int flags,
>  #endif
>  }
>  
> -qemu_co_mutex_init(>lock);
> -
>  /* Disable migration when VHD images are used */
>  error_setg(>migration_blocker, "The vpc format used by node '%s' "
> "does not support live migration",
> bdrv_get_device_or_node_name(bs));
> -migrate_add_blocker(s->migration_blocker);
> +ret = migrate_add_blocker(s->migration_blocker, errp);
> +if (ret < 0) {
> +error_free(s->migration_blocker);
> +goto fail;
> +}
> +
> +

Re: [Qemu-devel] [PATCH 16/21] qmp: add persistent flag to block-dirty-bitmap-add

2016-12-09 Thread Max Reitz
On 22.11.2016 18:26, Vladimir Sementsov-Ogievskiy wrote:
> Add optional 'persistent' flag to qmp command block-dirty-bitmap-add.
> Default is false.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> Signed-off-by: Denis V. Lunev 
> ---
>  blockdev.c| 17 -
>  docs/qmp-commands.txt |  3 +++
>  qapi/block-core.json  |  7 ++-
>  3 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 245e1e1..3876d1d 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1967,6 +1967,7 @@ static void 
> block_dirty_bitmap_add_prepare(BlkActionState *common,
>  /* AIO context taken and released within qmp_block_dirty_bitmap_add */
>  qmp_block_dirty_bitmap_add(action->node, action->name,
> action->has_granularity, action->granularity,
> +   action->has_persistent, action->persistent,
> _err);
>  
>  if (!local_err) {
> @@ -2696,10 +2697,12 @@ out:
>  
>  void qmp_block_dirty_bitmap_add(const char *node, const char *name,
>  bool has_granularity, uint32_t granularity,
> +bool has_persistent, bool persistent,
>  Error **errp)
>  {
>  AioContext *aio_context;
>  BlockDriverState *bs;
> +BdrvDirtyBitmap *bitmap;
>  
>  if (!name || name[0] == '\0') {
>  error_setg(errp, "Bitmap name cannot be empty");
> @@ -2725,7 +2728,19 @@ void qmp_block_dirty_bitmap_add(const char *node, 
> const char *name,
>  granularity = bdrv_get_default_bitmap_granularity(bs);
>  }
>  
> -bdrv_create_dirty_bitmap(bs, granularity, name, errp);
> +if (!has_persistent) {
> +persistent = false;
> +}
> +
> +if (persistent &&
> +!bdrv_can_store_dirty_bitmap(bs, name, granularity, errp)) {

Alignment to the opening parenthesis, please.

(Also, this may need a change depending on whether you want to rename it
to bdrv_can_store_new_dirty_bitmap().)

With that and the s/2\.8/2.9/ below fixed:

Reviewed-by: Max Reitz 

> +goto out;
> +}
> +
> +bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp);
> +if (bitmap != NULL) {
> +bdrv_dirty_bitmap_set_persistance(bitmap, persistent);
> +}
>  
>   out:
>  aio_context_release(aio_context);
> diff --git a/docs/qmp-commands.txt b/docs/qmp-commands.txt
> index abf210a..c4ad1e4 100644
> --- a/docs/qmp-commands.txt
> +++ b/docs/qmp-commands.txt
> @@ -1015,6 +1015,9 @@ Arguments:
>  - "node": device/node on which to create dirty bitmap (json-string)
>  - "name": name of the new dirty bitmap (json-string)
>  - "granularity": granularity to track writes with (int, optional)
> +- "persistent": bitmap will be saved to the corresponding block device image
> +file on its close. For now only Qcow2 disks support 
> persistent
> +bitmaps. (json-bool, optional, default false) (Since 2.8)
>  
>  Example:
>  
> diff --git a/qapi/block-core.json b/qapi/block-core.json
> index c29bef7..cec312c 100644
> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -1231,10 +1231,15 @@
>  # @granularity: #optional the bitmap granularity, default is 64k for
>  #   block-dirty-bitmap-add
>  #
> +# @persistent: #optional the bitmap is persistent, i.e. it will be saved to 
> the
> +#  corresponding block device image file on its close. Default is
> +#  false. (Since 2.8)
> +#
>  # Since 2.4
>  ##
>  { 'struct': 'BlockDirtyBitmapAdd',
> -  'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32' } }
> +  'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32',
> +'*persistent': 'bool' } }
>  
>  ##
>  # @block-dirty-bitmap-add
> 




signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH 15/21] qcow2: add .bdrv_can_store_dirty_bitmap

2016-12-09 Thread Max Reitz
On 22.11.2016 18:26, Vladimir Sementsov-Ogievskiy wrote:
> Realize .bdrv_can_store_dirty_bitmap interface.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>  block/qcow2-bitmap.c | 40 
>  block/qcow2.c|  1 +
>  block/qcow2.h|  4 
>  3 files changed, 45 insertions(+)
> 
> diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
> index a975388..55b1112 100644
> --- a/block/qcow2-bitmap.c
> +++ b/block/qcow2-bitmap.c
> @@ -1115,3 +1115,43 @@ fail:
>  
>  bitmap_list_free(bm_list);
>  }
> +
> +bool qcow2_can_store_dirty_bitmap(BlockDriverState *bs,
> +  const char *name,
> +  uint32_t granularity,
> +  Error **errp)
> +{
> +BDRVQcow2State *s = bs->opaque;
> +const char *reason = NULL;
> +bool found;
> +Qcow2BitmapList *bm_list;
> +
> +if (check_constraints_on_bitmap(bs, name, granularity) != 0) {
> +reason = "it doesn't satisfy the constraints";
> +goto common_errp;
> +}
> +
> +if (s->nb_bitmaps == 0) {
> +return true;
> +}
> +
> +bm_list = bitmap_list_load(bs, s->bitmap_directory_offset,
> +   s->bitmap_directory_size, errp);

Maybe it would make sense to keep the bitmap list in memory...

> +if (bm_list == NULL) {
> +return false;
> +}
> +
> +found = !!find_bitmap_by_name(bm_list, name);

You can omit the !!, storing it in a bool will do that for you.

> +bitmap_list_free(bm_list);
> +if (found) {
> +reason = "bitmap with the same name is already stored";
> +goto common_errp;
> +}
> +
> +return true;
> +
> +common_errp:
> +error_setg(errp, "Can't make bitmap '%s' persistent in '%s', as %s.",
> +   name, bdrv_get_device_or_node_name(bs), reason);

Hm, so this function isn't for checking whether a bitmap can be stored,
but whether it can be made persistent. That's a difference; you can
store a bitmap of the same name in the file if you want to overwrite it
(i.e. it's an auto-load bitmap), but you cannot create a new bitmap with
the same name.

Maybe rename it from bdrv_can_store_dirty_bitmap to
bdrv_can_store_new_dirty_bitmap?

Max

> +return false;
> +}
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 66c7f74..cb9c2a2 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -3516,6 +3516,7 @@ BlockDriver bdrv_qcow2 = {
>  
>  .bdrv_load_autoloading_dirty_bitmaps = 
> qcow2_load_autoloading_dirty_bitmaps,
>  .bdrv_store_persistent_dirty_bitmaps = 
> qcow2_store_persistent_dirty_bitmaps,
> +.bdrv_can_store_dirty_bitmap = qcow2_can_store_dirty_bitmap,
>  };
>  
>  static void bdrv_qcow2_init(void)
> diff --git a/block/qcow2.h b/block/qcow2.h
> index d9a7643..e7a44a1 100644
> --- a/block/qcow2.h
> +++ b/block/qcow2.h
> @@ -616,5 +616,9 @@ void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, 
> void **table);
>  /* qcow2-bitmap.c functions */
>  void qcow2_load_autoloading_dirty_bitmaps(BlockDriverState *bs, Error 
> **errp);
>  void qcow2_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error 
> **errp);
> +bool qcow2_can_store_dirty_bitmap(BlockDriverState *bs,
> +  const char *name,
> +  uint32_t granularity,
> +  Error **errp);
>  
>  #endif
> 




signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH kvm-unit-tests v8 09/10] arm/arm64: gicv3: add an IPI test

2016-12-09 Thread Andrew Jones
On Fri, Dec 09, 2016 at 04:08:00PM +, Andre Przywara wrote:
> On 08/12/16 17:50, Andrew Jones wrote:
> > +u32 gicv3_iar_irqnr(u32 iar)
> > +{
> > +   return iar;
> 
> I am probably a bit paranoid here, but the spec says that the interrupt
> ID is in bits[23:0] only (at most).

Indeed, I'll add '& ((1 << 24) - 1' here.

> 
> > +}
> > +
> > +void gicv3_ipi_send_mask(int irq, const cpumask_t *dest)
> > +{
> > +   u16 tlist;
> > +   int cpu;
> > +
> > +   assert(irq < 16);
> > +
> > +   /*
> > +* For each cpu in the mask collect its peers, which are also in
> > +* the mask, in order to form target lists.
> > +*/
> > +   for_each_cpu(cpu, dest) {
> > +   u64 mpidr = cpus[cpu], sgi1r;
> > +   u64 cluster_id;
> > +
> > +   /*
> > +* GICv3 can send IPIs to up 16 peer cpus with a single
> > +* write to ICC_SGI1R_EL1 (using the target list). Peers
> > +* are cpus that have nearly identical MPIDRs, the only
> > +* difference being Aff0. The matching upper affinity
> > +* levels form the cluster ID.
> > +*/
> > +   cluster_id = mpidr & ~0xffUL;
> > +   tlist = 0;
> > +
> > +   /*
> > +* Sort of open code for_each_cpu in order to have a
> > +* nested for_each_cpu loop.
> > +*/
> > +   while (cpu < nr_cpus) {
> > +   if ((mpidr & 0xff) >= 16) {
> > +   printf("cpu%d MPIDR:aff0 is %d (>= 16)!\n",
> > +   cpu, (int)(mpidr & 0xff));
> > +   break;
> > +   }
> > +
> > +   tlist |= 1 << (mpidr & 0xf);
> > +
> > +   cpu = cpumask_next(cpu, dest);
> > +   if (cpu >= nr_cpus)
> > +   break;
> > +
> > +   mpidr = cpus[cpu];
> > +
> > +   if (cluster_id != (mpidr & ~0xffUL)) {
> > +   /*
> > +* The next cpu isn't in our cluster. Roll
> > +* back the cpu index allowing the outer
> > +* for_each_cpu to find it again with
> > +* cpumask_next
> > +*/
> > +   --cpu;
> > +   break;
> > +   }
> > +   }
> > +
> > +   /* Send the IPIs for the target list of this cluster */
> > +   sgi1r = (MPIDR_TO_SGI_AFFINITY(cluster_id, 3)   |
> > +MPIDR_TO_SGI_AFFINITY(cluster_id, 2)   |
> > +irq << 24  |
> > +MPIDR_TO_SGI_AFFINITY(cluster_id, 1)   |
> > +tlist);
> > +
> > +   gicv3_write_sgi1r(sgi1r);
> > +   }
> > +
> > +   /* Force the above writes to ICC_SGI1R_EL1 to be executed */
> > +   isb();
> > +}
> 
> Wow, this is really heavy stuff, especially for a Friday afternoon ;-)
> But I convinced myself that it's correct. The only issue is that it's
> sub-optimal if the MPIDRs of the VCPUs are not in order, say: 0x000,
> 0x100, 0x001.
> In this case we do three register writes instead of the minimal two.
> But it's still correct, so it's actually a minor nit just to prove that
> I checked the algorithm ;-)
> 
> So apart from the minor comment above:
> 
> Reviewed-by: Andre Przywara 

Thanks!
drew



[Qemu-devel] [PATCH v3 1/1] migration: disallow migrate_add_blocker during migration

2016-12-09 Thread John Snow
If a migration is already in progress and somebody attempts
to add a migration blocker, this should rightly fail.

Add an errp parameter and a retcode return value to migrate_add_blocker.

Signed-off-by: John Snow 
---
 block/qcow.c  |  6 +-
 block/vdi.c   |  6 +-
 block/vhdx.c  | 24 ++--
 block/vmdk.c  |  7 ++-
 block/vpc.c   | 10 +++---
 block/vvfat.c | 20 
 hw/9pfs/9p.c  | 16 
 hw/display/virtio-gpu.c   | 29 -
 hw/misc/ivshmem.c | 11 +++
 hw/scsi/vhost-scsi.c  | 25 +++--
 hw/virtio/vhost.c |  8 +++-
 include/migration/migration.h |  6 +-
 migration/migration.c | 35 +--
 stubs/migr-blocker.c  |  3 ++-
 target-i386/kvm.c | 16 +---
 15 files changed, 163 insertions(+), 59 deletions(-)

diff --git a/block/qcow.c b/block/qcow.c
index 7540f43..11526a1 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -252,7 +252,11 @@ static int qcow_open(BlockDriverState *bs, QDict *options, 
int flags,
 error_setg(>migration_blocker, "The qcow format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
-migrate_add_blocker(s->migration_blocker);
+ret = migrate_add_blocker(s->migration_blocker, errp);
+if (ret < 0) {
+error_free(s->migration_blocker);
+goto fail;
+}
 
 qemu_co_mutex_init(>lock);
 return 0;
diff --git a/block/vdi.c b/block/vdi.c
index 96b78d5..2b56f52 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -471,7 +471,11 @@ static int vdi_open(BlockDriverState *bs, QDict *options, 
int flags,
 error_setg(>migration_blocker, "The vdi format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
-migrate_add_blocker(s->migration_blocker);
+ret = migrate_add_blocker(s->migration_blocker, errp);
+if (ret < 0) {
+error_free(s->migration_blocker);
+goto fail_free_bmap;
+}
 
 qemu_co_mutex_init(>write_lock);
 
diff --git a/block/vhdx.c b/block/vhdx.c
index 0ba2f0a..d81941b 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -991,20 +991,24 @@ static int vhdx_open(BlockDriverState *bs, QDict 
*options, int flags,
 }
 }
 
-if (flags & BDRV_O_RDWR) {
-ret = vhdx_update_headers(bs, s, false, NULL);
-if (ret < 0) {
-goto fail;
-}
-}
-
-/* TODO: differencing files */
-
 /* Disable migration when VHDX images are used */
 error_setg(>migration_blocker, "The vhdx format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
-migrate_add_blocker(s->migration_blocker);
+ret = migrate_add_blocker(s->migration_blocker, errp);
+if (ret < 0) {
+error_free(s->migration_blocker);
+goto fail;
+}
+
+if (flags & BDRV_O_RDWR) {
+ret = vhdx_update_headers(bs, s, false, NULL);
+if (ret < 0) {
+goto fail;
+}
+}
+
+/* TODO: differencing files */
 
 return 0;
 fail:
diff --git a/block/vmdk.c b/block/vmdk.c
index a11c27a..4a45a83 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -976,7 +976,12 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, 
int flags,
 error_setg(>migration_blocker, "The vmdk format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
-migrate_add_blocker(s->migration_blocker);
+ret = migrate_add_blocker(s->migration_blocker, errp);
+if (ret < 0) {
+error_free(s->migration_blocker);
+goto fail;
+}
+
 g_free(buf);
 return 0;
 
diff --git a/block/vpc.c b/block/vpc.c
index 8d5886f..299a8c8 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -422,13 +422,17 @@ static int vpc_open(BlockDriverState *bs, QDict *options, 
int flags,
 #endif
 }
 
-qemu_co_mutex_init(>lock);
-
 /* Disable migration when VHD images are used */
 error_setg(>migration_blocker, "The vpc format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
-migrate_add_blocker(s->migration_blocker);
+ret = migrate_add_blocker(s->migration_blocker, errp);
+if (ret < 0) {
+error_free(s->migration_blocker);
+goto fail;
+}
+
+qemu_co_mutex_init(>lock);
 
 return 0;
 
diff --git a/block/vvfat.c b/block/vvfat.c
index ded2109..3de3320 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -1185,22 +1185,26 @@ static int vvfat_open(BlockDriverState *bs, QDict 
*options, int flags,
 
 s->sector_count = s->faked_sectors + 

[Qemu-devel] [PATCH v3 0/1] migration: disallow migrate_add_blocker during migration

2016-12-09 Thread John Snow
As discussed on-list, this may be a necessary building block for
a run-time flag that prevents us from getting into any situations
where we configure a non-migratable QEMU.

I'd like extra attention to be paid to the virtio-gpu, vhost, and
ivshmem changes as I am not perfectly confident in those.

Sorry for the wide CC distributions.

V3: Rebased from a version I sent about a year ago.
Changed the migration function names a bit,
Changed new calls to migrate_add_blocker.

John Snow (1):
  migration: disallow migrate_add_blocker during migration

 block/qcow.c  |  6 +-
 block/vdi.c   |  6 +-
 block/vhdx.c  | 24 ++--
 block/vmdk.c  |  7 ++-
 block/vpc.c   | 10 +++---
 block/vvfat.c | 20 
 hw/9pfs/9p.c  | 16 
 hw/display/virtio-gpu.c   | 29 -
 hw/misc/ivshmem.c | 11 +++
 hw/scsi/vhost-scsi.c  | 25 +++--
 hw/virtio/vhost.c |  8 +++-
 include/migration/migration.h |  6 +-
 migration/migration.c | 35 +--
 stubs/migr-blocker.c  |  3 ++-
 target-i386/kvm.c | 16 +---
 15 files changed, 163 insertions(+), 59 deletions(-)

-- 
2.9.3




Re: [Qemu-devel] [PATCH v4 61/64] qemu/host-utils.h: Reduce the operation count in the fallback ctpop

2016-12-09 Thread Richard Henderson
On 12/09/2016 06:41 AM, Alex Bennée wrote:
> +struct bitcnt_test_data sixtyfour_bit_data[] = {
> +{ { .w64 = 0x0001 }, .popct=1 },

Thanks.  Merged with added ULL for the 64-bit data.


r~



Re: [Qemu-devel] [PATCH 03/19] check-help: add some hint to run a single test

2016-12-09 Thread Alex Bennée

Pranith Kumar  writes:

> From: Marc-André Lureau 
>
> It's possible to run the test directly, tests/test-foo, but then
> recompilation is not triggered and test environment variables aren't set
> for you.
>
> Signed-off-by: Marc-André Lureau 
> Signed-off-by: Pranith Kumar 

Reviewed-by: Alex Bennée 

> ---
>  tests/Makefile.include | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index e98d3b6..2a2b78d 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -731,6 +731,7 @@ check-help:
>   @echo " make check-qtest-TARGET   Run qtest tests for given target"
>   @echo " make check-qtest  Run qtest tests"
>   @echo " make check-unit   Run qobject tests"
> + @echo " make check-tests/test-foo Run the tests/test-foo unit test only"
>   @echo " make check-qapi-schemaRun QAPI schema tests"
>   @echo " make check-block  Run block tests"
>   @echo " make check-report.htmlGenerates an HTML test report"


--
Alex Bennée



Re: [Qemu-devel] [PATCH 04/19] tests/tcg: comment unused code

2016-12-09 Thread Alex Bennée

Pranith Kumar  writes:

> From: Marc-André Lureau 
>
> I didn't remove it, as suggest by checkpatch, because it looks like it
> may eventually be restored back.

I'm not so sure, especially with having full source control. Either fix
it or delete it please.

>
> Signed-off-by: Marc-André Lureau 
> Signed-off-by: Pranith Kumar 
> ---
>  tests/tcg/linux-test.c  | 8 ++--
>  tests/tcg/test-i386-fprem.c | 4 
>  2 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c
> index 5070d31..38d163c 100644
> --- a/tests/tcg/linux-test.c
> +++ b/tests/tcg/linux-test.c
> @@ -350,6 +350,7 @@ void test_socket(void)
>
>  #define WCOUNT_MAX 512
>
> +#if 0
>  void test_pipe(void)
>  {
>  fd_set rfds, wfds;
> @@ -421,11 +422,13 @@ void test_clone(void)
>
>  stack1 = malloc(STACK_SIZE);
>  pid1 = chk_error(clone(thread1_func, stack1 + STACK_SIZE,
> -   CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, 
> "hello1"));
> +   CLONE_VM | CLONE_FS | CLONE_FILES |
> +   SIGCHLD, (void *)"hello1"));
>
>  stack2 = malloc(STACK_SIZE);
>  pid2 = chk_error(clone(thread2_func, stack2 + STACK_SIZE,
> -   CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, 
> "hello2"));
> +   CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD,
> +   (void *)"hello2"));
>
>  while (waitpid(pid1, , 0) != pid1);
>  free(stack1);
> @@ -435,6 +438,7 @@ void test_clone(void)
>  thread2_res != 6)
>  error("clone");
>  }
> +#endif
>
>  /***/
>
> diff --git a/tests/tcg/test-i386-fprem.c b/tests/tcg/test-i386-fprem.c
> index 1a71623..1a2b144 100644
> --- a/tests/tcg/test-i386-fprem.c
> +++ b/tests/tcg/test-i386-fprem.c
> @@ -54,6 +54,7 @@ union float80u {
>
>  #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
>
> +#if 0
>  static const union float80u q_nan = {
>  .ieee_nan.negative = 0,  /* X */
>  .ieee_nan.exponent = 0x7fff,
> @@ -61,6 +62,7 @@ static const union float80u q_nan = {
>  .ieee_nan.quiet_nan = 1,
>  .ieee_nan.mantissa = 0,
>  };
> +#endif
>
>  static const union float80u s_nan = {
>  .ieee_nan.negative = 0,  /* X */
> @@ -91,12 +93,14 @@ static const union float80u pos_denorm = {
>  .ieee.mantissa = 1,
>  };
>
> +#if 0
>  static const union float80u smallest_positive_norm = {
>  .ieee.negative = 0,
>  .ieee.exponent = 1,
>  .ieee.one = 1,
>  .ieee.mantissa = 0,
>  };
> +#endif
>
>  static void fninit()
>  {


--
Alex Bennée



Re: [Qemu-devel] [PATCH 02/19] linux-user: fix tcg/mmap test

2016-12-09 Thread Alex Bennée

Pranith Kumar  writes:

> From: Marc-André Lureau 
>
> tests/tcg/mmap test fails with values other than default target page
> size. When creating a map beyond EOF, extra anonymous pages are added up
> to the target page boundary. Currently, this operation is performed only
> when qemu_real_host_page_size < TARGET_PAGE_SIZE, but it should be
> performed if the configured page size (qemu -p) is larger than
> qemu_real_host_page_size too.
>
> (also fixes some style issues to please checkpatch)
>
> Signed-off-by: Marc-André Lureau 
> Signed-off-by: Pranith Kumar 

Reviewed-by: Alex Bennée 

but again doesn't really need to be in this series

> ---
>  linux-user/mmap.c | 27 ++-
>  1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/linux-user/mmap.c b/linux-user/mmap.c
> index 61685bf..0794a43 100644
> --- a/linux-user/mmap.c
> +++ b/linux-user/mmap.c
> @@ -418,31 +418,32 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, 
> int prot,
>  }
>
>  /* When mapping files into a memory area larger than the file, accesses
> -   to pages beyond the file size will cause a SIGBUS.
> +   to pages beyond the file size will cause a SIGBUS.
>
> For example, if mmaping a file of 100 bytes on a host with 4K pages
> emulating a target with 8K pages, the target expects to be able to
> access the first 8K. But the host will trap us on any access beyond
> -   4K.
> +   4K.
>
> When emulating a target with a larger page-size than the hosts, we
> may need to truncate file maps at EOF and add extra anonymous pages
> up to the targets page boundary.  */
>
> -if ((qemu_real_host_page_size < TARGET_PAGE_SIZE)
> -&& !(flags & MAP_ANONYMOUS)) {
> -   struct stat sb;
> +if ((qemu_real_host_page_size < qemu_host_page_size) &&
> +!(flags & MAP_ANONYMOUS)) {
> +struct stat sb;
>
> -   if (fstat (fd, ) == -1)
> -   goto fail;
> +if (fstat(fd, ) == -1) {
> +goto fail;
> +}
>
> /* Are we trying to create a map beyond EOF?.  */
> -   if (offset + len > sb.st_size) {
> -   /* If so, truncate the file map at eof aligned with
> -  the hosts real pagesize. Additional anonymous maps
> -  will be created beyond EOF.  */
> -   len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset);
> -   }
> +if (offset + len > sb.st_size) {
> +/* If so, truncate the file map at eof aligned with
> +   the hosts real pagesize. Additional anonymous maps
> +   will be created beyond EOF.  */
> +len = REAL_HOST_PAGE_ALIGN(sb.st_size - offset);
> +}
>  }
>
>  if (!(flags & MAP_FIXED)) {


--
Alex Bennée



Re: [Qemu-devel] [PATCH 14/21] block: add bdrv_can_store_dirty_bitmap

2016-12-09 Thread Max Reitz
On 22.11.2016 18:26, Vladimir Sementsov-Ogievskiy wrote:
> This will be needed to check some restrictions before making bitmap
> persistent in qmp-block-dirty-bitmap-add (this functionality will be
> added by future patch)
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>  block.c   | 22 ++
>  include/block/block.h |  2 ++
>  include/block/block_int.h |  2 ++
>  3 files changed, 26 insertions(+)

Reviewed-by: Max Reitz 



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [for-2.9 2/5] pseries: Stubs for HPT resizing

2016-12-09 Thread Michael Roth
Quoting David Gibson (2016-12-08 20:23:11)
> This introduces stub implementations of the H_RESIZE_HPT_PREPARE and
> H_RESIZE_HPT_COMMIT hypercalls which we hope to add in a PAPR
> extension to allow run time resizing of a guest's hash page table.  It
> also adds a new machine property for controlling whether this new
> facility is available, and logic to check that against availability
> with KVM (only supported with KVM PR for now).
> 
> Finally, it adds a new string to the hypertas property in the device
> tree, advertising to the guest the availability of the HPT resizing
> hypercalls.  This is a tentative suggested value, and would need to be
> standardized by PAPR before being merged.
> 
> Signed-off-by: David Gibson 
> ---
>  hw/ppc/spapr.c | 66 
> ++
>  hw/ppc/spapr_hcall.c   | 36 +++
>  hw/ppc/trace-events|  2 ++
>  include/hw/ppc/spapr.h | 11 +
>  target-ppc/kvm.c   | 26 
>  target-ppc/kvm_ppc.h   |  5 
>  6 files changed, 146 insertions(+)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 0f25e83..ecb0822 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -760,6 +760,11 @@ static void spapr_dt_rtas(sPAPRMachineState *spapr, void 
> *fdt)
>  if (!kvm_enabled() || kvmppc_spapr_use_multitce()) {
>  add_str(hypertas, "hcall-multi-tce");
>  }
> +
> +if (spapr->resize_hpt != SPAPR_RESIZE_HPT_DISABLED) {
> +add_str(hypertas, "hcall-hpt-resize");
> +}
> +
>  _FDT(fdt_setprop(fdt, rtas, "ibm,hypertas-functions",
>   hypertas->str, hypertas->len));
>  g_string_free(hypertas, TRUE);
> @@ -1839,11 +1844,31 @@ static void ppc_spapr_init(MachineState *machine)
>  long load_limit, fw_size;
>  char *filename;
>  int smt = kvmppc_smt_threads();
> +Error *resize_hpt_err = NULL;
> 
>  msi_nonbroken = true;
> 
>  QLIST_INIT(>phbs);
> 
> +/* Check HPT resizing availability */
> +kvmppc_check_papr_resize_hpt(_hpt_err);
> +if (spapr->resize_hpt == SPAPR_RESIZE_HPT_DEFAULT) {
> +if (resize_hpt_err) {
> +spapr->resize_hpt = SPAPR_RESIZE_HPT_DISABLED;
> +error_free(resize_hpt_err);
> +resize_hpt_err = NULL;
> +} else {
> +spapr->resize_hpt = smc->resize_hpt_default;
> +}
> +}
> +
> +assert(spapr->resize_hpt != SPAPR_RESIZE_HPT_DEFAULT);
> +
> +if ((spapr->resize_hpt != SPAPR_RESIZE_HPT_DISABLED) && resize_hpt_err) {
> +error_report_err(resize_hpt_err);
> +exit(1);
> +}

I'm also a bit confused by this. Aren't semantics that HPT_ENABLED will allow
a fallback to non-resizable HPTs if the feature isn't available (whereas
HPT_REQUIRED won't)? I don't understand how such a fallback can ever be reached
with this check in place.

> +
>  /* Allocate RMA if necessary */
>  rma_alloc_size = kvmppc_alloc_rma();
> 
> @@ -2236,6 +2261,40 @@ static void spapr_set_modern_hotplug_events(Object 
> *obj, bool value,
>  spapr->use_hotplug_event_source = value;
>  }
> 
> +static char *spapr_get_resize_hpt(Object *obj, Error **errp)
> +{
> +sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> +
> +switch (spapr->resize_hpt) {
> +case SPAPR_RESIZE_HPT_DEFAULT:
> +return g_strdup("default");
> +case SPAPR_RESIZE_HPT_DISABLED:
> +return g_strdup("disabled");
> +case SPAPR_RESIZE_HPT_ENABLED:
> +return g_strdup("enabled");
> +case SPAPR_RESIZE_HPT_REQUIRED:
> +return g_strdup("required");
> +}
> +assert(0);
> +}
> +
> +static void spapr_set_resize_hpt(Object *obj, const char *value, Error 
> **errp)
> +{
> +sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> +
> +if (strcmp(value, "default") == 0) {
> +spapr->resize_hpt = SPAPR_RESIZE_HPT_DEFAULT;
> +} else if (strcmp(value, "disabled") == 0) {
> +spapr->resize_hpt = SPAPR_RESIZE_HPT_DISABLED;
> +} else if (strcmp(value, "enabled") == 0) {
> +spapr->resize_hpt = SPAPR_RESIZE_HPT_ENABLED;
> +} else if (strcmp(value, "required") == 0) {
> +spapr->resize_hpt = SPAPR_RESIZE_HPT_REQUIRED;
> +} else {
> +error_setg(errp, "Bad value for \"resize-hpt\" property");
> +}
> +}
> +
>  static void spapr_machine_initfn(Object *obj)
>  {
>  sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> @@ -2256,6 +2315,12 @@ static void spapr_machine_initfn(Object *obj)
>  " place of standard EPOW events when 
> possible"
>  " (required for memory hot-unplug 
> support)",
>  NULL);
> +
> +object_property_add_str(obj, "resize-hpt",
> +spapr_get_resize_hpt, spapr_set_resize_hpt, 
> NULL);
> +object_property_set_description(obj, "resize-hpt",
> +"Resizing 

Re: [Qemu-devel] [PATCH 13/21] qcow2: add .bdrv_store_persistent_dirty_bitmaps()

2016-12-09 Thread Max Reitz
On 22.11.2016 18:26, Vladimir Sementsov-Ogievskiy wrote:
> Realize block bitmap storing interface, to allow qcow2 images store
> persistent bitmaps.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy 
> ---
>  block/qcow2-bitmap.c | 451 
> +++
>  block/qcow2.c|   1 +
>  block/qcow2.h|   1 +
>  3 files changed, 453 insertions(+)
> 
> diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
> index 81be1ca..a975388 100644
> --- a/block/qcow2-bitmap.c
> +++ b/block/qcow2-bitmap.c
> @@ -28,6 +28,7 @@
>  #include "qemu/osdep.h"
>  #include "qapi/error.h"
>  #include "exec/log.h"
> +#include "qemu/cutils.h"
>  
>  #include "block/block_int.h"
>  #include "block/qcow2.h"
> @@ -43,6 +44,10 @@
>  #define BME_MIN_GRANULARITY_BITS 9
>  #define BME_MAX_NAME_SIZE 1023
>  
> +#if BME_MAX_TABLE_SIZE * 8ULL > INT_MAX
> +#error In the code bitmap table physical size assumed to fit into int
> +#endif
> +
>  /* Bitmap directory entry flags */
>  #define BME_RESERVED_FLAGS 0xfffcU
>  #define BME_FLAG_IN_USE 1
> @@ -74,6 +79,8 @@ typedef struct Qcow2Bitmap {
>  uint8_t granularity_bits;
>  char *name;
>  
> +BdrvDirtyBitmap *dirty_bitmap;

(I'm not quite happy with the asymmetry of this field (it isn't set by
load_bitmap(), but it is required by store_bitmap()), but making it
symmetric either by making load_bitmap() set it or by store_bitmap() not
reading it (but getting the value through an explicit parameter) makes
the code needlessly more complicated, so I guess I'll have to stay
not-quite-happy.)

> +
>  QSIMPLEQ_ENTRY(Qcow2Bitmap) entry;
>  } Qcow2Bitmap;
>  typedef QSIMPLEQ_HEAD(Qcow2BitmapList, Qcow2Bitmap) Qcow2BitmapList;
> @@ -87,6 +94,27 @@ static inline bool can_write(BlockDriverState *bs)
>  return !bdrv_is_read_only(bs) && !(bdrv_get_flags(bs) & BDRV_O_INACTIVE);
>  }
>  
> +static int update_header_sync(BlockDriverState *bs)
> +{
> +int ret;
> +
> +ret = qcow2_update_header(bs);
> +if (ret < 0) {
> +return ret;
> +}
> +
> +/* We doesn't return  bdrv_flush error code. Even if it fails, write was

s/doesn't/don't/

(Also, there's a double space after return.)

> + * successful and it is more logical to consider that header is in the 
> new
> + * state than in the old.
> + */
> +ret = bdrv_flush(bs);
> +if (ret < 0) {
> +fprintf(stderr, "Failed to flush qcow2 header");
> +}
> +
> +return 0;
> +}
> +
>  static inline void bitmap_table_to_cpu(uint64_t *bitmap_table, size_t size)
>  {
>  size_t i;
> @@ -96,6 +124,15 @@ static inline void bitmap_table_to_cpu(uint64_t 
> *bitmap_table, size_t size)
>  }
>  }
>  
> +static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size)
> +{
> +size_t i;
> +
> +for (i = 0; i < size; ++i) {
> +cpu_to_be64s(_table[i]);
> +}
> +}
> +
>  /* Check table entry specification constraints. If cluster_size is 0, offset
>   * alignment is not checked. */
>  static int check_table_entry(uint64_t entry, int cluster_size)
> @@ -121,6 +158,51 @@ static int check_table_entry(uint64_t entry, int 
> cluster_size)
>  return 0;
>  }
>  
> +static int check_constraints_on_bitmap(BlockDriverState *bs,
> +   const char *name,
> +   uint32_t granularity)
> +{
> +BDRVQcow2State *s = bs->opaque;
> +int granularity_bits = ctz32(granularity);
> +
> +int64_t nb_sectors = bdrv_nb_sectors(bs);
> +
> +if (nb_sectors < 0) {
> +return nb_sectors;
> +}
> +
> +uint64_t phys_bitmap_bytes = (nb_sectors << BDRV_SECTOR_BITS) >>

Using bdrv_getlength() would be simpler.

> + granularity_bits;
> +uint64_t bitmap_table_size = phys_bitmap_bytes / s->cluster_size;

Should be a DIV_ROUND_UP().

> +size_t name_size = strlen(name);
> +
> +int fail =

I'd personally like a bool more.

> +(bitmap_table_size > BME_MAX_TABLE_SIZE) ||
> +(phys_bitmap_bytes > BME_MAX_PHYS_SIZE) ||
> +(granularity_bits > BME_MAX_GRANULARITY_BITS) ||
> +(granularity_bits < BME_MIN_GRANULARITY_BITS) ||
> +(name_size > BME_MAX_NAME_SIZE);
> +
> +return fail ? -EINVAL : 0;
> +}
> +
> +static void clear_bitmap_table(BlockDriverState *bs, uint64_t *bitmap_table,
> +   uint32_t bitmap_table_size)
> +{
> +BDRVQcow2State *s = bs->opaque;
> +int i;
> +
> +for (i = 0; i < bitmap_table_size; ++i) {
> +uint64_t addr = bitmap_table[i] & BME_TABLE_ENTRY_OFFSET_MASK;
> +if (!addr) {
> +continue;
> +}
> +
> +qcow2_free_clusters(bs, addr, s->cluster_size, QCOW2_DISCARD_OTHER);
> +bitmap_table[i] = 0;
> +}
> +}
> +
>  static int bitmap_table_load(BlockDriverState *bs, Qcow2Bitmap *bm,
>   uint64_t **bitmap_table)
>  {
> @@ 

Re: [Qemu-devel] [PATCH 01/19] linux-user: fix settime old value location

2016-12-09 Thread Alex Bennée

Pranith Kumar  writes:

> From: Marc-André Lureau 
>
> old_value is the 4th argument of timer_settime(), not the 2nd.
>
> Signed-off-by: Marc-André Lureau 
> Signed-off-by: Pranith Kumar 

Reviewed-by: Alex Bennée 

but this should really be sent in another series.

> ---
>  linux-user/syscall.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 7b77503..5bd477a 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -12027,7 +12027,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long 
> arg1,
>  target_to_host_itimerspec(_new, arg3);
>  ret = get_errno(
>timer_settime(htimer, arg2, _new, 
> _old));
> -host_to_target_itimerspec(arg2, _old);
> +host_to_target_itimerspec(arg4, _old);
>  }
>  break;
>  }


--
Alex Bennée



Re: [Qemu-devel] [PATCH 01/20] Makefile: Allow CPU targets to reside in target/ folder, too

2016-12-09 Thread Thomas Huth
On 09.12.2016 13:24, Laurent Vivier wrote:
> Le 09/12/2016 à 13:17, Thomas Huth a écrit :
>> To be able to compile the CPU targets from within a subfolder
>> of the target/ folder, we've got to adapt the Makefile.target
>> a little bit first. After this change, target CPUs can either
>> reside in a target/xxx folder or continue to use the target-xxx
>> scheme. The latter will be disabled once all targets have been
>> moved.
>>
>> Signed-off-by: Thomas Huth 
>> ---
>>  Makefile.target | 10 --
>>  1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/Makefile.target b/Makefile.target
>> index 7a5080e..90b25ae 100644
>> --- a/Makefile.target
>> +++ b/Makefile.target
>> @@ -7,11 +7,17 @@ include config-target.mak
>>  include config-devices.mak
>>  include $(SRC_PATH)/rules.mak
>>  
>> +ifneq ($(wildcard $(SRC_PATH)/target/$(TARGET_BASE_ARCH)),)
>> +TARGET_FOLDER=target/$(TARGET_BASE_ARCH)
>> +else
>> +TARGET_FOLDER=target-$(TARGET_BASE_ARCH)
>> +endif
> 
> Perhaps you should consider to use ':=' instead of '='.

Most of the other variables in that file seem to be set with '=' instead
of ':=', so using '=' sounds more consistent to me ... is there a real
benefit of using ':=' here?

 Thomas




Re: [Qemu-devel] [PATCH v4 62/64] tcg: Use ctpop to generate ctz if needed

2016-12-09 Thread Richard Henderson
On 12/09/2016 08:07 AM, Alex Bennée wrote:
> 
> Richard Henderson  writes:
> 
>> Particularly when andc is also available, this is two insns
>> shorter than using clz to compute ctz.
>>
>> Signed-off-by: Richard Henderson 
>> ---
>>  tcg/tcg-op.c | 107 
>> ---
>>  1 file changed, 65 insertions(+), 42 deletions(-)
>>
>> diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
>> index 6f4b1b6..d1debde 100644
>> --- a/tcg/tcg-op.c
>> +++ b/tcg/tcg-op.c
>> @@ -497,43 +497,46 @@ void tcg_gen_ctz_i32(TCGv_i32 ret, TCGv_i32 arg1, 
>> TCGv_i32 arg2)
> 
>>  } else {
>> -gen_helper_ctz_i32(ret, arg1, arg2);
>> +TCGv_i32 z, t;
>> +if (TCG_TARGET_HAS_ctpop_i32 && TCG_TARGET_HAS_andc_i32) {
>> +t = tcg_temp_new_i32();
>> +tcg_gen_subi_i32(t, arg1, 1);
>> +tcg_gen_andc_i32(t, t, arg1);
>> +tcg_gen_ctpop_i32(t, t);
>> +do_movc:
> 
> Hmmm and...
> 
> 
>>  void tcg_gen_clrsb_i32(TCGv_i32 ret, TCGv_i32 arg)
>> @@ -1842,18 +1845,29 @@ void tcg_gen_ctz_i64(TCGv_i64 ret, TCGv_i64 arg1, 
>> TCGv_i64 arg2)
>>  {
>>  if (TCG_TARGET_HAS_ctz_i64) {
>>  tcg_gen_op3_i64(INDEX_op_ctz_i64, ret, arg1, arg2);
> 
>>  } else {
>> -gen_helper_ctz_i64(ret, arg1, arg2);
>> +TCGv_i64 z, t;
>> +if (TCG_TARGET_HAS_ctpop_i64 && TCG_TARGET_HAS_andc_i64) {
>> +t = tcg_temp_new_i64();
>> +tcg_gen_subi_i64(t, arg1, 1);
>> +tcg_gen_andc_i64(t, t, arg1);
>> +tcg_gen_ctpop_i64(t, t);
>> +do_movc:
> 
> Hmmm.
> 
> So I'm not a goto hater as it makes sense for a bunch of things. But
> this seems just a little too liberal usage to my eyes. What's wrong with
> a little extra nesting (seeing the compiler sorts it all out in the
> end):
> 
> if ((TCG_TARGET_HAS_ctpop_i32 && TCG_TARGET_HAS_andc_i32)
> || TCG_TARGET_HAS_clz_i32 || TCG_TARGET_HAS_clz_i64) {
> 
> TCGv_i32 z, t;
> 
> if (TCG_TARGET_HAS_ctpop_i32 && TCG_TARGET_HAS_andc_i32) {
> t = tcg_temp_new_i32();
> tcg_gen_subi_i32(t, arg1, 1);
> tcg_gen_andc_i32(t, t, arg1);
> tcg_gen_ctpop_i32(t, t);
> } else if (TCG_TARGET_HAS_clz_i32 || TCG_TARGET_HAS_clz_i64) {
> /* Since all non-x86 hosts have clz(0) == 32, don't fight it. 
>  */
> t = tcg_temp_new_i32();
> tcg_gen_neg_i32(t, arg1);
> tcg_gen_and_i32(t, t, arg1);
> tcg_gen_clzi_i32(t, t, 32);
> tcg_gen_xori_i32(t, t, 31);
> }
> /* final movc */
> z = tcg_const_i32(0);
> tcg_gen_movcond_i32(TCG_COND_EQ, ret, arg1, z, arg2, t);
> tcg_temp_free_i32(t);
> tcg_temp_free_i32(z);
> } else {
> gen_helper_ctz_i32(ret, arg1, arg2);
> }

That does look better.  Thanks,


r~




Re: [Qemu-devel] dpdk/vpp and cross-version migration for vhost

2016-12-09 Thread Daniel P. Berrange
On Fri, Dec 09, 2016 at 05:45:13PM +0100, Maxime Coquelin wrote:
> 
> 
> On 12/09/2016 03:42 PM, Daniel P. Berrange wrote:
> > On Fri, Dec 09, 2016 at 02:35:58PM +0100, Maxime Coquelin wrote:
> > > ++Daniel for libvirt
> > > 
> > > On 11/24/2016 07:31 AM, Yuanhan Liu wrote:
> > > > > > > > > > > As version here is an opaque string for libvirt and qemu,
> > > > > > > > > > > > > > > > > > anything can be used - but I suggest either 
> > > > > > > > > > > > > > > > > > a list
> > > > > > > > > > > > > > > > > > of values defining the interface, e.g.
> > > > > > > > > > > > > > > > > > any_layout=on,max_ring=256
> > > > > > > > > > > > > > > > > > or a version including the name and vendor 
> > > > > > > > > > > > > > > > > > of the backend,
> > > > > > > > > > > > > > > > > > e.g. "org.dpdk.v4.5.6".
> > > > > > > > 
> > > > > > > > The version scheme may not be ideal here. Assume a QEMU is 
> > > > > > > > supposed
> > > > > > > > to work with a specific DPDK version, however, user may disable 
> > > > > > > > some
> > > > > > > > newer features through qemu command line, that it also could 
> > > > > > > > work with
> > > > > > > > an elder DPDK version. Using the version scheme will not allow 
> > > > > > > > us doing
> > > > > > > > such migration to an elder DPDK version. The MTU is a lively 
> > > > > > > > example
> > > > > > > > here? (when MTU feature is provided by QEMU but is actually 
> > > > > > > > disabled
> > > > > > > > by user, that it could also work with an elder DPDK without MTU 
> > > > > > > > support).
> > > > > > > > 
> > > > > > > > --yliu
> > > > > > 
> > > > > > OK, so does a list of values look better to you then?
> > > > Yes, if there are no better way.
> > > > 
> > > > And I think it may be better to not list all those features, literally.
> > > > But instead, using the number should be better, say, 
> > > > features=0xdeadbeef.
> > > > 
> > > > Listing the feature names means we have to come to an agreement in all
> > > > components involved here (QEMU, libvirt, DPDK, VPP, and maybe more
> > > > backends), that we have to use the exact same feature names. Though it
> > > > may not be a big deal, it lacks some flexibility.
> > > > 
> > > > A feature bits will not have this issue.
> > > 
> > > I initially thought having key/value pairs would be more flexible, and
> > > could allow migrating to another application if compatible (i.e. from
> > > OVS to VPP, and vice versa...) without needing synchronization between
> > > the applications.
> > > 
> > > But Daniel pointed me out that it would add a lot of complexity on
> > > management tool side, as it would need to know how to interpret these
> > > key/value pairs. I think his argument is very valid.
> > > 
> > > So maybe the best way would be the version string, letting the
> > > application (OVS-DPDK/VPP/...) specify which version it is
> > > compatible with.
> > > For the downsides, as soon as a new feature is supported in vhost-user
> > > application, the new version will not be advertised as compatible with
> > > the previous one, even if the user disables the feature in Qemu (as
> > > pointed out by Yuanhan).
> > 
> > We need two distinct capabilities in order to make this work properly.
> > 
> > First, libvirt needs to be able to query the list of (one or more)
> > supported versions strings for a given host.
> 
> Shouldn't be the role of OpenStack/Neutron? IIUC, libvirt knows nothing
> about OVS.

If libvirt doesn't know about it, then libvirt can't do any migration
checks upfront. Nova will have todo a check against supported version
strings before triggering migrate in libvirt.  That's probably fine
from libvirt POV.


Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://entangle-photo.org   -o-http://search.cpan.org/~danberr/ :|



Re: [Qemu-devel] [PATCH 04/20] alpha: Move CPU files to target/ folder

2016-12-09 Thread Richard Henderson
On 12/09/2016 04:17 AM, Thomas Huth wrote:
> Signed-off-by: Thomas Huth 
> ---
>  MAINTAINERS  | 2 +-
>  hw/alpha/alpha_sys.h | 2 +-
>  {target-alpha => target/alpha}/Makefile.objs | 0
>  {target-alpha => target/alpha}/STATUS| 0
>  {target-alpha => target/alpha}/cpu-qom.h | 0
>  {target-alpha => target/alpha}/cpu.c | 0
>  {target-alpha => target/alpha}/cpu.h | 0
>  {target-alpha => target/alpha}/fpu_helper.c  | 0
>  {target-alpha => target/alpha}/gdbstub.c | 0
>  {target-alpha => target/alpha}/helper.c  | 0
>  {target-alpha => target/alpha}/helper.h  | 0
>  {target-alpha => target/alpha}/int_helper.c  | 0
>  {target-alpha => target/alpha}/machine.c | 0
>  {target-alpha => target/alpha}/mem_helper.c  | 0
>  {target-alpha => target/alpha}/sys_helper.c  | 0
>  {target-alpha => target/alpha}/translate.c   | 0
>  {target-alpha => target/alpha}/vax_helper.c  | 0
>  17 files changed, 2 insertions(+), 2 deletions(-)
>  rename {target-alpha => target/alpha}/Makefile.objs (100%)
>  rename {target-alpha => target/alpha}/STATUS (100%)
>  rename {target-alpha => target/alpha}/cpu-qom.h (100%)
>  rename {target-alpha => target/alpha}/cpu.c (100%)
>  rename {target-alpha => target/alpha}/cpu.h (100%)
>  rename {target-alpha => target/alpha}/fpu_helper.c (100%)
>  rename {target-alpha => target/alpha}/gdbstub.c (100%)
>  rename {target-alpha => target/alpha}/helper.c (100%)
>  rename {target-alpha => target/alpha}/helper.h (100%)
>  rename {target-alpha => target/alpha}/int_helper.c (100%)
>  rename {target-alpha => target/alpha}/machine.c (100%)
>  rename {target-alpha => target/alpha}/mem_helper.c (100%)
>  rename {target-alpha => target/alpha}/sys_helper.c (100%)
>  rename {target-alpha => target/alpha}/translate.c (100%)
>  rename {target-alpha => target/alpha}/vax_helper.c (100%)

Acked-by: Richard Henderson 


r~



Re: [Qemu-devel] dpdk/vpp and cross-version migration for vhost

2016-12-09 Thread Maxime Coquelin



On 12/09/2016 03:42 PM, Daniel P. Berrange wrote:

On Fri, Dec 09, 2016 at 02:35:58PM +0100, Maxime Coquelin wrote:

++Daniel for libvirt

On 11/24/2016 07:31 AM, Yuanhan Liu wrote:

As version here is an opaque string for libvirt and qemu,

anything can be used - but I suggest either a list
of values defining the interface, e.g.
any_layout=on,max_ring=256
or a version including the name and vendor of the backend,
e.g. "org.dpdk.v4.5.6".


The version scheme may not be ideal here. Assume a QEMU is supposed
to work with a specific DPDK version, however, user may disable some
newer features through qemu command line, that it also could work with
an elder DPDK version. Using the version scheme will not allow us doing
such migration to an elder DPDK version. The MTU is a lively example
here? (when MTU feature is provided by QEMU but is actually disabled
by user, that it could also work with an elder DPDK without MTU support).

--yliu


OK, so does a list of values look better to you then?

Yes, if there are no better way.

And I think it may be better to not list all those features, literally.
But instead, using the number should be better, say, features=0xdeadbeef.

Listing the feature names means we have to come to an agreement in all
components involved here (QEMU, libvirt, DPDK, VPP, and maybe more
backends), that we have to use the exact same feature names. Though it
may not be a big deal, it lacks some flexibility.

A feature bits will not have this issue.


I initially thought having key/value pairs would be more flexible, and
could allow migrating to another application if compatible (i.e. from
OVS to VPP, and vice versa...) without needing synchronization between
the applications.

But Daniel pointed me out that it would add a lot of complexity on
management tool side, as it would need to know how to interpret these
key/value pairs. I think his argument is very valid.

So maybe the best way would be the version string, letting the
application (OVS-DPDK/VPP/...) specify which version it is
compatible with.
For the downsides, as soon as a new feature is supported in vhost-user
application, the new version will not be advertised as compatible with
the previous one, even if the user disables the feature in Qemu (as
pointed out by Yuanhan).


We need two distinct capabilities in order to make this work properly.

First, libvirt needs to be able to query the list of (one or more)
supported versions strings for a given host.


Shouldn't be the role of OpenStack/Neutron? IIUC, libvirt knows nothing
about OVS.


Second, when launching QEMU we need to be able to specify the desired
version against the NIC backend.

So, consider host A, initially supporting "ovsdpdk-v1". When libvirt
launches the VM it will specify 'ovsdpgk-v1' as the desired version
string to use.

Now some time later you add features X, Y & Z to a new release of
DPDK and install this on host B.  Host B is able to support two
versions 'ovsdppk-v1' and 'ovsdpdk-v2'.  When libvirt launches
a VM on host B, it'll pick 'ovsdpgk-v2' by default, since that's
the newest.   When libvirt migrates a VM from host A, however,
it will request the old version 'ovsdpdk-v1' in order to ensure
compatibility.  Similarly when launching a new VM on host B,
libvirt could choose to use 'ovsdpdk-v1' as the version, in
order to enable migration to the olver host A, if desired.

This is exactly the way QEMU machine types work, hiding the
existance of 100's low level settings / default values, that
a mgmt app would otherwise have to worry about.


I agree on the principle. I need to check what is missing for OVS to
support different versions on different vhost-user ports.

Thanks,
Maxime


Regards,
Daniel





Re: [Qemu-devel] [PATCH kernel v5 0/5] Extend virtio-balloon for fast (de)inflating & fast live migration

2016-12-09 Thread Andrea Arcangeli
Hello,

On Fri, Dec 09, 2016 at 05:35:45AM +, Li, Liang Z wrote:
> > On 12/08/2016 08:45 PM, Li, Liang Z wrote:
> > > What's the conclusion of your discussion? It seems you want some
> > > statistic before deciding whether to  ripping the bitmap from the ABI,
> > > am I right?
> > 
> > I think Andrea and David feel pretty strongly that we should remove the
> > bitmap, unless we have some data to support keeping it.  I don't feel as
> > strongly about it, but I think their critique of it is pretty valid.  I 
> > think the
> > consensus is that the bitmap needs to go.
> > 
> 
> Thanks for you clarification.
> 
> > The only real question IMNHO is whether we should do a power-of-2 or a
> > length.  But, if we have 12 bits, then the argument for doing length is 
> > pretty
> > strong.  We don't need anywhere near 12 bits if doing power-of-2.
> > 
> So each item can max represent 16MB Bytes, seems not big enough,
> but enough for most case.
> Things became much more simple without the bitmap, and I like simple solution 
> too. :)
> 
> I will prepare the v6 and remove all the bitmap related stuffs. Thank you all!

Sounds great!

I suggested to check the statistics, because collecting those stats
looked simpler and quicker than removing all bitmap related stuff from
the patchset. However if you prefer to prepare a v6 without the bitmap
another perhaps more interesting way to evaluate the usefulness of the
bitmap is to just run the same benchmark and verify that there is no
regression compared to the bitmap enabled code.

The other issue with the bitmap is, the best case for the bitmap is
ever less likely to materialize the more RAM is added to the guest. It
won't regress linearly because after all there can be some locality
bias in the buddy splits, but if sync compaction is used in the large
order allocations tried before reaching order 0, the bitmap payoff
will regress close to linearly with the increase of RAM.

So it'd be good to check the stats or the benchmark on large guests,
at least one hundred gigabytes or so.

Changing topic but still about the ABI features needed, so it may be
relevant for this discussion:

1) vNUMA locality: i.e. allowing host to specify which vNODEs to take
   memory from, using alloc_pages_node in guest. So you can ask to
   take X pages from vnode A, Y pages from vnode B, in one vmenter.

2) allowing qemu to tell the guest to stop inflating the balloon and
   report a fragmentation limit being hit, when sync compaction
   powered allocations fails at certain power-of-two order granularity
   passed by qemu to the guest. This order constraint will be passed
   by default for hugetlbfs guests with 2MB hpage size, while it can
   be used optionally on THP backed guests. This option with THP
   guests would allow a highlevel management software to provide a
   "don't reduce guest performance" while shrinking the memory size of
   the guest from the GUI. If you deselect the option, you can shrink
   down to the last freeable 4k guest page, but doing so may have to
   split THP in the host (you don't know for sure if they were really
   THP but they could have been), and it may regress
   performance. Inflating the balloon while passing a minimum
   granularity "order" of the pages being zapped, will guarantee
   inflating the balloon cannot decrease guest performance
   instead. Plus it's needed for hugetlbfs anyway as far as I can
   tell. hugetlbfs would not be host enforceable even if the idea is
   not to free memory but only reduce the available memory of the
   guest (not without major changes that maps a hugetlb page with 4k
   ptes at least). While for a more cooperative usage of hugetlbfs
   guests, it's simply not useful to inflate the balloon at anything
   less than the "HPAGE_SIZE" hugetlbfs granularity.

We also plan to use userfaultfd to make the balloon driver host
enforced (will work fine on hugetlbfs 2M and tmpfs too) but that's
going to be invisible to the ABI so it's not strictly relevant for
this discussion.

On a side note, registering userfaultfd on the ballooned range, will
keep khugepaged at bay so it won't risk to re-inflating the
MADV_DONTNEED zapped sub-THP fragments no matter the sysfs tunings.

Thanks!
Andrea



[Qemu-devel] [PATCH 2/4] hw/arm/virt: Merge VirtBoardInfo and VirtMachineState

2016-12-09 Thread Peter Maydell
One of the purposes of VirtBoardInfo was to hold various
bits of state about the board. Now we have MachineState
and the subclass VirtMachineState to do this. Fold the
VirtBoardInfo into VirtMachineState rather than having
some flags in one struct and some in another with no
useful way to get between them.

In the process we drop the code for looking up the
memory map and irq map from the CPU model, because
in practice we always use the same maps in all cases.

For easier code review, this change removes the
VirtBoardInfo type but leaves all the variables which
used to be VirtBoardInfo* and are now VirtMachineState*
with their now-confusing 'vbi' names.

Signed-off-by: Peter Maydell 
---
 hw/arm/virt.c | 118 +-
 1 file changed, 51 insertions(+), 67 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 11c53a5..fd4eed9 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -66,23 +66,8 @@
 
 static ARMPlatformBusSystemParams platform_bus_params;
 
-typedef struct VirtBoardInfo {
-struct arm_boot_info bootinfo;
-const char *cpu_model;
-const MemMapEntry *memmap;
-const int *irqmap;
-int smp_cpus;
-void *fdt;
-int fdt_size;
-uint32_t clock_phandle;
-uint32_t gic_phandle;
-uint32_t msi_phandle;
-bool using_psci;
-} VirtBoardInfo;
-
 typedef struct {
 MachineClass parent;
-VirtBoardInfo *daughterboard;
 bool disallow_affinity_adjustment;
 bool no_its;
 bool no_pmu;
@@ -93,6 +78,16 @@ typedef struct {
 bool secure;
 bool highmem;
 int32_t gic_version;
+struct arm_boot_info bootinfo;
+const MemMapEntry *memmap;
+const int *irqmap;
+int smp_cpus;
+void *fdt;
+int fdt_size;
+uint32_t clock_phandle;
+uint32_t gic_phandle;
+uint32_t msi_phandle;
+bool using_psci;
 } VirtMachineState;
 
 #define TYPE_VIRT_MACHINE   MACHINE_TYPE_NAME("virt")
@@ -202,42 +197,27 @@ static const int a15irqmap[] = {
 [VIRT_PLATFORM_BUS] = 112, /* ...to 112 + PLATFORM_BUS_NUM_IRQS -1 */
 };
 
-static VirtBoardInfo machines[] = {
-{
-.cpu_model = "cortex-a15",
-.memmap = a15memmap,
-.irqmap = a15irqmap,
-},
-{
-.cpu_model = "cortex-a53",
-.memmap = a15memmap,
-.irqmap = a15irqmap,
-},
-{
-.cpu_model = "cortex-a57",
-.memmap = a15memmap,
-.irqmap = a15irqmap,
-},
-{
-.cpu_model = "host",
-.memmap = a15memmap,
-.irqmap = a15irqmap,
-},
+static const char *valid_cpus[] = {
+"cortex-a15",
+"cortex-a53",
+"cortex-a57",
+"host",
+NULL
 };
 
-static VirtBoardInfo *find_machine_info(const char *cpu)
+static bool cpuname_valid(const char *cpu)
 {
 int i;
 
-for (i = 0; i < ARRAY_SIZE(machines); i++) {
-if (strcmp(cpu, machines[i].cpu_model) == 0) {
-return [i];
+for (i = 0; i < ARRAY_SIZE(valid_cpus); i++) {
+if (strcmp(cpu, valid_cpus[i]) == 0) {
+return true;
 }
 }
-return NULL;
+return false;
 }
 
-static void create_fdt(VirtBoardInfo *vbi)
+static void create_fdt(VirtMachineState *vbi)
 {
 void *fdt = create_device_tree(>fdt_size);
 
@@ -277,7 +257,7 @@ static void create_fdt(VirtBoardInfo *vbi)
 
 }
 
-static void fdt_add_psci_node(const VirtBoardInfo *vbi)
+static void fdt_add_psci_node(const VirtMachineState *vbi)
 {
 uint32_t cpu_suspend_fn;
 uint32_t cpu_off_fn;
@@ -327,7 +307,7 @@ static void fdt_add_psci_node(const VirtBoardInfo *vbi)
 qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn);
 }
 
-static void fdt_add_timer_nodes(const VirtBoardInfo *vbi, int gictype)
+static void fdt_add_timer_nodes(const VirtMachineState *vbi, int gictype)
 {
 /* Note that on A15 h/w these interrupts are level-triggered,
  * but for the GIC implementation provided by both QEMU and KVM
@@ -361,7 +341,7 @@ static void fdt_add_timer_nodes(const VirtBoardInfo *vbi, 
int gictype)
GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL2_IRQ, irqflags);
 }
 
-static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi)
+static void fdt_add_cpu_nodes(const VirtMachineState *vbi)
 {
 int cpu;
 int addr_cells = 1;
@@ -424,7 +404,7 @@ static void fdt_add_cpu_nodes(const VirtBoardInfo *vbi)
 }
 }
 
-static void fdt_add_its_gic_node(VirtBoardInfo *vbi)
+static void fdt_add_its_gic_node(VirtMachineState *vbi)
 {
 vbi->msi_phandle = qemu_fdt_alloc_phandle(vbi->fdt);
 qemu_fdt_add_subnode(vbi->fdt, "/intc/its");
@@ -437,7 +417,7 @@ static void fdt_add_its_gic_node(VirtBoardInfo *vbi)
 qemu_fdt_setprop_cell(vbi->fdt, "/intc/its", "phandle", vbi->msi_phandle);
 }
 
-static void fdt_add_v2m_gic_node(VirtBoardInfo *vbi)
+static void fdt_add_v2m_gic_node(VirtMachineState *vbi)
 {
 vbi->msi_phandle = qemu_fdt_alloc_phandle(vbi->fdt);
 qemu_fdt_add_subnode(vbi->fdt, "/intc/v2m");
@@ -450,7 +430,7 @@ 

[Qemu-devel] [PATCH 4/4] hw/arm/virt: Don't incorrectly claim architectural timer to be edge-triggered

2016-12-09 Thread Peter Maydell
The architectural timers in ARM CPUs all have level triggered interrupts
(unless you're using KVM on a host kernel before 4.4, which misimplemented
them as edge-triggered).

We were incorrectly describing them in the device tree as edge triggered.
This can cause problems for guest kernels in 4.8 before rc6:
 * pre-4.8 kernels ignore the values in the DT
 * 4.8 before rc6 write the DT values to the GIC config registers
 * newer than rc6 ignore the DT and insist that the timer interrupts
   are level triggered regardless

Fix the DT so we're describing reality. For backwards-compatibility
purposes, only do this for the virt-2.9 machine onward.

Signed-off-by: Peter Maydell 
---
 hw/arm/virt.c | 34 ++
 1 file changed, 30 insertions(+), 4 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 54498ea..2ca9527 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -71,6 +71,7 @@ typedef struct {
 bool disallow_affinity_adjustment;
 bool no_its;
 bool no_pmu;
+bool claim_edge_triggered_timers;
 } VirtMachineClass;
 
 typedef struct {
@@ -309,12 +310,31 @@ static void fdt_add_psci_node(const VirtMachineState *vms)
 
 static void fdt_add_timer_nodes(const VirtMachineState *vms, int gictype)
 {
-/* Note that on A15 h/w these interrupts are level-triggered,
- * but for the GIC implementation provided by both QEMU and KVM
- * they are edge-triggered.
+/* On real hardware these interrupts are level-triggered.
+ * On KVM they were edge-triggered before host kernel version 4.4,
+ * and level-triggered afterwards.
+ * On emulated QEMU they are level-triggered.
+ *
+ * Getting the DTB info about them wrong is awkward for some
+ * guest kernels:
+ *  pre-4.8 ignore the DT and leave the interrupt configured
+ *   with whatever the GIC reset value (or the bootloader) left it at
+ *  4.8 before rc6 honour the incorrect data by programming it back
+ *   into the GIC, causing problems
+ *  4.8rc6 and later ignore the DT and always write "level triggered"
+ *   into the GIC
+ *
+ * For backwards-compatibility, virt-2.8 and earlier will continue
+ * to say these are edge-triggered, but later machines will report
+ * the correct information.
  */
 ARMCPU *armcpu;
-uint32_t irqflags = GIC_FDT_IRQ_FLAGS_EDGE_LO_HI;
+VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
+uint32_t irqflags = GIC_FDT_IRQ_FLAGS_LEVEL_HI;
+
+if (vmc->claim_edge_triggered_timers) {
+irqflags = GIC_FDT_IRQ_FLAGS_EDGE_LO_HI;
+}
 
 if (gictype == 2) {
 irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
@@ -1556,8 +1576,14 @@ static void virt_2_8_instance_init(Object *obj)
 
 static void virt_machine_2_8_options(MachineClass *mc)
 {
+VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
 virt_machine_2_9_options(mc);
 SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_8);
+/* For 2.8 and earlier we falsely claimed in the DT that
+ * our timers were edge-triggered, not level-triggered.
+ */
+vmc->claim_edge_triggered_timers = true;
 }
 DEFINE_VIRT_MACHINE(2, 8)
 
-- 
2.7.4




[Qemu-devel] [PATCH 3/4] hw/arm/virt: Rename 'vbi' variables to 'vms'

2016-12-09 Thread Peter Maydell
Rename all the variables which used to be VirtBoardInfo*
and are now VirtMachineState* so their names are in line
with the type being used.

Apart from the removal of the line 'VirtMachineState *vbi = vms;'
this commit is purely a search-and-replace of 'vbi' with 'vms'.

Signed-off-by: Peter Maydell 
---
 hw/arm/virt.c | 489 +-
 1 file changed, 244 insertions(+), 245 deletions(-)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index fd4eed9..54498ea 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -217,16 +217,16 @@ static bool cpuname_valid(const char *cpu)
 return false;
 }
 
-static void create_fdt(VirtMachineState *vbi)
+static void create_fdt(VirtMachineState *vms)
 {
-void *fdt = create_device_tree(>fdt_size);
+void *fdt = create_device_tree(>fdt_size);
 
 if (!fdt) {
 error_report("create_device_tree() failed");
 exit(1);
 }
 
-vbi->fdt = fdt;
+vms->fdt = fdt;
 
 /* Header */
 qemu_fdt_setprop_string(fdt, "/", "compatible", "linux,dummy-virt");
@@ -246,27 +246,27 @@ static void create_fdt(VirtMachineState *vbi)
  * optional but in practice if you omit them the kernel refuses to
  * probe for the device.
  */
-vbi->clock_phandle = qemu_fdt_alloc_phandle(fdt);
+vms->clock_phandle = qemu_fdt_alloc_phandle(fdt);
 qemu_fdt_add_subnode(fdt, "/apb-pclk");
 qemu_fdt_setprop_string(fdt, "/apb-pclk", "compatible", "fixed-clock");
 qemu_fdt_setprop_cell(fdt, "/apb-pclk", "#clock-cells", 0x0);
 qemu_fdt_setprop_cell(fdt, "/apb-pclk", "clock-frequency", 2400);
 qemu_fdt_setprop_string(fdt, "/apb-pclk", "clock-output-names",
 "clk24mhz");
-qemu_fdt_setprop_cell(fdt, "/apb-pclk", "phandle", vbi->clock_phandle);
+qemu_fdt_setprop_cell(fdt, "/apb-pclk", "phandle", vms->clock_phandle);
 
 }
 
-static void fdt_add_psci_node(const VirtMachineState *vbi)
+static void fdt_add_psci_node(const VirtMachineState *vms)
 {
 uint32_t cpu_suspend_fn;
 uint32_t cpu_off_fn;
 uint32_t cpu_on_fn;
 uint32_t migrate_fn;
-void *fdt = vbi->fdt;
+void *fdt = vms->fdt;
 ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(0));
 
-if (!vbi->using_psci) {
+if (!vms->using_psci) {
 return;
 }
 
@@ -307,7 +307,7 @@ static void fdt_add_psci_node(const VirtMachineState *vbi)
 qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn);
 }
 
-static void fdt_add_timer_nodes(const VirtMachineState *vbi, int gictype)
+static void fdt_add_timer_nodes(const VirtMachineState *vms, int gictype)
 {
 /* Note that on A15 h/w these interrupts are level-triggered,
  * but for the GIC implementation provided by both QEMU and KVM
@@ -319,29 +319,29 @@ static void fdt_add_timer_nodes(const VirtMachineState 
*vbi, int gictype)
 if (gictype == 2) {
 irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START,
  GIC_FDT_IRQ_PPI_CPU_WIDTH,
- (1 << vbi->smp_cpus) - 1);
+ (1 << vms->smp_cpus) - 1);
 }
 
-qemu_fdt_add_subnode(vbi->fdt, "/timer");
+qemu_fdt_add_subnode(vms->fdt, "/timer");
 
 armcpu = ARM_CPU(qemu_get_cpu(0));
 if (arm_feature(>env, ARM_FEATURE_V8)) {
 const char compat[] = "arm,armv8-timer\0arm,armv7-timer";
-qemu_fdt_setprop(vbi->fdt, "/timer", "compatible",
+qemu_fdt_setprop(vms->fdt, "/timer", "compatible",
  compat, sizeof(compat));
 } else {
-qemu_fdt_setprop_string(vbi->fdt, "/timer", "compatible",
+qemu_fdt_setprop_string(vms->fdt, "/timer", "compatible",
 "arm,armv7-timer");
 }
-qemu_fdt_setprop(vbi->fdt, "/timer", "always-on", NULL, 0);
-qemu_fdt_setprop_cells(vbi->fdt, "/timer", "interrupts",
+qemu_fdt_setprop(vms->fdt, "/timer", "always-on", NULL, 0);
+qemu_fdt_setprop_cells(vms->fdt, "/timer", "interrupts",
GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_S_EL1_IRQ, irqflags,
GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL1_IRQ, irqflags,
GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_VIRT_IRQ, irqflags,
GIC_FDT_IRQ_TYPE_PPI, ARCH_TIMER_NS_EL2_IRQ, irqflags);
 }
 
-static void fdt_add_cpu_nodes(const VirtMachineState *vbi)
+static void fdt_add_cpu_nodes(const VirtMachineState *vms)
 {
 int cpu;
 int addr_cells = 1;
@@ -360,7 +360,7 @@ static void fdt_add_cpu_nodes(const VirtMachineState *vbi)
  *  The simplest way to go is to examine affinity IDs of all our CPUs. If
  *  at least one of them has Aff3 populated, we set #address-cells to 2.
  */
-for (cpu = 0; cpu < vbi->smp_cpus; cpu++) {
+for (cpu = 0; cpu < vms->smp_cpus; cpu++) {
 ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu));
 
 if (armcpu->mp_affinity & ARM_AFF3_MASK) {
@@ -369,101 +369,101 @@ static 

[Qemu-devel] [PATCH 1/4] hw/arm/virt: add 2.9 machine type

2016-12-09 Thread Peter Maydell
Signed-off-by: Peter Maydell 
---
 include/hw/compat.h |  3 +++
 hw/arm/virt.c   | 19 +--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/include/hw/compat.h b/include/hw/compat.h
index 0f06e11..f8b8354 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -1,6 +1,9 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
+#define HW_COMPAT_2_8 \
+/* empty */
+
 #define HW_COMPAT_2_7 \
 {\
 .driver   = "virtio-pci",\
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index d04e4ac..11c53a5 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1525,7 +1525,7 @@ static void machvirt_machine_init(void)
 }
 type_init(machvirt_machine_init);
 
-static void virt_2_8_instance_init(Object *obj)
+static void virt_2_9_instance_init(Object *obj)
 {
 VirtMachineState *vms = VIRT_MACHINE(obj);
 
@@ -1558,10 +1558,25 @@ static void virt_2_8_instance_init(Object *obj)
 "Valid values are 2, 3 and host", NULL);
 }
 
+static void virt_machine_2_9_options(MachineClass *mc)
+{
+}
+DEFINE_VIRT_MACHINE_AS_LATEST(2, 9)
+
+#define VIRT_COMPAT_2_8 \
+HW_COMPAT_2_8
+
+static void virt_2_8_instance_init(Object *obj)
+{
+virt_2_9_instance_init(obj);
+}
+
 static void virt_machine_2_8_options(MachineClass *mc)
 {
+virt_machine_2_9_options(mc);
+SET_MACHINE_COMPAT(mc, VIRT_COMPAT_2_8);
 }
-DEFINE_VIRT_MACHINE_AS_LATEST(2, 8)
+DEFINE_VIRT_MACHINE(2, 8)
 
 #define VIRT_COMPAT_2_7 \
 HW_COMPAT_2_7
-- 
2.7.4




[Qemu-devel] [PATCH 0/4] hw/arm/virt: 2.9 machtype, fix timer dt info

2016-12-09 Thread Peter Maydell
This patchset fixes an error in how we were reporting the
architectural timers in the device tree for the virt board.
Old KVM host kernels (before 4.4) implemented these timers
as edge-triggered, which led us to decide to report them in
the DT as edge triggered. However in newer kernels this
was fixed and they're level triggered as they're architecturally
supposed to be.

Patch 4 fixes up the DT.
Patch 1 adds the 2.9 machine type so we can make the DT
 change only apply to new virt machine types
Patches 2 and 3 are a cleanup, so that we can have
 convenient access to the VirtMachineClass at the point
 in the code where we want to look at it. We collapse the
 VirtBoardInfo struct into the VirtMachineState, since
 the former mostly exists because at the time there was
 no VirtMachineState.

(Most of the diffstat is the result of s/vbi/vms/ on
the file to update variable names.)

Kernel behaviours as far as I know them:
 * host v4.3 and earlier: implemented timers as weird
   sort-of-edge-triggered semantics
 * host v4.4 and later: timers are level triggered
vs
 * guest pre-4.8: ignore the values in the DT, trust
   whatever the GIC's reset values are
 * guest 4.8 before rc6: write the DT values to the
   GIC config registers
 * guest newer than rc6 ignore the DT, and always write
   'level triggered' to the GIC

This combination means that (assuming that post 4.8
guest kernels work at all on pre 4.4 host kernels) I
don't expect this to break anything. Testing would probably
be a good idea, though: I plan to do some more combinations
but kernel builds on my aarch64 system are slow so I
thought I'd send out the patchset before I went home today...

Peter Maydell (4):
  hw/arm/virt: add 2.9 machine type
  hw/arm/virt: Merge VirtBoardInfo and VirtMachineState
  hw/arm/virt: Rename 'vbi' variables to 'vms'
  hw/arm/virt: Don't incorrectly claim architectural timer to be
edge-triggered

 include/hw/compat.h |   3 +
 hw/arm/virt.c   | 616 +++-
 2 files changed, 323 insertions(+), 296 deletions(-)

-- 
2.7.4




Re: [Qemu-devel] [PATCH for-2.8 2/2] tests: check-qom-proplist: add checks for cmdline-created objects

2016-12-09 Thread Michael Roth
Quoting Markus Armbruster (2016-12-07 05:10:47)
> "Daniel P. Berrange"  writes:
> 
> > On Tue, Dec 06, 2016 at 02:15:00PM -0600, Michael Roth wrote:
> >> check-qom-proplist originally added tests for verifying that
> >> object-creation helpers object_new_with_{props,propv} behaved in
> >> similar fashion to the "traditional" method involving setting each
> >> individual property separately after object creation rather than
> >> in via a single call.
> >> 
> >> Another similar "helper" for creating Objects exists in the form of
> >> objects specified via -object command-line parameters. By that
> >> rationale, we extend check-qom-proplist to include similar checks
> >> for command-line-created objects by employing the same
> >> qemu_opts_parse()-based parsing the vl.c employs.
> >> 
> >> This parser has a side-effect of parsing the object's options into
> >> a QemuOpt structure and registering this in the global QemuOptsList
> >> using the Object's ID. This can conflict with future Object instances
> >> that attempt to use the same ID if we don't ensure this is cleaned
> >> up as part of Object finalization, so we add specific checks for this
> >> scenario in addition to the normal sanity checks.
> >> 
> >> Suggested-by: Daniel Berrange 
> >> Cc: "Dr. David Alan Gilbert" 
> >> Cc: Markus Armbruster 
> >> Cc: Eric Blake 
> >> Cc: Daniel Berrange 
> >> Signed-off-by: Michael Roth 
> >> ---
> >>  tests/check-qom-proplist.c | 54 
> >> +-
> >>  1 file changed, 53 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
> >> index a16cefc..087ce21 100644
> >> --- a/tests/check-qom-proplist.c
> >> +++ b/tests/check-qom-proplist.c
> >> @@ -23,6 +23,9 @@
> >>  #include "qapi/error.h"
> >>  #include "qom/object.h"
> >>  #include "qemu/module.h"
> >> +#include "qemu/option.h"
> >> +#include "qemu/config-file.h"
> >> +#include "qom/object_interfaces.h"
> >>  
> >>  
> >>  #define TYPE_DUMMY "qemu-dummy"
> >> @@ -162,6 +165,10 @@ static const TypeInfo dummy_info = {
> >>  .instance_finalize = dummy_finalize,
> >>  .class_size = sizeof(DummyObjectClass),
> >>  .class_init = dummy_class_init,
> >> +.interfaces = (InterfaceInfo[]) {
> >> +{ TYPE_USER_CREATABLE },
> >> +{ }
> >> +}
> >>  };
> >>  
> >>  
> >> @@ -291,7 +298,6 @@ static void dummy_backend_init(Object *obj)
> >>  {
> >>  }
> >>  
> >> -
> >>  static const TypeInfo dummy_dev_info = {
> >>  .name  = TYPE_DUMMY_DEV,
> >>  .parent= TYPE_OBJECT,
> >> @@ -320,6 +326,14 @@ static const TypeInfo dummy_backend_info = {
> >>  .class_size = sizeof(DummyBackendClass),
> >>  };
> >>  
> >> +static QemuOptsList qemu_object_opts = {
> >> +.name = "object",
> >> +.implied_opt_name = "qom-type",
> >> +.head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head),
> >> +.desc = {
> >> +{ }
> >> +},
> >> +};
> >>  
> >>  
> >>  static void test_dummy_createv(void)
> >> @@ -388,6 +402,43 @@ static void test_dummy_createlist(void)
> >>  object_unparent(OBJECT(dobj));
> >>  }
> >>  
> >> +static void test_dummy_createcmdl(void)
> >> +{
> >> +QemuOpts *opts;
> >> +DummyObject *dobj;
> >> +Error *err = NULL;
> >> +const char *params = TYPE_DUMMY \
> >> + ",id=dev0," \
> >> + "bv=yes,sv=Hiss hiss hiss,av=platypus";
> >> +
> >> +qemu_add_opts(_object_opts);
> >> +opts = qemu_opts_parse(_object_opts, params, true, );
> >> +g_assert(err == NULL);
> >> +g_assert(opts);
> >> +
> >> +dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, ));
> >> +g_assert(err == NULL);
> >> +g_assert(dobj);
> >> +g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss");
> >> +g_assert(dobj->bv == true);
> >> +g_assert(dobj->av == DUMMY_PLATYPUS);
> >> +
> >> +user_creatable_del("dev0", );
> >> +g_assert(err == NULL);
> >> +error_free(err);
> >> +
> >> +/* cmdline-parsing via qemu_opts_parse() results in a QemuOpts entry
> >> + * corresponding to the Object's ID to be added to the QemuOptsList
> >> + * for objects. To avoid having this entry conflict with future
> >> + * Objects using the same ID (which can happen in cases where
> >> + * qemu_opts_parse() is used to parse the object params, such as
> >> + * with hmp_object_add() at the time of this comment), we check
> >> + * for this in user_creatable_del() and remove the QemuOpts if it
> >> + * is present. The below check ensures this works as expected.
> >> + */
> >> +g_assert(qemu_opts_find(_object_opts, "dev0") == NULL);
> >> +}
> >> +
> >>  static void test_dummy_badenum(void)
> >>  {
> >>  Error *err = NULL;
> >> @@ -525,6 +576,7 @@ int main(int argc, char **argv)
> >>  
> >>   

Re: [Qemu-devel] [PATCH for-2.8 1/2] monitor: fix object_del for command-line-created objects

2016-12-09 Thread Michael Roth
Quoting Markus Armbruster (2016-12-07 04:36:20)
> Michael Roth  writes:
> 
> > Currently objects specified on the command-line are only partially
> > cleaned up when 'object_del' is issued in either HMP or QMP: the
> > object itself is fully finalized, but the QemuOpts are not removed.
> > This results in the following behavior:
> >
> >   x86_64-softmmu/qemu-system-x86_64 -monitor stdio \
> > -object memory-backend-ram,id=ram1,size=256M
> >
> >   QEMU 2.7.91 monitor - type 'help' for more information
> >   (qemu) object_del ram1
> >   (qemu) object_del ram1
> >   object 'ram1' not found
> >   (qemu) object_add memory-backend-ram,id=ram1,size=256M
> >   Duplicate ID 'ram1' for object
> >   Try "help object_add" for more information
> >
> > which can be an issue for use-cases like memory hotplug.
> >
> > This happens on the HMP side because hmp_object_add() attempts to
> > create a temporary QemuOpts entry with ID 'ram1', which ends up
> > conflicting with the command-line-created entry, since it was never
> > cleaned up during the previous hmp_object_del() call.
> >
> > We address this by adding a check in user_creatable_del(), which
> > is called by both qmp_object_del() and hmp_object_del() to handle
> > the actual object cleanup, to determine whether an option group entry
> > matching the object's ID is present and removing it if it is.
> >
> > Note that qmp_object_add() never attempts to create a temporary
> > QemuOpts entry, so it does not encounter the duplicate ID error,
> > which is why this isn't generally visible in libvirt.
> >
> > Cc: "Dr. David Alan Gilbert" 
> > Cc: Markus Armbruster 
> > Cc: Eric Blake 
> > Cc: Daniel Berrange 
> > Cc: qemu-sta...@nongnu.org
> > Signed-off-by: Michael Roth 
> > ---
> >  qom/object_interfaces.c | 11 +++
> >  1 file changed, 11 insertions(+)
> >
> > diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> > index ded4d84..23849f9 100644
> > --- a/qom/object_interfaces.c
> > +++ b/qom/object_interfaces.c
> > @@ -5,6 +5,7 @@
> >  #include "qapi-visit.h"
> >  #include "qapi/qobject-output-visitor.h"
> >  #include "qapi/opts-visitor.h"
> > +#include "qemu/config-file.h"
> >  
> >  void user_creatable_complete(Object *obj, Error **errp)
> >  {
> > @@ -197,6 +198,7 @@ void user_creatable_del(const char *id, Error **errp)
> >  {
> >  Object *container;
> >  Object *obj;
> > +QemuOptsList *opt_group;
> >  
> >  container = object_get_objects_root();
> >  obj = object_resolve_path_component(container, id);
> > @@ -209,6 +211,15 @@ void user_creatable_del(const char *id, Error **errp)
> >  error_setg(errp, "object '%s' is in use, can not be deleted", id);
> >  return;
> >  }
> > +
> > +/* if object was defined on the command-line, remove its corresponding
> > + * option group entry
> > + */
> > +opt_group = qemu_find_opts_err("object", NULL);
> > +if (opt_group) {
> 
> How can opt_group ever be null?
> 
> For what it's worth, we assume it can't in hmp_object_add() and main().

I was trying to avoid as many assumptions as possible since
user_creatable_complete() is kind of reaching out of it's scope here.
If we ever changed the behavior on the parsing side this could result in
a segfault that might slip through if this particular scenario isn't
specifically tested.

However, that's less of a concern now thanks to the unit tests that
Daniel suggested which would catch this breakage. So that kind of handles
my concerns. Will change it for v3.

> 
> > +qemu_opts_del(qemu_opts_find(opt_group, id));
> > +}
> > +
> >  object_unparent(obj);
> >  }
> 




Re: [Qemu-devel] [PATCH v4 00/64] tcg 2.9 patch queue

2016-12-09 Thread Alex Bennée

Richard Henderson  writes:

> This is a combination of two patch sets that have had previous
> revisions, as well as some new patches.  I wanted to post this
> all together since Alex was having trouble with prerequisites.
>
> The full tree is at
>
>   git://github.com/rth7680/qemu.git tcg-2.9

OK I've finished my pass through this uber-set. I've given it a fairly
good tyre-kicking on ARM (guest and hosts) with RISU so I think you can
have a:

Tested-by: Alex Bennée 

for the ARM bits at least.

>
> Changes since v3:
>   * PPC host patches have been properly annotated for cpu revision,
> - cnttz[wd] are power9 inventions,
> - cntpop[wd] are power7 inventions.
>
>   * X86 host checks the correct cpuid bit for lzcnt.
>
>   * Generic TCG has significant changes to enable "interesting"
> combinations of constraints for X86 host bsr/bsf and to some
> extent lzcnt/tzcnt.
>
>   * Opcode for ctpop.  I had begun with only the helpers for ctpop,
> but added the opcode after I discovered that power7/8 could use
> that as a better alternative for implementing ctz.
>
>   * Updates to the i386 and ppc disassemblers, to handle the new
> insns that we're emitting.
>
>
> r~
>
>
> Richard Henderson (64):
>   tcg: Add field extraction primitives
>   tcg: Minor adjustments to deposit expanders
>   tcg: Add deposit_z expander
>   tcg/aarch64: Implement field extraction opcodes
>   tcg/arm: Move isa detection to tcg-target.h
>   tcg/arm: Implement field extraction opcodes
>   tcg/i386: Implement field extraction opcodes
>   tcg/mips: Implement field extraction opcodes
>   tcg/ppc: Implement field extraction opcodes
>   tcg/s390: Expose host facilities to tcg-target.h
>   tcg/s390: Implement field extraction opcodes
>   tcg/s390: Support deposit into zero
>   target-alpha: Use deposit and extract ops
>   target-arm: Use new deposit and extract ops
>   target-i386: Use new deposit and extract ops
>   target-mips: Use the new extract op
>   target-ppc: Use the new deposit and extract ops
>   target-s390x: Use the new deposit and extract ops
>   tcg/optimize: Fold movcond 0/1 into setcond
>   tcg: Add markup for output requires new register
>   tcg: Transition flat op_defs array to a target callback
>   tcg: Pass the opcode width to target_parse_constraint
>   tcg: Allow an operand to be matching or a constant
>   tcg: Add clz and ctz opcodes
>   disas/i386.c: Handle tzcnt
>   disas/ppc: Handle popcnt and cnttz
>   target-alpha: Use the ctz and clz opcodes
>   target-cris: Use clz opcode
>   target-microblaze: Use clz opcode
>   target-mips: Use clz opcode
>   target-openrisc: Use clz and ctz opcodes
>   target-ppc: Use clz and ctz opcodes
>   target-s390x: Use clz opcode
>   target-tilegx: Use clz and ctz opcodes
>   target-tricore: Use clz opcode
>   target-unicore32: Use clz opcode
>   target-xtensa: Use clz opcode
>   target-arm: Use clz opcode
>   target-i386: Use clz and ctz opcodes
>   tcg/ppc: Handle ctz and clz opcodes
>   tcg/aarch64: Handle ctz and clz opcodes
>   tcg/arm: Handle ctz and clz opcodes
>   tcg/mips: Handle clz opcode
>   tcg/s390: Handle clz opcode
>   tcg/i386: Fuly convert tcg_target_op_def
>   tcg/i386: Hoist common arguments in tcg_out_op
>   tcg/i386: Allow bmi2 shiftx to have non-matching operands
>   tcg/i386: Handle ctz and clz opcodes
>   tcg/i386: Rely on undefined/undocumented behaviour of BSF/BSR
>   tcg: Add helpers for clrsb
>   target-arm: Use clrsb helper
>   target-tricore: Use clrsb helper
>   target-xtensa: Use clrsb helper
>   tcg: Add opcode for ctpop
>   target-alpha: Use ctpop helper
>   target-ppc: Use ctpop helper
>   target-s390x: Avoid a loop for popcnt
>   target-sparc: Use ctpop helper
>   target-tilegx: Use ctpop helper
>   target-i386: Use ctpop helper
>   qemu/host-utils.h: Reduce the operation count in the fallback ctpop
>   tcg: Use ctpop to generate ctz if needed
>   tcg/ppc: Handle ctpop opcode
>   tcg/i386: Handle ctpop opcode
>
>  disas/i386.c  |  12 +-
>  disas/ppc.c   |  10 +
>  include/qemu/host-utils.h |  25 +-
>  target-alpha/helper.h |   4 -
>  target-alpha/int_helper.c |  15 -
>  target-alpha/translate.c  |  73 +++--
>  target-arm/helper-a64.c   |  20 --
>  target-arm/helper-a64.h   |   4 -
>  target-arm/helper.c   |   5 -
>  target-arm/helper.h   |   1 -
>  target-arm/translate-a64.c|  95 ++
>  target-arm/translate.c|  43 +--
>  target-cris/helper.h  |   1 -
>  target-cris/op_helper.c   |   5 -
>  target-cris/translate.c   |   2 +-
>  target-i386/cc_helper.c   |   3 +
>  target-i386/cpu.h |   1 +
>  target-i386/helper.h  |   2 -
>  target-i386/int_helper.c  |  11 -
>  target-i386/ops_sse.h |  26 --
>  target-i386/ops_sse_header.h  |   1 -
>  target-i386/translate.c   |  89 ++---
>  target-microblaze/helper.h|   1 -
>  

Re: [Qemu-devel] [PATCH v4 62/64] tcg: Use ctpop to generate ctz if needed

2016-12-09 Thread Alex Bennée

Richard Henderson  writes:

> Particularly when andc is also available, this is two insns
> shorter than using clz to compute ctz.
>
> Signed-off-by: Richard Henderson 
> ---
>  tcg/tcg-op.c | 107 
> ---
>  1 file changed, 65 insertions(+), 42 deletions(-)
>
> diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c
> index 6f4b1b6..d1debde 100644
> --- a/tcg/tcg-op.c
> +++ b/tcg/tcg-op.c
> @@ -497,43 +497,46 @@ void tcg_gen_ctz_i32(TCGv_i32 ret, TCGv_i32 arg1, 
> TCGv_i32 arg2)

>  } else {
> -gen_helper_ctz_i32(ret, arg1, arg2);
> +TCGv_i32 z, t;
> +if (TCG_TARGET_HAS_ctpop_i32 && TCG_TARGET_HAS_andc_i32) {
> +t = tcg_temp_new_i32();
> +tcg_gen_subi_i32(t, arg1, 1);
> +tcg_gen_andc_i32(t, t, arg1);
> +tcg_gen_ctpop_i32(t, t);
> +do_movc:

Hmmm and...


>  void tcg_gen_clrsb_i32(TCGv_i32 ret, TCGv_i32 arg)
> @@ -1842,18 +1845,29 @@ void tcg_gen_ctz_i64(TCGv_i64 ret, TCGv_i64 arg1, 
> TCGv_i64 arg2)
>  {
>  if (TCG_TARGET_HAS_ctz_i64) {
>  tcg_gen_op3_i64(INDEX_op_ctz_i64, ret, arg1, arg2);

>  } else {
> -gen_helper_ctz_i64(ret, arg1, arg2);
> +TCGv_i64 z, t;
> +if (TCG_TARGET_HAS_ctpop_i64 && TCG_TARGET_HAS_andc_i64) {
> +t = tcg_temp_new_i64();
> +tcg_gen_subi_i64(t, arg1, 1);
> +tcg_gen_andc_i64(t, t, arg1);
> +tcg_gen_ctpop_i64(t, t);
> +do_movc:

Hmmm.

So I'm not a goto hater as it makes sense for a bunch of things. But
this seems just a little too liberal usage to my eyes. What's wrong with
a little extra nesting (seeing the compiler sorts it all out in the
end):

if ((TCG_TARGET_HAS_ctpop_i32 && TCG_TARGET_HAS_andc_i32)
|| TCG_TARGET_HAS_clz_i32 || TCG_TARGET_HAS_clz_i64) {

TCGv_i32 z, t;

if (TCG_TARGET_HAS_ctpop_i32 && TCG_TARGET_HAS_andc_i32) {
t = tcg_temp_new_i32();
tcg_gen_subi_i32(t, arg1, 1);
tcg_gen_andc_i32(t, t, arg1);
tcg_gen_ctpop_i32(t, t);
} else if (TCG_TARGET_HAS_clz_i32 || TCG_TARGET_HAS_clz_i64) {
/* Since all non-x86 hosts have clz(0) == 32, don't fight it.  
*/
t = tcg_temp_new_i32();
tcg_gen_neg_i32(t, arg1);
tcg_gen_and_i32(t, t, arg1);
tcg_gen_clzi_i32(t, t, 32);
tcg_gen_xori_i32(t, t, 31);
}
/* final movc */
z = tcg_const_i32(0);
tcg_gen_movcond_i32(TCG_COND_EQ, ret, arg1, z, arg2, t);
tcg_temp_free_i32(t);
tcg_temp_free_i32(z);
} else {
gen_helper_ctz_i32(ret, arg1, arg2);
}

--
Alex Bennée



Re: [Qemu-devel] [PATCH kvm-unit-tests v8 09/10] arm/arm64: gicv3: add an IPI test

2016-12-09 Thread Andre Przywara
Hi,

On 08/12/16 17:50, Andrew Jones wrote:
> Signed-off-by: Andrew Jones 
> 
> ---
> v8:
>  - keep the gic_common_ops concept completely local to
>lib/arm/gic.c by instead exposing the more useful
>concept of gic-specific functions
>  - sysreg rebase changes
>  - ordered ICC registers in spec-order (OCD kicked in...)
> v7:
>  - add common ipi_send_single/mask (replacing ipi_send).
>Note, the arg order irq,cpu got swapped. [Eric]
>  - comment rewording [Eric]
>  - make enable_defaults a common op [Eric]
>  - gic_enable_defaults() will now invoke gic_init if
>necessary [drew]
>  - split lib/arm/gic.c into gic-v2/3.c [Eric]
> v6: move most gicv2/gicv3 wrappers to common code [Alex]
> v5:
>  - fix copy+paste error in gicv3_write_eoir [drew]
>  - use modern register names [Andre]
> v4:
>  - heavily comment gicv3_ipi_send_tlist() [Eric]
>  - changes needed for gicv2 iar/irqstat fix to other patch
> v2:
>  - use IRM for gicv3 broadcast
> ---
>  arm/unittests.cfg  |  6 
>  lib/arm/asm/arch_gicv3.h   | 21 
>  lib/arm/asm/gic-v2.h   |  6 
>  lib/arm/asm/gic-v3.h   | 12 +++
>  lib/arm/asm/gic.h  | 19 +++
>  lib/arm64/asm/arch_gicv3.h | 22 
>  arm/gic.c  | 81 +++
>  lib/arm/gic-v2.c   | 30 
>  lib/arm/gic-v3.c   | 84 +
>  lib/arm/gic.c  | 85 
> --
>  10 files changed, 350 insertions(+), 16 deletions(-)



> diff --git a/lib/arm/gic-v2.c b/lib/arm/gic-v2.c
> index e80eb8f29488..dc6a97c600ec 100644
> --- a/lib/arm/gic-v2.c
> +++ b/lib/arm/gic-v2.c
> @@ -25,3 +25,33 @@ void gicv2_enable_defaults(void)
>   writel(GICC_INT_PRI_THRESHOLD, cpu_base + GICC_PMR);
>   writel(GICC_ENABLE, cpu_base + GICC_CTLR);
>  }
> +
> +u32 gicv2_read_iar(void)
> +{
> + return readl(gicv2_cpu_base() + GICC_IAR);
> +}
> +
> +u32 gicv2_iar_irqnr(u32 iar)
> +{
> + return iar & GICC_IAR_INT_ID_MASK;
> +}
> +
> +void gicv2_write_eoir(u32 irqstat)
> +{
> + writel(irqstat, gicv2_cpu_base() + GICC_EOIR);
> +}
> +
> +void gicv2_ipi_send_single(int irq, int cpu)
> +{
> + assert(cpu < 8);
> + assert(irq < 16);
> + writel(1 << (cpu + 16) | irq, gicv2_dist_base() + GICD_SGIR);
> +}
> +
> +void gicv2_ipi_send_mask(int irq, const cpumask_t *dest)
> +{
> + u8 tlist = (u8)cpumask_bits(dest)[0];
> +
> + assert(irq < 16);
> + writel(tlist << 16 | irq, gicv2_dist_base() + GICD_SGIR);
> +}
> diff --git a/lib/arm/gic-v3.c b/lib/arm/gic-v3.c
> index c46d16e11782..9682fc96b631 100644
> --- a/lib/arm/gic-v3.c
> +++ b/lib/arm/gic-v3.c
> @@ -59,3 +59,87 @@ void gicv3_enable_defaults(void)
>   gicv3_write_pmr(GICC_INT_PRI_THRESHOLD);
>   gicv3_write_grpen1(1);
>  }
> +
> +u32 gicv3_iar_irqnr(u32 iar)
> +{
> + return iar;

I am probably a bit paranoid here, but the spec says that the interrupt
ID is in bits[23:0] only (at most).

> +}
> +
> +void gicv3_ipi_send_mask(int irq, const cpumask_t *dest)
> +{
> + u16 tlist;
> + int cpu;
> +
> + assert(irq < 16);
> +
> + /*
> +  * For each cpu in the mask collect its peers, which are also in
> +  * the mask, in order to form target lists.
> +  */
> + for_each_cpu(cpu, dest) {
> + u64 mpidr = cpus[cpu], sgi1r;
> + u64 cluster_id;
> +
> + /*
> +  * GICv3 can send IPIs to up 16 peer cpus with a single
> +  * write to ICC_SGI1R_EL1 (using the target list). Peers
> +  * are cpus that have nearly identical MPIDRs, the only
> +  * difference being Aff0. The matching upper affinity
> +  * levels form the cluster ID.
> +  */
> + cluster_id = mpidr & ~0xffUL;
> + tlist = 0;
> +
> + /*
> +  * Sort of open code for_each_cpu in order to have a
> +  * nested for_each_cpu loop.
> +  */
> + while (cpu < nr_cpus) {
> + if ((mpidr & 0xff) >= 16) {
> + printf("cpu%d MPIDR:aff0 is %d (>= 16)!\n",
> + cpu, (int)(mpidr & 0xff));
> + break;
> + }
> +
> + tlist |= 1 << (mpidr & 0xf);
> +
> + cpu = cpumask_next(cpu, dest);
> + if (cpu >= nr_cpus)
> + break;
> +
> + mpidr = cpus[cpu];
> +
> + if (cluster_id != (mpidr & ~0xffUL)) {
> + /*
> +  * The next cpu isn't in our cluster. Roll
> +  * back the cpu index allowing the outer
> +  * for_each_cpu to find it again with
> +  * cpumask_next
> +

Re: [Qemu-devel] [PATCH v4 04/64] tcg/aarch64: Implement field extraction opcodes

2016-12-09 Thread Alex Bennée

Richard Henderson  writes:

> On 12/06/2016 04:24 AM, Alex Bennée wrote:
>>> > +case INDEX_op_extract_i64:
>>> > +case INDEX_op_extract_i32:
>>> > +tcg_out_ubfm(s, ext, a0, a1, a2, a2 + args[3] - 1);
>>> > +break;
>>> > +
>>> > +case INDEX_op_sextract_i64:
>>> > +case INDEX_op_sextract_i32:
>>> > +tcg_out_sbfm(s, ext, a0, a1, a2, a2 + args[3] - 1);
>>> > +break;
>>> > +
>> This isn't right is it? As I'm reading it extract takes from a
>> offset+len from the source register to low bits of the destination
>> register. The Bitfield Move instructions are the other way around,
>> moving from the low order bits in the source register to an offset+len
>> in the destination.
>>
>
> It is right.  Extract is written as ofs/len in assembly, but encoded as 
> lsb/msb
> in the opcode -- just like bitfield move.
>
> Boot an armv7 guest and there should be enough uses to convince you.

Yeah I got confused by the description and missed that UBFX is an alias
in those cases.

Reviewed-by: Alex Bennée 

--
Alex Bennée



[Qemu-devel] Any QEMU 2.8 release blockers?

2016-12-09 Thread Stefan Hajnoczi
Hi folks,
How is QEMU 2.8.0-rc3 holding up?

I'm not aware of release blockers.  QEMU 2.8.0 will be released on
Tuesday, December 13th if nothing comes up.  It will be the -rc3
source tree.

Stefan



Re: [Qemu-devel] [PATCH RFC 0/1] Allow storing the qcow2 L2 cache in disk

2016-12-09 Thread Alberto Garcia
On Fri 09 Dec 2016 03:18:23 PM CET, Kevin Wolf wrote:
>> I have been making some tests with exactly that scenario and the
>> results look good: storing the cache in disk gives roughly the same
>> performance as storing it in memory.
>> 
>> |-++--++|
>> | | Random 4k reads   | Sequential 4k reads |
>> | | Throughput | IOPS | Throughput |  IOPS  |
>> |-++--++|
>> | Cache in memory/SSD | 406 KB/s   |   99 | 84 MB/s|  21000 |
>> | Default cache (1MB) | 200 KB/s   |   60 | 83 MB/s|  21000 |
>> | No cache| 200 KB/s   |   49 | 56 MB/s|  14000 |
>> |-++--++|
>> 
>> I'm including the patch that I used to get these results. This is the
>> simplest approach that I could think of.
>> 
>> Opinions, questions?
>
> I suppose you used the fact that the cache is now on disk to increase
> the cache size so that it covers the whole image?

Right, the wording on the table is not clear, but that's what I did. I
also don't think this makes much sense if the cache is not big enough to
cover the whole image.

> If so, are you sure that you aren't just testing that accessing memory
> in the kernel page cache is just as fast as accessing memory in qemu's
> own cache? It seems this would just bypass the cache size limit given
> to qemu by instead leaving things cached in the kernel where the limit
> doesn't apply.

Fair question: what I checked is that the PSS/RSS values match the
expected values (i.e, they don't grow as you read from the disk
image). If the kernel is caching those pages so accessing them after
MADV_DONTNEED does not require going to disk again is a possibility that
I haven't ruled out.

Berto



Re: [Qemu-devel] [PATCH v4 61/64] qemu/host-utils.h: Reduce the operation count in the fallback ctpop

2016-12-09 Thread Alex Bennée

Richard Henderson  writes:

> Signed-off-by: Richard Henderson 

Reviewed-by: Alex Bennée 

As it looked like we were messing about with the Hackers Delight
algorithms I thought it might be worth defending any changes with some
unit tests. Feel free to include the unit test bellow:

--8<---cut here---start->8---
>From 66857f0be793c86ce9aaa6e02ffccc6552f6e894 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alex=20Benn=C3=A9e?= 
Date: Fri, 9 Dec 2016 14:36:00 +
Subject: [PATCH] new: tests/test-bitcnt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add some unit tests for bit count functions (currently only ctpop). As
the routines are based on the Hackers Delight optimisations I based
the test patterns on their tests.

Signed-off-by: Alex Bennée 
---
 tests/.gitignore   |   1 +
 tests/Makefile.include |   2 +
 tests/test-bitcnt.c| 135 +
 3 files changed, 138 insertions(+)
 create mode 100644 tests/test-bitcnt.c

diff --git a/tests/.gitignore b/tests/.gitignore
index c0d7857538..96986efc1a 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -13,6 +13,7 @@ rcutorture
 test-aio
 test-base64
 test-bitops
+test-bitcnt
 test-blockjob
 test-blockjob-txn
 test-bufferiszero
diff --git a/tests/Makefile.include b/tests/Makefile.include
index e98d3b6bb3..8b85c5399a 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -81,6 +81,7 @@ gcov-files-test-qht-y = util/qht.c
 check-unit-y += tests/test-qht-par$(EXESUF)
 gcov-files-test-qht-par-y = util/qht.c
 check-unit-y += tests/test-bitops$(EXESUF)
+check-unit-y += tests/test-bitcnt$(EXESUF)
 check-unit-$(CONFIG_HAS_GLIB_SUBPROCESS_TESTS) += 
tests/test-qdev-global-props$(EXESUF)
 check-unit-y += tests/check-qom-interface$(EXESUF)
 gcov-files-check-qom-interface-y = qom/object.c
@@ -570,6 +571,7 @@ tests/test-opts-visitor$(EXESUF): tests/test-opts-visitor.o 
$(test-qapi-obj-y)

 tests/test-mul64$(EXESUF): tests/test-mul64.o $(test-util-obj-y)
 tests/test-bitops$(EXESUF): tests/test-bitops.o $(test-util-obj-y)
+tests/test-bitcnt$(EXESUF): tests/test-bitcnt.o $(test-util-obj-y)
 tests/test-crypto-hash$(EXESUF): tests/test-crypto-hash.o $(test-crypto-obj-y)
 tests/test-crypto-cipher$(EXESUF): tests/test-crypto-cipher.o 
$(test-crypto-obj-y)
 tests/test-crypto-secret$(EXESUF): tests/test-crypto-secret.o 
$(test-crypto-obj-y)
diff --git a/tests/test-bitcnt.c b/tests/test-bitcnt.c
new file mode 100644
index 00..3969b32803
--- /dev/null
+++ b/tests/test-bitcnt.c
@@ -0,0 +1,135 @@
+/*
+ * Test bit count routines
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+
+#include "qemu/osdep.h"
+#include "qemu/host-utils.h"
+
+struct bitcnt_test_data {
+/* value to count */
+union {
+uint8_t  w8;
+uint16_t w16;
+uint32_t w32;
+uint64_t w64;
+} value;
+/* expected result */
+int popct;
+};
+
+struct bitcnt_test_data eight_bit_data[] = {
+{ { .w8 = 0x01 }, .popct=1 },
+{ { .w8 = 0x03 }, .popct=2 },
+{ { .w8 = 0x04 }, .popct=1 },
+{ { .w8 = 0x0f }, .popct=4 },
+{ { .w8 = 0x3f }, .popct=6 },
+{ { .w8 = 0x40 }, .popct=1 },
+{ { .w8 = 0xf0 }, .popct=4 },
+{ { .w8 = 0x7f }, .popct=7 },
+{ { .w8 = 0x80 }, .popct=1 },
+{ { .w8 = 0xf1 }, .popct=5 },
+{ { .w8 = 0xfe }, .popct=7 },
+{ { .w8 = 0xff }, .popct=8 },
+};
+
+static void test_ctpop8(void)
+{
+int i;
+
+for (i = 0; i < ARRAY_SIZE(eight_bit_data); i++) {
+struct bitcnt_test_data *d = _bit_data[i];
+g_assert(ctpop8(d->value.w8)==d->popct);
+}
+}
+
+struct bitcnt_test_data sixteen_bit_data[] = {
+{ { .w16 = 0x0001 }, .popct=1 },
+{ { .w16 = 0x0003 }, .popct=2 },
+{ { .w16 = 0x000f }, .popct=4 },
+{ { .w16 = 0x003f }, .popct=6 },
+{ { .w16 = 0x00f0 }, .popct=4 },
+{ { .w16 = 0x0f0f }, .popct=8 },
+{ { .w16 = 0x1f1f }, .popct=10 },
+{ { .w16 = 0x4000 }, .popct=1 },
+{ { .w16 = 0x4001 }, .popct=2 },
+{ { .w16 = 0x7000 }, .popct=3 },
+{ { .w16 = 0x7fff }, .popct=15 },
+};
+
+static void test_ctpop16(void)
+{
+int i;
+
+for (i = 0; i < ARRAY_SIZE(sixteen_bit_data); i++) {
+struct bitcnt_test_data *d = _bit_data[i];
+g_assert(ctpop16(d->value.w16)==d->popct);
+}
+}
+
+struct bitcnt_test_data thirtytwo_bit_data[] = {
+{ { .w32 = 0x0001 }, .popct=1 },
+{ { .w32 = 0x000f }, .popct=4 },
+{ { .w32 = 0x0f0f }, .popct=8 },
+{ { .w32 = 0x1f1f }, .popct=10 },
+{ { .w32 = 0x4001 }, .popct=2 },
+{ { .w32 = 0x7000 }, .popct=3 },
+{ { .w32 = 0x7fff }, .popct=15 },
+{ { .w32 = 0x }, .popct=16 },
+{ { .w32 = 0x }, .popct=16 },
+

Re: [Qemu-devel] dpdk/vpp and cross-version migration for vhost

2016-12-09 Thread Daniel P. Berrange
On Fri, Dec 09, 2016 at 02:35:58PM +0100, Maxime Coquelin wrote:
> ++Daniel for libvirt
> 
> On 11/24/2016 07:31 AM, Yuanhan Liu wrote:
> > > > > > > > > As version here is an opaque string for libvirt and qemu,
> > > > > > > > > > > > > > >>anything can be used - but I suggest either a list
> > > > > > > > > > > > > > >>of values defining the interface, e.g.
> > > > > > > > > > > > > > >>any_layout=on,max_ring=256
> > > > > > > > > > > > > > >>or a version including the name and vendor of the 
> > > > > > > > > > > > > > >>backend,
> > > > > > > > > > > > > > >>e.g. "org.dpdk.v4.5.6".
> > > > > >
> > > > > > The version scheme may not be ideal here. Assume a QEMU is supposed
> > > > > > to work with a specific DPDK version, however, user may disable some
> > > > > > newer features through qemu command line, that it also could work 
> > > > > > with
> > > > > > an elder DPDK version. Using the version scheme will not allow us 
> > > > > > doing
> > > > > > such migration to an elder DPDK version. The MTU is a lively example
> > > > > > here? (when MTU feature is provided by QEMU but is actually disabled
> > > > > > by user, that it could also work with an elder DPDK without MTU 
> > > > > > support).
> > > > > >
> > > > > > --yliu
> > > >
> > > > OK, so does a list of values look better to you then?
> > Yes, if there are no better way.
> > 
> > And I think it may be better to not list all those features, literally.
> > But instead, using the number should be better, say, features=0xdeadbeef.
> > 
> > Listing the feature names means we have to come to an agreement in all
> > components involved here (QEMU, libvirt, DPDK, VPP, and maybe more
> > backends), that we have to use the exact same feature names. Though it
> > may not be a big deal, it lacks some flexibility.
> > 
> > A feature bits will not have this issue.
> 
> I initially thought having key/value pairs would be more flexible, and
> could allow migrating to another application if compatible (i.e. from
> OVS to VPP, and vice versa...) without needing synchronization between
> the applications.
> 
> But Daniel pointed me out that it would add a lot of complexity on
> management tool side, as it would need to know how to interpret these
> key/value pairs. I think his argument is very valid.
> 
> So maybe the best way would be the version string, letting the
> application (OVS-DPDK/VPP/...) specify which version it is
> compatible with.
> For the downsides, as soon as a new feature is supported in vhost-user
> application, the new version will not be advertised as compatible with
> the previous one, even if the user disables the feature in Qemu (as
> pointed out by Yuanhan).

We need two distinct capabilities in order to make this work properly.

First, libvirt needs to be able to query the list of (one or more)
supported versions strings for a given host.

Second, when launching QEMU we need to be able to specify the desired
version against the NIC backend.

So, consider host A, initially supporting "ovsdpdk-v1". When libvirt
launches the VM it will specify 'ovsdpgk-v1' as the desired version
string to use.

Now some time later you add features X, Y & Z to a new release of
DPDK and install this on host B.  Host B is able to support two
versions 'ovsdppk-v1' and 'ovsdpdk-v2'.  When libvirt launches
a VM on host B, it'll pick 'ovsdpgk-v2' by default, since that's
the newest.   When libvirt migrates a VM from host A, however,
it will request the old version 'ovsdpdk-v1' in order to ensure
compatibility.  Similarly when launching a new VM on host B,
libvirt could choose to use 'ovsdpdk-v1' as the version, in
order to enable migration to the olver host A, if desired.

This is exactly the way QEMU machine types work, hiding the
existance of 100's low level settings / default values, that
a mgmt app would otherwise have to worry about.

Regards,
Daniel
-- 
|: http://berrange.com  -o-http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o- http://virt-manager.org :|
|: http://entangle-photo.org   -o-http://search.cpan.org/~danberr/ :|



[Qemu-devel] [PATCH] hw/intc/arm_gicv3_common: fix aff3 in typer

2016-12-09 Thread Andrew Jones
Signed-off-by: Andrew Jones 
---
 hw/intc/arm_gicv3_common.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/intc/arm_gicv3_common.c b/hw/intc/arm_gicv3_common.c
index 0f8c4b86e023..0aa9b9ca6655 100644
--- a/hw/intc/arm_gicv3_common.c
+++ b/hw/intc/arm_gicv3_common.c
@@ -204,7 +204,8 @@ static void arm_gicv3_common_realize(DeviceState *dev, 
Error **errp)
 /* The CPU mp-affinity property is in MPIDR register format; squash
  * the affinity bytes into 32 bits as the GICR_TYPER has them.
  */
-cpu_affid = (cpu_affid & 0xFFULL >> 8) | (cpu_affid & 
0xFF);
+cpu_affid = ((cpu_affid & 0xFFULL) >> 8) |
+ (cpu_affid & 0xFF);
 s->cpu[i].gicr_typer = (cpu_affid << 32) |
 (1 << 24) |
 (i << 8) |
-- 
2.9.3




Re: [Qemu-devel] [PATCH 11/20] sparc: Move CPU files to target/ folder

2016-12-09 Thread Artyom Tarasenko
Acked-By: Artyom Tarasenko 

(Forgot to hit "Reply to all" in the previous mail)


> On Fri, Dec 9, 2016 at 1:17 PM, Thomas Huth  wrote:
>> Signed-off-by: Thomas Huth 
>> ---
>>  MAINTAINERS   | 2 +-
>>  Makefile.objs | 2 +-
>>  {target-sparc => target/sparc}/Makefile.objs  | 0
>>  {target-sparc => target/sparc}/TODO   | 0
>>  {target-sparc => target/sparc}/asi.h  | 0
>>  {target-sparc => target/sparc}/cc_helper.c| 0
>>  {target-sparc => target/sparc}/cpu-qom.h  | 0
>>  {target-sparc => target/sparc}/cpu.c  | 0
>>  {target-sparc => target/sparc}/cpu.h  | 0
>>  {target-sparc => target/sparc}/fop_helper.c   | 0
>>  {target-sparc => target/sparc}/gdbstub.c  | 0
>>  {target-sparc => target/sparc}/helper.c   | 0
>>  {target-sparc => target/sparc}/helper.h   | 0
>>  {target-sparc => target/sparc}/int32_helper.c | 0
>>  {target-sparc => target/sparc}/int64_helper.c | 0
>>  {target-sparc => target/sparc}/ldst_helper.c  | 0
>>  {target-sparc => target/sparc}/machine.c  | 0
>>  {target-sparc => target/sparc}/mmu_helper.c   | 0
>>  {target-sparc => target/sparc}/monitor.c  | 0
>>  {target-sparc => target/sparc}/trace-events   | 8 
>>  {target-sparc => target/sparc}/translate.c| 0
>>  {target-sparc => target/sparc}/vis_helper.c   | 0
>>  {target-sparc => target/sparc}/win_helper.c   | 0
>>  23 files changed, 6 insertions(+), 6 deletions(-)
>>  rename {target-sparc => target/sparc}/Makefile.objs (100%)
>>  rename {target-sparc => target/sparc}/TODO (100%)
>>  rename {target-sparc => target/sparc}/asi.h (100%)
>>  rename {target-sparc => target/sparc}/cc_helper.c (100%)
>>  rename {target-sparc => target/sparc}/cpu-qom.h (100%)
>>  rename {target-sparc => target/sparc}/cpu.c (100%)
>>  rename {target-sparc => target/sparc}/cpu.h (100%)
>>  rename {target-sparc => target/sparc}/fop_helper.c (100%)
>>  rename {target-sparc => target/sparc}/gdbstub.c (100%)
>>  rename {target-sparc => target/sparc}/helper.c (100%)
>>  rename {target-sparc => target/sparc}/helper.h (100%)
>>  rename {target-sparc => target/sparc}/int32_helper.c (100%)
>>  rename {target-sparc => target/sparc}/int64_helper.c (100%)
>>  rename {target-sparc => target/sparc}/ldst_helper.c (100%)
>>  rename {target-sparc => target/sparc}/machine.c (100%)
>>  rename {target-sparc => target/sparc}/mmu_helper.c (100%)
>>  rename {target-sparc => target/sparc}/monitor.c (100%)
>>  rename {target-sparc => target/sparc}/trace-events (94%)
>>  rename {target-sparc => target/sparc}/translate.c (100%)
>>  rename {target-sparc => target/sparc}/vis_helper.c (100%)
>>  rename {target-sparc => target/sparc}/win_helper.c (100%)
>>
>> diff --git a/MAINTAINERS b/MAINTAINERS
>> index 48b0a7b..f8959d8 100644
>> --- a/MAINTAINERS
>> +++ b/MAINTAINERS
>> @@ -218,7 +218,7 @@ SPARC
>>  M: Mark Cave-Ayland 
>>  M: Artyom Tarasenko 
>>  S: Maintained
>> -F: target-sparc/
>> +F: target/sparc/
>>  F: hw/sparc/
>>  F: hw/sparc64/
>>  F: disas/sparc.c
>> diff --git a/Makefile.objs b/Makefile.objs
>> index c5ebb80..e59b979 100644
>> --- a/Makefile.objs
>> +++ b/Makefile.objs
>> @@ -157,7 +157,7 @@ trace-events-y += audio/trace-events
>>  trace-events-y += net/trace-events
>>  trace-events-y += target/arm/trace-events
>>  trace-events-y += target/i386/trace-events
>> -trace-events-y += target-sparc/trace-events
>> +trace-events-y += target/sparc/trace-events
>>  trace-events-y += target/s390x/trace-events
>>  trace-events-y += target/ppc/trace-events
>>  trace-events-y += qom/trace-events
>> diff --git a/target-sparc/Makefile.objs b/target/sparc/Makefile.objs
>> similarity index 100%
>> rename from target-sparc/Makefile.objs
>> rename to target/sparc/Makefile.objs
>> diff --git a/target-sparc/TODO b/target/sparc/TODO
>> similarity index 100%
>> rename from target-sparc/TODO
>> rename to target/sparc/TODO
>> diff --git a/target-sparc/asi.h b/target/sparc/asi.h
>> similarity index 100%
>> rename from target-sparc/asi.h
>> rename to target/sparc/asi.h
>> diff --git a/target-sparc/cc_helper.c b/target/sparc/cc_helper.c
>> similarity index 100%
>> rename from target-sparc/cc_helper.c
>> rename to target/sparc/cc_helper.c
>> diff --git a/target-sparc/cpu-qom.h b/target/sparc/cpu-qom.h
>> similarity index 100%
>> rename from target-sparc/cpu-qom.h
>> rename to target/sparc/cpu-qom.h
>> diff --git a/target-sparc/cpu.c b/target/sparc/cpu.c
>> similarity index 100%
>> rename from target-sparc/cpu.c
>> rename to target/sparc/cpu.c
>> diff --git a/target-sparc/cpu.h b/target/sparc/cpu.h
>> similarity index 100%
>> rename from target-sparc/cpu.h
>> rename to target/sparc/cpu.h
>> diff --git a/target-sparc/fop_helper.c b/target/sparc/fop_helper.c
>> similarity index 100%
>> rename from target-sparc/fop_helper.c
>> rename to target/sparc/fop_helper.c
>> diff --git 

Re: [Qemu-devel] [PATCH RFC 0/1] Allow storing the qcow2 L2 cache in disk

2016-12-09 Thread Max Reitz
On 09.12.2016 14:47, Alberto Garcia wrote:
> Hi all,
> 
> as we all know, one of the main things that can make the qcow2 format
> slow is the need to load entries from the L2 table in order to map a
> guest offset (on the virtual disk) to a host offset (on the qcow2
> image).
> 
> We have an L2 cache to deal with this, and as long as the cache is big
> enough then the peformance is comparable to that of a raw image.
> 
> For large qcow2 images the amount of RAM we need in order to cache all
> L2 tables can be big (128MB per TB of disk image if we're using the
> default cluster size of 64KB). In order to solve this problem we have
> a setting that allows the user to clean unused cache entries after a
> certain interval of time. This works fine most of the time, although
> we can still have peaks of RAM usage if there's a lot of I/O going on
> in one or more VMs.
> 
> In some scenarios, however, there's a different alternative: if the
> qcow2 image is stored in a slow backend (eg. HDD), we could save
> memory by putting the L2 cache in a faster one (SSD) instead of in
> RAM.
> 
> I have been making some tests with exactly that scenario and the
> results look good: storing the cache in disk gives roughly the same
> performance as storing it in memory.
> 
> |-++--++|
> | | Random 4k reads   | Sequential 4k reads |
> | | Throughput | IOPS | Throughput |  IOPS  |
> |-++--++|
> | Cache in memory/SSD | 406 KB/s   |   99 | 84 MB/s|  21000 |
> | Default cache (1MB) | 200 KB/s   |   60 | 83 MB/s|  21000 |
> | No cache| 200 KB/s   |   49 | 56 MB/s|  14000 |
> |-++--++|
> 
> I'm including the patch that I used to get these results. This is the
> simplest approach that I could think of.
> 
> Opinions, questions?

Well, from a full design standpoint, it doesn't make a lot of sense to me:

We have a two-level on-disk structure for cluster mapping so as to not
waste memory for unused areas and so that we don't need to keep one
large continuous chunk of metadata. Accessing the disk is slow, so we
also have an in-memory cache which is just a single level fully
associative cache replicating the same data (but just a part of it).

Now you want to replicate all of it and store it on disk. My mind tells
me that is duplicate data: We already have all of the metadata elsewhere
on disk, namely in the qcow2 file, and even better, it is not stored in
a fully associative structure there but directly mapped, making finding
the correct entry much quicker.

Therefore, this is not a good idea. The existing structures already
exist and are just better.

However, the thing is that the existing structures also only exist in
the original qcow2 file and cannot be just placed anywhere else, as
opposed to our cache. In order to solve this, we would need to
(incompatibly) modify the qcow2 format to allow storing data
independently from metadata. I think this would be certainly doable, but
the question is whether it is worth the effort.

I'm not sure, maybe it actually is worth the effort. Your patch is nice
and simple and certainly improves things now. But the question is
whether we can't do better than to look up all cluster mappings in a
fully associative table.

Maybe we can at least make the cache directly mapped if it is supposed
to cover the whole image? That is, we would basically just load all of
the L2 tables into memory and bypass the existing cache.

Max



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH RFC 0/1] Allow storing the qcow2 L2 cache in disk

2016-12-09 Thread Kevin Wolf
Am 09.12.2016 um 14:47 hat Alberto Garcia geschrieben:
> Hi all,
> 
> as we all know, one of the main things that can make the qcow2 format
> slow is the need to load entries from the L2 table in order to map a
> guest offset (on the virtual disk) to a host offset (on the qcow2
> image).
> 
> We have an L2 cache to deal with this, and as long as the cache is big
> enough then the peformance is comparable to that of a raw image.
> 
> For large qcow2 images the amount of RAM we need in order to cache all
> L2 tables can be big (128MB per TB of disk image if we're using the
> default cluster size of 64KB). In order to solve this problem we have
> a setting that allows the user to clean unused cache entries after a
> certain interval of time. This works fine most of the time, although
> we can still have peaks of RAM usage if there's a lot of I/O going on
> in one or more VMs.
> 
> In some scenarios, however, there's a different alternative: if the
> qcow2 image is stored in a slow backend (eg. HDD), we could save
> memory by putting the L2 cache in a faster one (SSD) instead of in
> RAM.
> 
> I have been making some tests with exactly that scenario and the
> results look good: storing the cache in disk gives roughly the same
> performance as storing it in memory.
> 
> |-++--++|
> | | Random 4k reads   | Sequential 4k reads |
> | | Throughput | IOPS | Throughput |  IOPS  |
> |-++--++|
> | Cache in memory/SSD | 406 KB/s   |   99 | 84 MB/s|  21000 |
> | Default cache (1MB) | 200 KB/s   |   60 | 83 MB/s|  21000 |
> | No cache| 200 KB/s   |   49 | 56 MB/s|  14000 |
> |-++--++|
> 
> I'm including the patch that I used to get these results. This is the
> simplest approach that I could think of.
> 
> Opinions, questions?

I suppose you used the fact that the cache is now on disk to increase
the cache size so that it covers the whole image?

If so, are you sure that you aren't just testing that accessing memory
in the kernel page cache is just as fast as accessing memory in qemu's
own cache? It seems this would just bypass the cache size limit given to
qemu by instead leaving things cached in the kernel where the limit
doesn't apply.

Kevin



Re: [Qemu-devel] [PATCH 02/36] qdict: Add convenience helpers for wrapped puts

2016-12-09 Thread Alberto Garcia
On Wed 30 Nov 2016 08:44:20 PM CET, Eric Blake wrote:
> Quite a few users of qdict_put() were manually wrapping a
> non-QObject. We can make such call-sites shorter, by providing
> common macros to do the tedious work.  Also shorten nearby
> qdict_put_obj(,,QOBJECT()) sequences.
>
> Signed-off-by: Eric Blake 

Thanks, the code looks much better now :)

Reviewed-by: Alberto Garcia 

Berto



Re: [Qemu-devel] [PATCH for-2.9 v2] virtio-crypto: zeroize the key material before free

2016-12-09 Thread Max Reitz
On 09.12.2016 02:42, Gonglei (Arei) wrote:
> Hi,
> 
>>
>> Subject: Re: [Qemu-devel] [PATCH for-2.9 v2] virtio-crypto: zeroize the key
>> material before free
>>
>> On 08.12.2016 16:23, Eric Blake wrote:
>>> On 12/07/2016 08:28 PM, Gonglei (Arei) wrote:
>>>
> As far as I'm aware, other projects usually have a special memset
> variation for doing this. That is because compilers may choose to
> "optimize" memset(p, ...) + free(p) to just the free(p). Having a

 Actually, I googled this, but I didn't find a definite answer. And

 The Linux kernel uses kzfree instead of memset + kfree
>> (mm/slab_common.c).
>>
>> Well, I personally don't mind whether we use a custom zfree() or a
>> custom memset_s() + free(). I only mind that this patch actually always
>> does what it is intended to do.
>>
> Yes, but why linux kernel to think about the compiler optimization for
> memset for sensitive data?

I'm afraid I don't quite (syntactically) understand this question. Do
you mean to ask why the Linux kernel would have to think about this
optimization? My answer to that would be because the optimization of
memset() + free() is known, and they probably want to protect against
the compiler optimizing it even with -ffreestanding and differently
called functions -- you never know.

Related example: gcc detects code that basically does a memset() and
replaces it with a call to memset(). There were a couple of versions
where it did that even with -ffreestanding or -fno-builtin, which is bad
if you want to actually write a memset(). They fixed it by now (so that
-ffreestanding and -fno-builtin will imply
-fno-tree-loop-distribute-patterns, which will disable that optimization.

Now imagine the same case here: Maybe at some point gcc is able to
detect that kfree() is basically free() and will then optimize the
memset() before kfree() away. A couple of versions later, somebody will
notice that -- but at that point, the damage has been done already and
there are compiled versions out which leak sensitive data somewhere.

I think this is why the Linux kernel decides to be proactive and use
kzfree() from the start, and this is also why I'm proposing to not delay
this issue in qemu until some compiler actually makes it a real issue.

>>> If we're worried about cleaning things without allowing the compiler a
>>> chance to optimize, then writing our own qemu_zfree() wrapper may indeed
>>> make sense.  But that won't cover the case in Daniel's earlier patch
>>> (referenced elsewhere in this thread), as that was zeroizing stack
>>> memory (before it went out of scope) rather than heap memory (before
>>> free).  So you'd still need some sort of 'write this memory no matter
>>> what' primitive that would be directly usable on stack memory and
>>> indirectly used as part of the qemu_zfree() wrapper.
>>>
> If we wrap a secure_memset(), then both stack memory and heap
> memory can use it.
> 
> Pls see:
> 
> http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1381.pdf
> 
> But the secure_memset() is not as efficient as possible due to the nature of 
> the volatile
> type qualifier preventing the compiler from optimizing the code at all.
> 
> It will cause huge performance regression at hot path of data plane...

I would suggest we implement an own secure_memset() or secure_bzero()
which falls back on what we have:
- memset_s(), if that is available;
- explizit_bzero() if we have libbsd;
- SecureZeroMemory() on Windows

Or we have to write it ourselves:
https://sourceware.org/ml/libc-alpha/2014-12/msg00506.html suggests that
putting a full memory barrier after the memset() should be enough.

>>> But I wouldn't worry about it for now, unless someone proves we actually
>>> have a compiler optimizing away the cleanups.
>>
>> It's true that we don't have to worry about it *now*, but the approach
>> of waiting until the compiler breaks it does not seem right to me.
>>
>> If at some point some compiler recognizes g_free() as being the same
>> function as free() and thus optimizes memset() + g_free(), we simply
>> won't notice because nobody will keep track of the generated assembly
>> output all the time.
>>
>> There is a reason C11 introduced memset_s(), and it is this.
>>
> ...does it make sense if we introduce secure_memset() now ? 
> 
> Waiting for your feedback. Thanks!

I would propose so; or better something like secure_bzero() or
secure_memzero(), because we can then fall back on existing
implementations like explizit_bzero() or SecureZeroMemory().

We don't have to implement this immediately, but we should do it before
the 2.9 release.

Max



signature.asc
Description: OpenPGP digital signature


[Qemu-devel] [PATCH RFC 1/1] qcow2: Allow storing the qcow2 L2 cache in disk

2016-12-09 Thread Alberto Garcia
In scenarios where we have a large qcow2 file stored in a slow storage
backend, we can save memory by storing its L2 cache in a faster drive
rather than keeping it in RAM.

Signed-off-by: Alberto Garcia 
---
 block/qcow2-cache.c | 56 +
 block/qcow2.c   | 11 +--
 block/qcow2.h   |  3 ++-
 3 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
index 1d25147..8ba8ed9 100644
--- a/block/qcow2-cache.c
+++ b/block/qcow2-cache.c
@@ -23,6 +23,7 @@
  */
 
 #include "qemu/osdep.h"
+#include "qemu/mmap-alloc.h"
 #include "block/block_int.h"
 #include "qemu-common.h"
 #include "qcow2.h"
@@ -36,6 +37,7 @@ typedef struct Qcow2CachedTable {
 } Qcow2CachedTable;
 
 struct Qcow2Cache {
+int fd;
 Qcow2CachedTable   *entries;
 struct Qcow2Cache  *depends;
 int size;
@@ -63,7 +65,7 @@ static inline int qcow2_cache_get_table_idx(BlockDriverState 
*bs,
 }
 
 static void qcow2_cache_table_release(BlockDriverState *bs, Qcow2Cache *c,
-  int i, int num_tables)
+  int i, int num_tables, bool flush)
 {
 /* Using MADV_DONTNEED to discard memory is a Linux-specific feature */
 #ifdef CONFIG_LINUX
@@ -74,6 +76,10 @@ static void qcow2_cache_table_release(BlockDriverState *bs, 
Qcow2Cache *c,
 size_t offset = QEMU_ALIGN_UP((uintptr_t) t, align) - (uintptr_t) t;
 size_t length = QEMU_ALIGN_DOWN(mem_size - offset, align);
 if (length > 0) {
+if (flush) {
+assert(c->fd > 0);
+msync((uint8_t *) t + offset, length, MS_SYNC);
+}
 madvise((uint8_t *) t + offset, length, MADV_DONTNEED);
 }
 #endif
@@ -106,26 +112,50 @@ void qcow2_cache_clean_unused(BlockDriverState *bs, 
Qcow2Cache *c)
 }
 
 if (to_clean > 0) {
-qcow2_cache_table_release(bs, c, i - to_clean, to_clean);
+qcow2_cache_table_release(bs, c, i - to_clean, to_clean, false);
 }
 }
 
 c->cache_clean_lru_counter = c->lru_counter;
 }
 
-Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables)
+Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables,
+   const char *cache_file_path)
 {
 BDRVQcow2State *s = bs->opaque;
 Qcow2Cache *c;
+size_t total_size = (size_t) num_tables * s->cluster_size;
 
 c = g_new0(Qcow2Cache, 1);
 c->size = num_tables;
 c->entries = g_try_new0(Qcow2CachedTable, num_tables);
-c->table_array = qemu_try_blockalign(bs->file->bs,
- (size_t) num_tables * 
s->cluster_size);
+if (cache_file_path) {
+size_t align = MAX(bdrv_opt_mem_align(bs->file->bs), getpagesize());
+char *filename = g_strdup_printf("%s/qemu-qcow2-cache.XX",
+ cache_file_path);
+c->fd = mkstemp(filename);
+if (c->fd > 0) {
+unlink(filename);
+}
+g_free(filename);
+if (c->fd == -1 || ftruncate(c->fd, total_size)) {
+goto out;
+}
+c->table_array = qemu_ram_mmap(c->fd, total_size, align, true);
+} else {
+c->table_array = qemu_try_blockalign(bs->file->bs, total_size);
+}
 
+out:
 if (!c->entries || !c->table_array) {
-qemu_vfree(c->table_array);
+if (cache_file_path) {
+qemu_ram_munmap(c->table_array, total_size);
+if (c->fd > 0) {
+close(c->fd);
+}
+} else {
+qemu_vfree(c->table_array);
+}
 g_free(c->entries);
 g_free(c);
 c = NULL;
@@ -142,7 +172,14 @@ int qcow2_cache_destroy(BlockDriverState *bs, Qcow2Cache 
*c)
 assert(c->entries[i].ref == 0);
 }
 
-qemu_vfree(c->table_array);
+if (c->fd) {
+BDRVQcow2State *s = bs->opaque;
+size_t total_size = (size_t) c->size * s->cluster_size;
+qemu_ram_munmap(c->table_array, total_size);
+close(c->fd);
+} else {
+qemu_vfree(c->table_array);
+}
 g_free(c->entries);
 g_free(c);
 
@@ -297,7 +334,7 @@ int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c)
 c->entries[i].lru_counter = 0;
 }
 
-qcow2_cache_table_release(bs, c, 0, c->size);
+qcow2_cache_table_release(bs, c, 0, c->size, false);
 
 c->lru_counter = 0;
 
@@ -399,6 +436,9 @@ void qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, 
void **table)
 
 if (c->entries[i].ref == 0) {
 c->entries[i].lru_counter = ++c->lru_counter;
+if (c->fd) {
+qcow2_cache_table_release(bs, c, i, 1, true);
+}
 }
 
 assert(c->entries[i].ref >= 0);
diff --git a/block/qcow2.c b/block/qcow2.c
index 96fb8a8..4d5d092 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -461,6 +461,11 @@ static QemuOptsList 

[Qemu-devel] [PATCH RFC 0/1] Allow storing the qcow2 L2 cache in disk

2016-12-09 Thread Alberto Garcia
Hi all,

as we all know, one of the main things that can make the qcow2 format
slow is the need to load entries from the L2 table in order to map a
guest offset (on the virtual disk) to a host offset (on the qcow2
image).

We have an L2 cache to deal with this, and as long as the cache is big
enough then the peformance is comparable to that of a raw image.

For large qcow2 images the amount of RAM we need in order to cache all
L2 tables can be big (128MB per TB of disk image if we're using the
default cluster size of 64KB). In order to solve this problem we have
a setting that allows the user to clean unused cache entries after a
certain interval of time. This works fine most of the time, although
we can still have peaks of RAM usage if there's a lot of I/O going on
in one or more VMs.

In some scenarios, however, there's a different alternative: if the
qcow2 image is stored in a slow backend (eg. HDD), we could save
memory by putting the L2 cache in a faster one (SSD) instead of in
RAM.

I have been making some tests with exactly that scenario and the
results look good: storing the cache in disk gives roughly the same
performance as storing it in memory.

|-++--++|
| | Random 4k reads   | Sequential 4k reads |
| | Throughput | IOPS | Throughput |  IOPS  |
|-++--++|
| Cache in memory/SSD | 406 KB/s   |   99 | 84 MB/s|  21000 |
| Default cache (1MB) | 200 KB/s   |   60 | 83 MB/s|  21000 |
| No cache| 200 KB/s   |   49 | 56 MB/s|  14000 |
|-++--++|

I'm including the patch that I used to get these results. This is the
simplest approach that I could think of.

Opinions, questions?

Thanks,

Berto

Alberto Garcia (1):
  qcow2: Allow storing the qcow2 L2 cache in disk

 block/qcow2-cache.c | 56 +
 block/qcow2.c   | 11 +--
 block/qcow2.h   |  3 ++-
 3 files changed, 59 insertions(+), 11 deletions(-)

-- 
2.10.2




Re: [Qemu-devel] dpdk/vpp and cross-version migration for vhost

2016-12-09 Thread Maxime Coquelin

++Daniel for libvirt

On 11/24/2016 07:31 AM, Yuanhan Liu wrote:

As version here is an opaque string for libvirt and qemu,
> > > > > >>anything can be used - but I suggest either a list
> > > > > >>of values defining the interface, e.g.
> > > > > >>any_layout=on,max_ring=256
> > > > > >>or a version including the name and vendor of the backend,
> > > > > >>e.g. "org.dpdk.v4.5.6".

> >
> > The version scheme may not be ideal here. Assume a QEMU is supposed
> > to work with a specific DPDK version, however, user may disable some
> > newer features through qemu command line, that it also could work with
> > an elder DPDK version. Using the version scheme will not allow us doing
> > such migration to an elder DPDK version. The MTU is a lively example
> > here? (when MTU feature is provided by QEMU but is actually disabled
> > by user, that it could also work with an elder DPDK without MTU support).
> >
> >   --yliu

>
> OK, so does a list of values look better to you then?

Yes, if there are no better way.

And I think it may be better to not list all those features, literally.
But instead, using the number should be better, say, features=0xdeadbeef.

Listing the feature names means we have to come to an agreement in all
components involved here (QEMU, libvirt, DPDK, VPP, and maybe more
backends), that we have to use the exact same feature names. Though it
may not be a big deal, it lacks some flexibility.

A feature bits will not have this issue.


I initially thought having key/value pairs would be more flexible, and
could allow migrating to another application if compatible (i.e. from
OVS to VPP, and vice versa...) without needing synchronization between
the applications.

But Daniel pointed me out that it would add a lot of complexity on
management tool side, as it would need to know how to interpret these
key/value pairs. I think his argument is very valid.

So maybe the best way would be the version string, letting the
application (OVS-DPDK/VPP/...) specify which version it is
compatible with.
For the downsides, as soon as a new feature is supported in vhost-user
application, the new version will not be advertised as compatible with
the previous one, even if the user disables the feature in Qemu (as
pointed out by Yuanhan).

The question is are we ready to add complexity on management tool side
to permit more migration cases, or do we prefer keeping it simple but
sometimes prevent migration even if technically possible?

 -- Maxime



Re: [Qemu-devel] [for-2.9 4/5] pseries: Enable HPT resizing for 2.9

2016-12-09 Thread Laurent Vivier


On 09/12/2016 03:23, David Gibson wrote:
> We've now implemented a PAPR extensions which allows PAPR guests (i.e.
> "pseries" machine type) to resize their hash page table during runtime.
> 
> However, that extension is only enabled if explicitly chosen on the
> command line.  This patch enables it by default for spapr-2.9, but leaves
> it disabled (by default) for older machine types.
> 
> Signed-off-by: David Gibson 
> ---
>  hw/ppc/spapr.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index f3b74dc..25468f6 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2770,7 +2770,7 @@ static void spapr_machine_class_init(ObjectClass *oc, 
> void *data)
>  
>  smc->dr_lmb_enabled = true;
>  smc->tcg_default_cpu = "POWER8";
> -smc->resize_hpt_default = SPAPR_RESIZE_HPT_DISABLED;
> +smc->resize_hpt_default = SPAPR_RESIZE_HPT_ENABLED;
>  mc->query_hotpluggable_cpus = spapr_query_hotpluggable_cpus;
>  fwc->get_dev_path = spapr_get_fw_dev_path;
>  nc->nmi_monitor_handler = spapr_nmi;
> @@ -2851,8 +2851,11 @@ static void 
> spapr_machine_2_8_instance_options(MachineState *machine)
>  
>  static void spapr_machine_2_8_class_options(MachineClass *mc)
>  {
> +sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
> +
>  spapr_machine_2_9_class_options(mc);
>  SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_8);
> +smc->resize_hpt_default = SPAPR_RESIZE_HPT_DISABLED;
>  }
>  
>  DEFINE_SPAPR_MACHINE(2_8, "2.8", false);
> 

Reviewed-by: Laurent Vivier 



Re: [Qemu-devel] [for-2.9 1/5] pseries: Add pseries-2.9 machine type

2016-12-09 Thread Laurent Vivier


On 09/12/2016 03:23, David Gibson wrote:
> Signed-off-by: David Gibson 
> ---
>  hw/ppc/spapr.c  | 23 +--
>  include/hw/compat.h |  3 +++
>  2 files changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index cfadc46..0f25e83 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -2761,18 +2761,37 @@ static const TypeInfo spapr_machine_info = {
>  type_init(spapr_machine_register_##suffix)
>  
>  /*
> + * pseries-2.9
> + */
> +static void spapr_machine_2_9_instance_options(MachineState *machine)
> +{
> +}
> +
> +static void spapr_machine_2_9_class_options(MachineClass *mc)
> +{
> +/* Defaults for the latest behaviour inherited from the base class */
> +}
> +
> +DEFINE_SPAPR_MACHINE(2_9, "2.9", true);
> +
> +/*
>   * pseries-2.8
>   */
> +#define SPAPR_COMPAT_2_8\
> +HW_COMPAT_2_8
> +
>  static void spapr_machine_2_8_instance_options(MachineState *machine)
>  {
> +spapr_machine_2_9_instance_options(machine);
>  }
>  
>  static void spapr_machine_2_8_class_options(MachineClass *mc)
>  {
> -/* Defaults for the latest behaviour inherited from the base class */
> +spapr_machine_2_9_class_options(mc);
> +SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_8);
>  }
>  
> -DEFINE_SPAPR_MACHINE(2_8, "2.8", true);
> +DEFINE_SPAPR_MACHINE(2_8, "2.8", false);
>  
>  /*
>   * pseries-2.7
> diff --git a/include/hw/compat.h b/include/hw/compat.h
> index 0f06e11..f8b8354 100644
> --- a/include/hw/compat.h
> +++ b/include/hw/compat.h
> @@ -1,6 +1,9 @@
>  #ifndef HW_COMPAT_H
>  #define HW_COMPAT_H
>  
> +#define HW_COMPAT_2_8 \
> +/* empty */
> +
>  #define HW_COMPAT_2_7 \
>  {\
>  .driver   = "virtio-pci",\
> 
Reviewed-by: Laurent Vivier 




Re: [Qemu-devel] Timeslice of vCPU thread in QEMU/KVM is not stable

2016-12-09 Thread Weiwei Jia
Hi Pankaj Gupta,

Thanks for your reply. I have found the problem after debug Linux
Kernel. The problem is once there is I/O thread upon vCPU2 thread of
VM1, there will be some mutex (synchronization) produced so that it
will be preempted by vCPU2 thread of VM2. After I set
"/proc/sys/kernel/sched_wakeup_granularity_ns" to be the default value
(3 milliseconds), the timeslice is stable again even though there is
I/O thread upon vCPU2 thread of VM1. That means, vCPU2 thread of VM2
can not preempt vCPU2 thread of VM1 because
"/proc/sys/kernel/sched_wakeup_granularity_ns" is 3 milliseconds.
Thank you again :)

Best Regards,
Harry

On Fri, Dec 9, 2016 at 3:07 AM, Pankaj Gupta  wrote:
> Hello,
>
>>
>> Hi everyone,
>>
>> I am testing the timeslice of vCPU thread in QEMU/KVM. In principle,
>> the timeslice should be stable under following workload but it is
>> unstable after I do experiments with following workload. I appreciate
>> it if you can give me some suggestions. Thanks in advance.
>>
>> Workload settings:
>> In VMM, there are 6 pCPUs which are pCPU0, pCPU1, pCPU2, pCPU3, pCPU4,
>> pCPU5. There are two Kernel Virtual Machines (VM1 and VM2) upon VMM.
>> In each VM, there are 5 vritual CPUs (vCPU0, vCPU1, vCPU2, vCPU3,
>> vCPU4). vCPU0 in VM1 and vCPU0 in VM2 are pinned to pCPU0 and pCPU5
>> separately to handle interrupts dedicatedly. vCPU1 in VM1 and vCPU1 in
>> VM2 are pinned to pCPU1; vCPU2 in VM1 and vCPU2 in VM2 are pinned to
>> pCPU2; vCPU3 in VM1 and vCPU3 in VM2 are pinned to pCPU3; vCPU4 in VM1
>> and vCPU4 in VM2 are pinned to pCPU4. There is one CPU intensive
>> thread (while(1){i++}) upon each vCPU in VM1 and VM2 to avoid the vCPU
>> to be idle. In VM1, I start one I/O thread on vCPU2, which the I/O
>> thread reads 4KB from disk each time (reads 8GB in total). The I/O
>> scheduler in VM1 and VM2 is Noop. The I/O scheduler in VMM is CFQ.
>> "/proc/sys/kernel/sched_min_granularity_ns" is set to be 100
>> microseconds in VM1 and VM2. "/proc/sys/kernel/sched_latency_ns" is
>> set to be 100 microseconds in VM1 and VM2.
>> "/proc/sys/kernel/sched_wakeup_granularity_ns" is set to be 0
>> microseconds in VM1 and VM2.
>> "/proc/sys/kernel/sched_min_granularity_ns" is set to be 2.25
>> milliseconds in VMM. "/proc/sys/kernel/sched_latency_ns" is set to be
>> 18 milliseconds in VMM. "/proc/sys/kernel/sched_wakeup_granularity_ns"
>> is set to be 0 microseconds in VMM. I also pinned the I/O worker
>> threads started by QEMU to pCPU5. The process scheduling class I use
>> is CFS.
>>
>> Linux Kernel version for VMM is: 3.16.39
>> Linux Kernel version for VM1 and VM2 is: 4.7.4
>> QEMU emulator version is: 2.0.0
>>
>> I test the timeslice of vCPU2 thread of VM1 in VMM according to above
>> workload settings and the experiment shows that the timeslice is not
>> stable. I also find that after the I/O thread on vCPU2 in VM1 is
>> finished, the timeslice of vCPU2 thread of VM1 will be stable. From
>> the experiment, it seems that the unstable timeslice of vCPU2 thread
>> of VM1 is caused by the I/O thread on it in VM1. However, I think the
>> I/O thread on vCPU2 in VM1 should not affect its timeslice since each
>> vCPU in VM1 and VM2 has one CPU intensive thread (while(1){i++}).
>> Please give me some suggestions if you have. Thank you.
>
> I think you need to check what else is scheduling on pCPU2(physical cpu).
> If you want to avoid any other task to be scheduled at pCPU2, you need
> to isolate the pCPU2 core to avoid scheduler to run any other task on it.
>
>>
>> Best,
>> Harry
>> --
>> To unsubscribe from this list: send the line "unsubscribe kvm" in
>> the body of a message to majord...@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>



Re: [Qemu-devel] [PATCH 03/20] m68k: Move CPU files to target/ folder

2016-12-09 Thread Laurent Vivier
Le 09/12/2016 à 13:17, Thomas Huth a écrit :
> Signed-off-by: Thomas Huth 
> ---
>  MAINTAINERS| 2 +-
>  include/hw/m68k/mcf.h  | 2 +-
>  {target-m68k => target/m68k}/Makefile.objs | 0
>  {target-m68k => target/m68k}/cpu-qom.h | 0
>  {target-m68k => target/m68k}/cpu.c | 0
>  {target-m68k => target/m68k}/cpu.h | 0
>  {target-m68k => target/m68k}/gdbstub.c | 0
>  {target-m68k => target/m68k}/helper.c  | 0
>  {target-m68k => target/m68k}/helper.h  | 0
>  {target-m68k => target/m68k}/m68k-semi.c   | 0
>  {target-m68k => target/m68k}/op_helper.c   | 0
>  {target-m68k => target/m68k}/qregs.def | 0
>  {target-m68k => target/m68k}/translate.c   | 0
>  13 files changed, 2 insertions(+), 2 deletions(-)
>  rename {target-m68k => target/m68k}/Makefile.objs (100%)
>  rename {target-m68k => target/m68k}/cpu-qom.h (100%)
>  rename {target-m68k => target/m68k}/cpu.c (100%)
>  rename {target-m68k => target/m68k}/cpu.h (100%)
>  rename {target-m68k => target/m68k}/gdbstub.c (100%)
>  rename {target-m68k => target/m68k}/helper.c (100%)
>  rename {target-m68k => target/m68k}/helper.h (100%)
>  rename {target-m68k => target/m68k}/m68k-semi.c (100%)
>  rename {target-m68k => target/m68k}/op_helper.c (100%)
>  rename {target-m68k => target/m68k}/qregs.def (100%)
>  rename {target-m68k => target/m68k}/translate.c (100%)

Acked-by: Laurent Vivier 





Re: [Qemu-devel] [PATCH 07/20] i386: Move CPU files to target/ folder

2016-12-09 Thread Eduardo Habkost
On Fri, Dec 09, 2016 at 01:17:37PM +0100, Thomas Huth wrote:
> Signed-off-by: Thomas Huth 

Acked-by: Eduardo Habkost 

> ---
>  MAINTAINERS  | 4 ++--
>  Makefile.objs| 2 +-
>  hw/i386/acpi-build.c | 2 +-
>  hw/i386/kvm/apic.c   | 2 +-
>  hw/intc/ioapic.c | 2 +-
>  hw/misc/hyperv_testdev.c | 2 +-
>  scripts/analyze-inclusions   | 6 +++---
>  {target-i386 => target/i386}/Makefile.objs   | 0
>  {target-i386 => target/i386}/TODO| 0
>  {target-i386 => target/i386}/arch_dump.c | 0
>  {target-i386 => target/i386}/arch_memory_mapping.c   | 0
>  {target-i386 => target/i386}/bpt_helper.c| 0
>  {target-i386 => target/i386}/cc_helper.c | 0
>  {target-i386 => target/i386}/cc_helper_template.h| 0
>  {target-i386 => target/i386}/cpu-qom.h   | 0
>  {target-i386 => target/i386}/cpu.c   | 0
>  {target-i386 => target/i386}/cpu.h   | 0
>  {target-i386 => target/i386}/excp_helper.c   | 0
>  {target-i386 => target/i386}/fpu_helper.c| 0
>  {target-i386 => target/i386}/gdbstub.c   | 0
>  {target-i386 => target/i386}/helper.c| 0
>  {target-i386 => target/i386}/helper.h| 0
>  {target-i386 => target/i386}/hyperv.c| 0
>  {target-i386 => target/i386}/hyperv.h| 0
>  {target-i386 => target/i386}/int_helper.c| 0
>  {target-i386 => target/i386}/kvm-stub.c  | 0
>  {target-i386 => target/i386}/kvm.c   | 0
>  {target-i386 => target/i386}/kvm_i386.h  | 0
>  {target-i386 => target/i386}/machine.c   | 0
>  {target-i386 => target/i386}/mem_helper.c| 0
>  {target-i386 => target/i386}/misc_helper.c   | 0
>  {target-i386 => target/i386}/monitor.c   | 0
>  {target-i386 => target/i386}/mpx_helper.c| 0
>  {target-i386 => target/i386}/ops_sse.h   | 0
>  {target-i386 => target/i386}/ops_sse_header.h| 0
>  {target-i386 => target/i386}/seg_helper.c| 0
>  {target-i386 => target/i386}/shift_helper_template.h | 0
>  {target-i386 => target/i386}/smm_helper.c| 0
>  {target-i386 => target/i386}/svm.h   | 0
>  {target-i386 => target/i386}/svm_helper.c| 0
>  {target-i386 => target/i386}/trace-events| 2 +-
>  {target-i386 => target/i386}/translate.c | 0
>  42 files changed, 11 insertions(+), 11 deletions(-)
>  rename {target-i386 => target/i386}/Makefile.objs (100%)
>  rename {target-i386 => target/i386}/TODO (100%)
>  rename {target-i386 => target/i386}/arch_dump.c (100%)
>  rename {target-i386 => target/i386}/arch_memory_mapping.c (100%)
>  rename {target-i386 => target/i386}/bpt_helper.c (100%)
>  rename {target-i386 => target/i386}/cc_helper.c (100%)
>  rename {target-i386 => target/i386}/cc_helper_template.h (100%)
>  rename {target-i386 => target/i386}/cpu-qom.h (100%)
>  rename {target-i386 => target/i386}/cpu.c (100%)
>  rename {target-i386 => target/i386}/cpu.h (100%)
>  rename {target-i386 => target/i386}/excp_helper.c (100%)
>  rename {target-i386 => target/i386}/fpu_helper.c (100%)
>  rename {target-i386 => target/i386}/gdbstub.c (100%)
>  rename {target-i386 => target/i386}/helper.c (100%)
>  rename {target-i386 => target/i386}/helper.h (100%)
>  rename {target-i386 => target/i386}/hyperv.c (100%)
>  rename {target-i386 => target/i386}/hyperv.h (100%)
>  rename {target-i386 => target/i386}/int_helper.c (100%)
>  rename {target-i386 => target/i386}/kvm-stub.c (100%)
>  rename {target-i386 => target/i386}/kvm.c (100%)
>  rename {target-i386 => target/i386}/kvm_i386.h (100%)
>  rename {target-i386 => target/i386}/machine.c (100%)
>  rename {target-i386 => target/i386}/mem_helper.c (100%)
>  rename {target-i386 => target/i386}/misc_helper.c (100%)
>  rename {target-i386 => target/i386}/monitor.c (100%)
>  rename {target-i386 => target/i386}/mpx_helper.c (100%)
>  rename {target-i386 => target/i386}/ops_sse.h (100%)
>  rename {target-i386 => target/i386}/ops_sse_header.h (100%)
>  rename {target-i386 => target/i386}/seg_helper.c (100%)
>  rename {target-i386 => target/i386}/shift_helper_template.h (100%)
>  rename {target-i386 => target/i386}/smm_helper.c (100%)
>  rename {target-i386 => target/i386}/svm.h (100%)
>  rename {target-i386 => target/i386}/svm_helper.c (100%)
>  rename {target-i386 => target/i386}/trace-events (94%)
>  rename {target-i386 => target/i386}/translate.c (100%)
[...]

-- 
Eduardo



[Qemu-devel] [PATCH 19/20] xtensa: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS   | 2 +-
 {target-xtensa => target/xtensa}/Makefile.objs| 0
 {target-xtensa => target/xtensa}/core-dc232b.c| 0
 {target-xtensa => target/xtensa}/core-dc232b/core-isa.h   | 0
 {target-xtensa => target/xtensa}/core-dc232b/gdb-config.c | 0
 {target-xtensa => target/xtensa}/core-dc233c.c| 0
 {target-xtensa => target/xtensa}/core-dc233c/core-isa.h   | 0
 {target-xtensa => target/xtensa}/core-dc233c/gdb-config.c | 0
 {target-xtensa => target/xtensa}/core-fsf.c   | 0
 {target-xtensa => target/xtensa}/core-fsf/core-isa.h  | 0
 {target-xtensa => target/xtensa}/cpu-qom.h| 0
 {target-xtensa => target/xtensa}/cpu.c| 0
 {target-xtensa => target/xtensa}/cpu.h| 0
 {target-xtensa => target/xtensa}/gdbstub.c| 0
 {target-xtensa => target/xtensa}/helper.c | 0
 {target-xtensa => target/xtensa}/helper.h | 0
 {target-xtensa => target/xtensa}/import_core.sh   | 0
 {target-xtensa => target/xtensa}/monitor.c| 0
 {target-xtensa => target/xtensa}/op_helper.c  | 0
 {target-xtensa => target/xtensa}/overlay_tool.h   | 0
 {target-xtensa => target/xtensa}/translate.c  | 0
 {target-xtensa => target/xtensa}/xtensa-semi.c| 0
 tests/tcg/xtensa/Makefile | 2 +-
 23 files changed, 2 insertions(+), 2 deletions(-)
 rename {target-xtensa => target/xtensa}/Makefile.objs (100%)
 rename {target-xtensa => target/xtensa}/core-dc232b.c (100%)
 rename {target-xtensa => target/xtensa}/core-dc232b/core-isa.h (100%)
 rename {target-xtensa => target/xtensa}/core-dc232b/gdb-config.c (100%)
 rename {target-xtensa => target/xtensa}/core-dc233c.c (100%)
 rename {target-xtensa => target/xtensa}/core-dc233c/core-isa.h (100%)
 rename {target-xtensa => target/xtensa}/core-dc233c/gdb-config.c (100%)
 rename {target-xtensa => target/xtensa}/core-fsf.c (100%)
 rename {target-xtensa => target/xtensa}/core-fsf/core-isa.h (100%)
 rename {target-xtensa => target/xtensa}/cpu-qom.h (100%)
 rename {target-xtensa => target/xtensa}/cpu.c (100%)
 rename {target-xtensa => target/xtensa}/cpu.h (100%)
 rename {target-xtensa => target/xtensa}/gdbstub.c (100%)
 rename {target-xtensa => target/xtensa}/helper.c (100%)
 rename {target-xtensa => target/xtensa}/helper.h (100%)
 rename {target-xtensa => target/xtensa}/import_core.sh (100%)
 rename {target-xtensa => target/xtensa}/monitor.c (100%)
 rename {target-xtensa => target/xtensa}/op_helper.c (100%)
 rename {target-xtensa => target/xtensa}/overlay_tool.h (100%)
 rename {target-xtensa => target/xtensa}/translate.c (100%)
 rename {target-xtensa => target/xtensa}/xtensa-semi.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 9e9607c..585cd5a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -243,7 +243,7 @@ Xtensa
 M: Max Filippov 
 W: http://wiki.osll.spb.ru/doku.php?id=etc:users:jcmvbkbc:qemu-target-xtensa
 S: Maintained
-F: target-xtensa/
+F: target/xtensa/
 F: hw/xtensa/
 F: tests/tcg/xtensa/
 
diff --git a/target-xtensa/Makefile.objs b/target/xtensa/Makefile.objs
similarity index 100%
rename from target-xtensa/Makefile.objs
rename to target/xtensa/Makefile.objs
diff --git a/target-xtensa/core-dc232b.c b/target/xtensa/core-dc232b.c
similarity index 100%
rename from target-xtensa/core-dc232b.c
rename to target/xtensa/core-dc232b.c
diff --git a/target-xtensa/core-dc232b/core-isa.h 
b/target/xtensa/core-dc232b/core-isa.h
similarity index 100%
rename from target-xtensa/core-dc232b/core-isa.h
rename to target/xtensa/core-dc232b/core-isa.h
diff --git a/target-xtensa/core-dc232b/gdb-config.c 
b/target/xtensa/core-dc232b/gdb-config.c
similarity index 100%
rename from target-xtensa/core-dc232b/gdb-config.c
rename to target/xtensa/core-dc232b/gdb-config.c
diff --git a/target-xtensa/core-dc233c.c b/target/xtensa/core-dc233c.c
similarity index 100%
rename from target-xtensa/core-dc233c.c
rename to target/xtensa/core-dc233c.c
diff --git a/target-xtensa/core-dc233c/core-isa.h 
b/target/xtensa/core-dc233c/core-isa.h
similarity index 100%
rename from target-xtensa/core-dc233c/core-isa.h
rename to target/xtensa/core-dc233c/core-isa.h
diff --git a/target-xtensa/core-dc233c/gdb-config.c 
b/target/xtensa/core-dc233c/gdb-config.c
similarity index 100%
rename from target-xtensa/core-dc233c/gdb-config.c
rename to target/xtensa/core-dc233c/gdb-config.c
diff --git a/target-xtensa/core-fsf.c b/target/xtensa/core-fsf.c
similarity index 100%
rename from target-xtensa/core-fsf.c
rename to target/xtensa/core-fsf.c
diff --git a/target-xtensa/core-fsf/core-isa.h 
b/target/xtensa/core-fsf/core-isa.h
similarity index 100%
rename from target-xtensa/core-fsf/core-isa.h
rename to target/xtensa/core-fsf/core-isa.h
diff --git a/target-xtensa/cpu-qom.h b/target/xtensa/cpu-qom.h
similarity index 

[Qemu-devel] [PATCH 20/20] Makefile.target: Targets now have to reside in the target/ folder

2016-12-09 Thread Thomas Huth
Now that all target CPU folders have been moved to target/, we
do not need to support the old naming scheme of target-xxx
anymore.

Signed-off-by: Thomas Huth 
---
 Makefile.target | 4 
 1 file changed, 4 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 90b25ae..1da789c 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -7,11 +7,7 @@ include config-target.mak
 include config-devices.mak
 include $(SRC_PATH)/rules.mak
 
-ifneq ($(wildcard $(SRC_PATH)/target/$(TARGET_BASE_ARCH)),)
 TARGET_FOLDER=target/$(TARGET_BASE_ARCH)
-else
-TARGET_FOLDER=target-$(TARGET_BASE_ARCH)
-endif
 
 $(call set-vpath, $(SRC_PATH):$(BUILD_DIR))
 ifdef CONFIG_LINUX
-- 
1.8.3.1




[Qemu-devel] [PATCH 15/20] openrisc: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 2 +-
 {target-openrisc => target/openrisc}/Makefile.objs  | 0
 {target-openrisc => target/openrisc}/cpu.c  | 0
 {target-openrisc => target/openrisc}/cpu.h  | 0
 {target-openrisc => target/openrisc}/exception.c| 0
 {target-openrisc => target/openrisc}/exception.h| 0
 {target-openrisc => target/openrisc}/exception_helper.c | 0
 {target-openrisc => target/openrisc}/fpu_helper.c   | 0
 {target-openrisc => target/openrisc}/gdbstub.c  | 0
 {target-openrisc => target/openrisc}/helper.h   | 0
 {target-openrisc => target/openrisc}/int_helper.c   | 0
 {target-openrisc => target/openrisc}/interrupt.c| 0
 {target-openrisc => target/openrisc}/interrupt_helper.c | 0
 {target-openrisc => target/openrisc}/machine.c  | 0
 {target-openrisc => target/openrisc}/mmu.c  | 0
 {target-openrisc => target/openrisc}/mmu_helper.c   | 0
 {target-openrisc => target/openrisc}/sys_helper.c   | 0
 {target-openrisc => target/openrisc}/translate.c| 0
 18 files changed, 1 insertion(+), 1 deletion(-)
 rename {target-openrisc => target/openrisc}/Makefile.objs (100%)
 rename {target-openrisc => target/openrisc}/cpu.c (100%)
 rename {target-openrisc => target/openrisc}/cpu.h (100%)
 rename {target-openrisc => target/openrisc}/exception.c (100%)
 rename {target-openrisc => target/openrisc}/exception.h (100%)
 rename {target-openrisc => target/openrisc}/exception_helper.c (100%)
 rename {target-openrisc => target/openrisc}/fpu_helper.c (100%)
 rename {target-openrisc => target/openrisc}/gdbstub.c (100%)
 rename {target-openrisc => target/openrisc}/helper.h (100%)
 rename {target-openrisc => target/openrisc}/int_helper.c (100%)
 rename {target-openrisc => target/openrisc}/interrupt.c (100%)
 rename {target-openrisc => target/openrisc}/interrupt_helper.c (100%)
 rename {target-openrisc => target/openrisc}/machine.c (100%)
 rename {target-openrisc => target/openrisc}/mmu.c (100%)
 rename {target-openrisc => target/openrisc}/mmu_helper.c (100%)
 rename {target-openrisc => target/openrisc}/sys_helper.c (100%)
 rename {target-openrisc => target/openrisc}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index f172df9..d4d5605 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -184,7 +184,7 @@ F: default-configs/moxie-softmmu.mak
 OpenRISC
 M: Jia Liu 
 S: Maintained
-F: target-openrisc/
+F: target/openrisc/
 F: hw/openrisc/
 F: tests/tcg/openrisc/
 
diff --git a/target-openrisc/Makefile.objs b/target/openrisc/Makefile.objs
similarity index 100%
rename from target-openrisc/Makefile.objs
rename to target/openrisc/Makefile.objs
diff --git a/target-openrisc/cpu.c b/target/openrisc/cpu.c
similarity index 100%
rename from target-openrisc/cpu.c
rename to target/openrisc/cpu.c
diff --git a/target-openrisc/cpu.h b/target/openrisc/cpu.h
similarity index 100%
rename from target-openrisc/cpu.h
rename to target/openrisc/cpu.h
diff --git a/target-openrisc/exception.c b/target/openrisc/exception.c
similarity index 100%
rename from target-openrisc/exception.c
rename to target/openrisc/exception.c
diff --git a/target-openrisc/exception.h b/target/openrisc/exception.h
similarity index 100%
rename from target-openrisc/exception.h
rename to target/openrisc/exception.h
diff --git a/target-openrisc/exception_helper.c 
b/target/openrisc/exception_helper.c
similarity index 100%
rename from target-openrisc/exception_helper.c
rename to target/openrisc/exception_helper.c
diff --git a/target-openrisc/fpu_helper.c b/target/openrisc/fpu_helper.c
similarity index 100%
rename from target-openrisc/fpu_helper.c
rename to target/openrisc/fpu_helper.c
diff --git a/target-openrisc/gdbstub.c b/target/openrisc/gdbstub.c
similarity index 100%
rename from target-openrisc/gdbstub.c
rename to target/openrisc/gdbstub.c
diff --git a/target-openrisc/helper.h b/target/openrisc/helper.h
similarity index 100%
rename from target-openrisc/helper.h
rename to target/openrisc/helper.h
diff --git a/target-openrisc/int_helper.c b/target/openrisc/int_helper.c
similarity index 100%
rename from target-openrisc/int_helper.c
rename to target/openrisc/int_helper.c
diff --git a/target-openrisc/interrupt.c b/target/openrisc/interrupt.c
similarity index 100%
rename from target-openrisc/interrupt.c
rename to target/openrisc/interrupt.c
diff --git a/target-openrisc/interrupt_helper.c 
b/target/openrisc/interrupt_helper.c
similarity index 100%
rename from target-openrisc/interrupt_helper.c
rename to target/openrisc/interrupt_helper.c
diff --git a/target-openrisc/machine.c b/target/openrisc/machine.c
similarity index 100%
rename from target-openrisc/machine.c
rename to target/openrisc/machine.c
diff --git a/target-openrisc/mmu.c b/target/openrisc/mmu.c
similarity index 100%
rename from target-openrisc/mmu.c
rename to target/openrisc/mmu.c
diff --git a/target-openrisc/mmu_helper.c 

Re: [Qemu-devel] [PATCH 10/20] s390x: Move CPU files to target/ folder

2016-12-09 Thread Cornelia Huck
On Fri,  9 Dec 2016 13:17:40 +0100
Thomas Huth  wrote:

> Signed-off-by: Thomas Huth 
> ---
>  MAINTAINERS   | 8 
>  Makefile.objs | 2 +-
>  {target-s390x => target/s390x}/Makefile.objs  | 2 +-
>  {target-s390x => target/s390x}/arch_dump.c| 0
>  {target-s390x => target/s390x}/cc_helper.c| 0
>  {target-s390x => target/s390x}/cpu-qom.h  | 0
>  {target-s390x => target/s390x}/cpu.c  | 0
>  {target-s390x => target/s390x}/cpu.h  | 0
>  {target-s390x => target/s390x}/cpu_features.c | 0
>  {target-s390x => target/s390x}/cpu_features.h | 0
>  {target-s390x => target/s390x}/cpu_features_def.h | 0
>  {target-s390x => target/s390x}/cpu_models.c   | 0
>  {target-s390x => target/s390x}/cpu_models.h   | 0
>  {target-s390x => target/s390x}/fpu_helper.c   | 0
>  {target-s390x => target/s390x}/gdbstub.c  | 0
>  {target-s390x => target/s390x}/gen-features.c | 0
>  {target-s390x => target/s390x}/helper.c   | 0
>  {target-s390x => target/s390x}/helper.h   | 0
>  {target-s390x => target/s390x}/insn-data.def  | 0
>  {target-s390x => target/s390x}/insn-format.def| 0
>  {target-s390x => target/s390x}/int_helper.c   | 0
>  {target-s390x => target/s390x}/interrupt.c| 0
>  {target-s390x => target/s390x}/ioinst.c   | 0
>  {target-s390x => target/s390x}/kvm.c  | 0
>  {target-s390x => target/s390x}/machine.c  | 0
>  {target-s390x => target/s390x}/mem_helper.c   | 0
>  {target-s390x => target/s390x}/misc_helper.c  | 0
>  {target-s390x => target/s390x}/mmu_helper.c   | 0
>  {target-s390x => target/s390x}/trace-events   | 8 
>  {target-s390x => target/s390x}/translate.c| 0
>  30 files changed, 10 insertions(+), 10 deletions(-)
>  rename {target-s390x => target/s390x}/Makefile.objs (94%)
>  rename {target-s390x => target/s390x}/arch_dump.c (100%)
>  rename {target-s390x => target/s390x}/cc_helper.c (100%)
>  rename {target-s390x => target/s390x}/cpu-qom.h (100%)
>  rename {target-s390x => target/s390x}/cpu.c (100%)
>  rename {target-s390x => target/s390x}/cpu.h (100%)
>  rename {target-s390x => target/s390x}/cpu_features.c (100%)
>  rename {target-s390x => target/s390x}/cpu_features.h (100%)
>  rename {target-s390x => target/s390x}/cpu_features_def.h (100%)
>  rename {target-s390x => target/s390x}/cpu_models.c (100%)
>  rename {target-s390x => target/s390x}/cpu_models.h (100%)
>  rename {target-s390x => target/s390x}/fpu_helper.c (100%)
>  rename {target-s390x => target/s390x}/gdbstub.c (100%)
>  rename {target-s390x => target/s390x}/gen-features.c (100%)
>  rename {target-s390x => target/s390x}/helper.c (100%)
>  rename {target-s390x => target/s390x}/helper.h (100%)
>  rename {target-s390x => target/s390x}/insn-data.def (100%)
>  rename {target-s390x => target/s390x}/insn-format.def (100%)
>  rename {target-s390x => target/s390x}/int_helper.c (100%)
>  rename {target-s390x => target/s390x}/interrupt.c (100%)
>  rename {target-s390x => target/s390x}/ioinst.c (100%)
>  rename {target-s390x => target/s390x}/kvm.c (100%)
>  rename {target-s390x => target/s390x}/machine.c (100%)
>  rename {target-s390x => target/s390x}/mem_helper.c (100%)
>  rename {target-s390x => target/s390x}/misc_helper.c (100%)
>  rename {target-s390x => target/s390x}/mmu_helper.c (100%)
>  rename {target-s390x => target/s390x}/trace-events (91%)
>  rename {target-s390x => target/s390x}/translate.c (100%)

Acked-by: Cornelia Huck 




[Qemu-devel] [PATCH 13/20] lm32: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS| 2 +-
 {target-lm32 => target/lm32}/Makefile.objs | 0
 {target-lm32 => target/lm32}/README| 0
 {target-lm32 => target/lm32}/TODO  | 0
 {target-lm32 => target/lm32}/cpu-qom.h | 0
 {target-lm32 => target/lm32}/cpu.c | 0
 {target-lm32 => target/lm32}/cpu.h | 0
 {target-lm32 => target/lm32}/gdbstub.c | 0
 {target-lm32 => target/lm32}/helper.c  | 0
 {target-lm32 => target/lm32}/helper.h  | 0
 {target-lm32 => target/lm32}/lm32-semi.c   | 0
 {target-lm32 => target/lm32}/machine.c | 0
 {target-lm32 => target/lm32}/op_helper.c   | 0
 {target-lm32 => target/lm32}/translate.c   | 0
 14 files changed, 1 insertion(+), 1 deletion(-)
 rename {target-lm32 => target/lm32}/Makefile.objs (100%)
 rename {target-lm32 => target/lm32}/README (100%)
 rename {target-lm32 => target/lm32}/TODO (100%)
 rename {target-lm32 => target/lm32}/cpu-qom.h (100%)
 rename {target-lm32 => target/lm32}/cpu.c (100%)
 rename {target-lm32 => target/lm32}/cpu.h (100%)
 rename {target-lm32 => target/lm32}/gdbstub.c (100%)
 rename {target-lm32 => target/lm32}/helper.c (100%)
 rename {target-lm32 => target/lm32}/helper.h (100%)
 rename {target-lm32 => target/lm32}/lm32-semi.c (100%)
 rename {target-lm32 => target/lm32}/machine.c (100%)
 rename {target-lm32 => target/lm32}/op_helper.c (100%)
 rename {target-lm32 => target/lm32}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index ccb841f..0d6b5fe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -135,7 +135,7 @@ F: disas/cris.c
 LM32
 M: Michael Walle 
 S: Maintained
-F: target-lm32/
+F: target/lm32/
 F: disas/lm32.c
 F: hw/lm32/
 F: hw/*/lm32_*
diff --git a/target-lm32/Makefile.objs b/target/lm32/Makefile.objs
similarity index 100%
rename from target-lm32/Makefile.objs
rename to target/lm32/Makefile.objs
diff --git a/target-lm32/README b/target/lm32/README
similarity index 100%
rename from target-lm32/README
rename to target/lm32/README
diff --git a/target-lm32/TODO b/target/lm32/TODO
similarity index 100%
rename from target-lm32/TODO
rename to target/lm32/TODO
diff --git a/target-lm32/cpu-qom.h b/target/lm32/cpu-qom.h
similarity index 100%
rename from target-lm32/cpu-qom.h
rename to target/lm32/cpu-qom.h
diff --git a/target-lm32/cpu.c b/target/lm32/cpu.c
similarity index 100%
rename from target-lm32/cpu.c
rename to target/lm32/cpu.c
diff --git a/target-lm32/cpu.h b/target/lm32/cpu.h
similarity index 100%
rename from target-lm32/cpu.h
rename to target/lm32/cpu.h
diff --git a/target-lm32/gdbstub.c b/target/lm32/gdbstub.c
similarity index 100%
rename from target-lm32/gdbstub.c
rename to target/lm32/gdbstub.c
diff --git a/target-lm32/helper.c b/target/lm32/helper.c
similarity index 100%
rename from target-lm32/helper.c
rename to target/lm32/helper.c
diff --git a/target-lm32/helper.h b/target/lm32/helper.h
similarity index 100%
rename from target-lm32/helper.h
rename to target/lm32/helper.h
diff --git a/target-lm32/lm32-semi.c b/target/lm32/lm32-semi.c
similarity index 100%
rename from target-lm32/lm32-semi.c
rename to target/lm32/lm32-semi.c
diff --git a/target-lm32/machine.c b/target/lm32/machine.c
similarity index 100%
rename from target-lm32/machine.c
rename to target/lm32/machine.c
diff --git a/target-lm32/op_helper.c b/target/lm32/op_helper.c
similarity index 100%
rename from target-lm32/op_helper.c
rename to target/lm32/op_helper.c
diff --git a/target-lm32/translate.c b/target/lm32/translate.c
similarity index 100%
rename from target-lm32/translate.c
rename to target/lm32/translate.c
-- 
1.8.3.1




[Qemu-devel] [PATCH 10/20] s390x: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS   | 8 
 Makefile.objs | 2 +-
 {target-s390x => target/s390x}/Makefile.objs  | 2 +-
 {target-s390x => target/s390x}/arch_dump.c| 0
 {target-s390x => target/s390x}/cc_helper.c| 0
 {target-s390x => target/s390x}/cpu-qom.h  | 0
 {target-s390x => target/s390x}/cpu.c  | 0
 {target-s390x => target/s390x}/cpu.h  | 0
 {target-s390x => target/s390x}/cpu_features.c | 0
 {target-s390x => target/s390x}/cpu_features.h | 0
 {target-s390x => target/s390x}/cpu_features_def.h | 0
 {target-s390x => target/s390x}/cpu_models.c   | 0
 {target-s390x => target/s390x}/cpu_models.h   | 0
 {target-s390x => target/s390x}/fpu_helper.c   | 0
 {target-s390x => target/s390x}/gdbstub.c  | 0
 {target-s390x => target/s390x}/gen-features.c | 0
 {target-s390x => target/s390x}/helper.c   | 0
 {target-s390x => target/s390x}/helper.h   | 0
 {target-s390x => target/s390x}/insn-data.def  | 0
 {target-s390x => target/s390x}/insn-format.def| 0
 {target-s390x => target/s390x}/int_helper.c   | 0
 {target-s390x => target/s390x}/interrupt.c| 0
 {target-s390x => target/s390x}/ioinst.c   | 0
 {target-s390x => target/s390x}/kvm.c  | 0
 {target-s390x => target/s390x}/machine.c  | 0
 {target-s390x => target/s390x}/mem_helper.c   | 0
 {target-s390x => target/s390x}/misc_helper.c  | 0
 {target-s390x => target/s390x}/mmu_helper.c   | 0
 {target-s390x => target/s390x}/trace-events   | 8 
 {target-s390x => target/s390x}/translate.c| 0
 30 files changed, 10 insertions(+), 10 deletions(-)
 rename {target-s390x => target/s390x}/Makefile.objs (94%)
 rename {target-s390x => target/s390x}/arch_dump.c (100%)
 rename {target-s390x => target/s390x}/cc_helper.c (100%)
 rename {target-s390x => target/s390x}/cpu-qom.h (100%)
 rename {target-s390x => target/s390x}/cpu.c (100%)
 rename {target-s390x => target/s390x}/cpu.h (100%)
 rename {target-s390x => target/s390x}/cpu_features.c (100%)
 rename {target-s390x => target/s390x}/cpu_features.h (100%)
 rename {target-s390x => target/s390x}/cpu_features_def.h (100%)
 rename {target-s390x => target/s390x}/cpu_models.c (100%)
 rename {target-s390x => target/s390x}/cpu_models.h (100%)
 rename {target-s390x => target/s390x}/fpu_helper.c (100%)
 rename {target-s390x => target/s390x}/gdbstub.c (100%)
 rename {target-s390x => target/s390x}/gen-features.c (100%)
 rename {target-s390x => target/s390x}/helper.c (100%)
 rename {target-s390x => target/s390x}/helper.h (100%)
 rename {target-s390x => target/s390x}/insn-data.def (100%)
 rename {target-s390x => target/s390x}/insn-format.def (100%)
 rename {target-s390x => target/s390x}/int_helper.c (100%)
 rename {target-s390x => target/s390x}/interrupt.c (100%)
 rename {target-s390x => target/s390x}/ioinst.c (100%)
 rename {target-s390x => target/s390x}/kvm.c (100%)
 rename {target-s390x => target/s390x}/machine.c (100%)
 rename {target-s390x => target/s390x}/mem_helper.c (100%)
 rename {target-s390x => target/s390x}/misc_helper.c (100%)
 rename {target-s390x => target/s390x}/mmu_helper.c (100%)
 rename {target-s390x => target/s390x}/trace-events (91%)
 rename {target-s390x => target/s390x}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index fb6c3a6..48b0a7b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -202,7 +202,7 @@ S390
 M: Richard Henderson 
 M: Alexander Graf 
 S: Maintained
-F: target-s390x/
+F: target/s390x/
 F: hw/s390x/
 F: disas/s390.c
 
@@ -286,9 +286,9 @@ M: Christian Borntraeger 
 M: Cornelia Huck 
 M: Alexander Graf 
 S: Maintained
-F: target-s390x/kvm.c
-F: target-s390x/ioinst.[ch]
-F: target-s390x/machine.c
+F: target/s390x/kvm.c
+F: target/s390x/ioinst.[ch]
+F: target/s390x/machine.c
 F: hw/intc/s390_flic.c
 F: hw/intc/s390_flic_kvm.c
 F: include/hw/s390x/s390_flic.h
diff --git a/Makefile.objs b/Makefile.objs
index 91a24c5..c5ebb80 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -158,7 +158,7 @@ trace-events-y += net/trace-events
 trace-events-y += target/arm/trace-events
 trace-events-y += target/i386/trace-events
 trace-events-y += target-sparc/trace-events
-trace-events-y += target-s390x/trace-events
+trace-events-y += target/s390x/trace-events
 trace-events-y += target/ppc/trace-events
 trace-events-y += qom/trace-events
 trace-events-y += linux-user/trace-events
diff --git a/target-s390x/Makefile.objs b/target/s390x/Makefile.objs
similarity index 94%
rename from target-s390x/Makefile.objs
rename to target/s390x/Makefile.objs
index 6b02b17..c573633 100644
--- a/target-s390x/Makefile.objs
+++ b/target/s390x/Makefile.objs
@@ -5,7 +5,7 @@ obj-$(CONFIG_SOFTMMU) += machine.o ioinst.o arch_dump.o 
mmu_helper.o
 obj-$(CONFIG_KVM) += kvm.o
 
 # build 

Re: [Qemu-devel] [PATCH 10/20] s390x: Move CPU files to target/ folder

2016-12-09 Thread Christian Borntraeger
On 12/09/2016 01:17 PM, Thomas Huth wrote:
> Signed-off-by: Thomas Huth 

grep does not seem to find any other place.

Reviewed-by: Christian Borntraeger 

> ---
>  MAINTAINERS   | 8 
>  Makefile.objs | 2 +-
>  {target-s390x => target/s390x}/Makefile.objs  | 2 +-
>  {target-s390x => target/s390x}/arch_dump.c| 0
>  {target-s390x => target/s390x}/cc_helper.c| 0
>  {target-s390x => target/s390x}/cpu-qom.h  | 0
>  {target-s390x => target/s390x}/cpu.c  | 0
>  {target-s390x => target/s390x}/cpu.h  | 0
>  {target-s390x => target/s390x}/cpu_features.c | 0
>  {target-s390x => target/s390x}/cpu_features.h | 0
>  {target-s390x => target/s390x}/cpu_features_def.h | 0
>  {target-s390x => target/s390x}/cpu_models.c   | 0
>  {target-s390x => target/s390x}/cpu_models.h   | 0
>  {target-s390x => target/s390x}/fpu_helper.c   | 0
>  {target-s390x => target/s390x}/gdbstub.c  | 0
>  {target-s390x => target/s390x}/gen-features.c | 0
>  {target-s390x => target/s390x}/helper.c   | 0
>  {target-s390x => target/s390x}/helper.h   | 0
>  {target-s390x => target/s390x}/insn-data.def  | 0
>  {target-s390x => target/s390x}/insn-format.def| 0
>  {target-s390x => target/s390x}/int_helper.c   | 0
>  {target-s390x => target/s390x}/interrupt.c| 0
>  {target-s390x => target/s390x}/ioinst.c   | 0
>  {target-s390x => target/s390x}/kvm.c  | 0
>  {target-s390x => target/s390x}/machine.c  | 0
>  {target-s390x => target/s390x}/mem_helper.c   | 0
>  {target-s390x => target/s390x}/misc_helper.c  | 0
>  {target-s390x => target/s390x}/mmu_helper.c   | 0
>  {target-s390x => target/s390x}/trace-events   | 8 
>  {target-s390x => target/s390x}/translate.c| 0
>  30 files changed, 10 insertions(+), 10 deletions(-)
>  rename {target-s390x => target/s390x}/Makefile.objs (94%)
>  rename {target-s390x => target/s390x}/arch_dump.c (100%)
>  rename {target-s390x => target/s390x}/cc_helper.c (100%)
>  rename {target-s390x => target/s390x}/cpu-qom.h (100%)
>  rename {target-s390x => target/s390x}/cpu.c (100%)
>  rename {target-s390x => target/s390x}/cpu.h (100%)
>  rename {target-s390x => target/s390x}/cpu_features.c (100%)
>  rename {target-s390x => target/s390x}/cpu_features.h (100%)
>  rename {target-s390x => target/s390x}/cpu_features_def.h (100%)
>  rename {target-s390x => target/s390x}/cpu_models.c (100%)
>  rename {target-s390x => target/s390x}/cpu_models.h (100%)
>  rename {target-s390x => target/s390x}/fpu_helper.c (100%)
>  rename {target-s390x => target/s390x}/gdbstub.c (100%)
>  rename {target-s390x => target/s390x}/gen-features.c (100%)
>  rename {target-s390x => target/s390x}/helper.c (100%)
>  rename {target-s390x => target/s390x}/helper.h (100%)
>  rename {target-s390x => target/s390x}/insn-data.def (100%)
>  rename {target-s390x => target/s390x}/insn-format.def (100%)
>  rename {target-s390x => target/s390x}/int_helper.c (100%)
>  rename {target-s390x => target/s390x}/interrupt.c (100%)
>  rename {target-s390x => target/s390x}/ioinst.c (100%)
>  rename {target-s390x => target/s390x}/kvm.c (100%)
>  rename {target-s390x => target/s390x}/machine.c (100%)
>  rename {target-s390x => target/s390x}/mem_helper.c (100%)
>  rename {target-s390x => target/s390x}/misc_helper.c (100%)
>  rename {target-s390x => target/s390x}/mmu_helper.c (100%)
>  rename {target-s390x => target/s390x}/trace-events (91%)
>  rename {target-s390x => target/s390x}/translate.c (100%)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index fb6c3a6..48b0a7b 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -202,7 +202,7 @@ S390
>  M: Richard Henderson 
>  M: Alexander Graf 
>  S: Maintained
> -F: target-s390x/
> +F: target/s390x/
>  F: hw/s390x/
>  F: disas/s390.c
> 
> @@ -286,9 +286,9 @@ M: Christian Borntraeger 
>  M: Cornelia Huck 
>  M: Alexander Graf 
>  S: Maintained
> -F: target-s390x/kvm.c
> -F: target-s390x/ioinst.[ch]
> -F: target-s390x/machine.c
> +F: target/s390x/kvm.c
> +F: target/s390x/ioinst.[ch]
> +F: target/s390x/machine.c
>  F: hw/intc/s390_flic.c
>  F: hw/intc/s390_flic_kvm.c
>  F: include/hw/s390x/s390_flic.h
> diff --git a/Makefile.objs b/Makefile.objs
> index 91a24c5..c5ebb80 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -158,7 +158,7 @@ trace-events-y += net/trace-events
>  trace-events-y += target/arm/trace-events
>  trace-events-y += target/i386/trace-events
>  trace-events-y += target-sparc/trace-events
> -trace-events-y += target-s390x/trace-events
> +trace-events-y += target/s390x/trace-events
>  trace-events-y += target/ppc/trace-events
>  trace-events-y += qom/trace-events
>  trace-events-y += linux-user/trace-events
> diff --git 

[Qemu-devel] [PATCH 09/20] mips: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS   | 4 ++--
 include/hw/mips/cpudevs.h | 2 +-
 {target-mips => target/mips}/Makefile.objs| 0
 {target-mips => target/mips}/TODO | 0
 {target-mips => target/mips}/cpu-qom.h| 0
 {target-mips => target/mips}/cpu.c| 0
 {target-mips => target/mips}/cpu.h| 0
 {target-mips => target/mips}/dsp_helper.c | 0
 {target-mips => target/mips}/gdbstub.c| 0
 {target-mips => target/mips}/helper.c | 0
 {target-mips => target/mips}/helper.h | 0
 {target-mips => target/mips}/kvm.c| 0
 {target-mips => target/mips}/kvm_mips.h   | 0
 {target-mips => target/mips}/lmi_helper.c | 0
 {target-mips => target/mips}/machine.c| 0
 {target-mips => target/mips}/mips-defs.h  | 0
 {target-mips => target/mips}/mips-semi.c  | 0
 {target-mips => target/mips}/msa_helper.c | 0
 {target-mips => target/mips}/op_helper.c  | 0
 {target-mips => target/mips}/translate.c  | 0
 {target-mips => target/mips}/translate_init.c | 0
 21 files changed, 3 insertions(+), 3 deletions(-)
 rename {target-mips => target/mips}/Makefile.objs (100%)
 rename {target-mips => target/mips}/TODO (100%)
 rename {target-mips => target/mips}/cpu-qom.h (100%)
 rename {target-mips => target/mips}/cpu.c (100%)
 rename {target-mips => target/mips}/cpu.h (100%)
 rename {target-mips => target/mips}/dsp_helper.c (100%)
 rename {target-mips => target/mips}/gdbstub.c (100%)
 rename {target-mips => target/mips}/helper.c (100%)
 rename {target-mips => target/mips}/helper.h (100%)
 rename {target-mips => target/mips}/kvm.c (100%)
 rename {target-mips => target/mips}/kvm_mips.h (100%)
 rename {target-mips => target/mips}/lmi_helper.c (100%)
 rename {target-mips => target/mips}/machine.c (100%)
 rename {target-mips => target/mips}/mips-defs.h (100%)
 rename {target-mips => target/mips}/mips-semi.c (100%)
 rename {target-mips => target/mips}/msa_helper.c (100%)
 rename {target-mips => target/mips}/op_helper.c (100%)
 rename {target-mips => target/mips}/translate.c (100%)
 rename {target-mips => target/mips}/translate_init.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index c7b1a3f..fb6c3a6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -161,7 +161,7 @@ MIPS
 M: Aurelien Jarno 
 M: Yongbok Kim 
 S: Maintained
-F: target-mips/
+F: target/mips/
 F: hw/mips/
 F: hw/misc/mips_*
 F: hw/intc/mips_gic.c
@@ -274,7 +274,7 @@ F: target/arm/kvm.c
 MIPS
 M: James Hogan 
 S: Maintained
-F: target-mips/kvm.c
+F: target/mips/kvm.c
 
 PPC
 M: Alexander Graf 
diff --git a/include/hw/mips/cpudevs.h b/include/hw/mips/cpudevs.h
index 8673daa..31f5319 100644
--- a/include/hw/mips/cpudevs.h
+++ b/include/hw/mips/cpudevs.h
@@ -1,7 +1,7 @@
 #ifndef HW_MIPS_CPUDEVS_H
 #define HW_MIPS_CPUDEVS_H
 
-#include "target-mips/cpu-qom.h"
+#include "cpu-qom.h"
 
 /* Definitions for MIPS CPU internal devices.  */
 
diff --git a/target-mips/Makefile.objs b/target/mips/Makefile.objs
similarity index 100%
rename from target-mips/Makefile.objs
rename to target/mips/Makefile.objs
diff --git a/target-mips/TODO b/target/mips/TODO
similarity index 100%
rename from target-mips/TODO
rename to target/mips/TODO
diff --git a/target-mips/cpu-qom.h b/target/mips/cpu-qom.h
similarity index 100%
rename from target-mips/cpu-qom.h
rename to target/mips/cpu-qom.h
diff --git a/target-mips/cpu.c b/target/mips/cpu.c
similarity index 100%
rename from target-mips/cpu.c
rename to target/mips/cpu.c
diff --git a/target-mips/cpu.h b/target/mips/cpu.h
similarity index 100%
rename from target-mips/cpu.h
rename to target/mips/cpu.h
diff --git a/target-mips/dsp_helper.c b/target/mips/dsp_helper.c
similarity index 100%
rename from target-mips/dsp_helper.c
rename to target/mips/dsp_helper.c
diff --git a/target-mips/gdbstub.c b/target/mips/gdbstub.c
similarity index 100%
rename from target-mips/gdbstub.c
rename to target/mips/gdbstub.c
diff --git a/target-mips/helper.c b/target/mips/helper.c
similarity index 100%
rename from target-mips/helper.c
rename to target/mips/helper.c
diff --git a/target-mips/helper.h b/target/mips/helper.h
similarity index 100%
rename from target-mips/helper.h
rename to target/mips/helper.h
diff --git a/target-mips/kvm.c b/target/mips/kvm.c
similarity index 100%
rename from target-mips/kvm.c
rename to target/mips/kvm.c
diff --git a/target-mips/kvm_mips.h b/target/mips/kvm_mips.h
similarity index 100%
rename from target-mips/kvm_mips.h
rename to target/mips/kvm_mips.h
diff --git a/target-mips/lmi_helper.c b/target/mips/lmi_helper.c
similarity index 100%
rename from target-mips/lmi_helper.c
rename to target/mips/lmi_helper.c
diff --git a/target-mips/machine.c b/target/mips/machine.c
similarity index 100%
rename from target-mips/machine.c
rename to target/mips/machine.c
diff --git a/target-mips/mips-defs.h 

Re: [Qemu-devel] [PATCH 13/20] lm32: Move CPU files to target/ folder

2016-12-09 Thread Michael Walle

Am 2016-12-09 13:17, schrieb Thomas Huth:

Signed-off-by: Thomas Huth 
---
 MAINTAINERS| 2 +-
 {target-lm32 => target/lm32}/Makefile.objs | 0
 {target-lm32 => target/lm32}/README| 0
 {target-lm32 => target/lm32}/TODO  | 0
 {target-lm32 => target/lm32}/cpu-qom.h | 0
 {target-lm32 => target/lm32}/cpu.c | 0
 {target-lm32 => target/lm32}/cpu.h | 0
 {target-lm32 => target/lm32}/gdbstub.c | 0
 {target-lm32 => target/lm32}/helper.c  | 0
 {target-lm32 => target/lm32}/helper.h  | 0
 {target-lm32 => target/lm32}/lm32-semi.c   | 0
 {target-lm32 => target/lm32}/machine.c | 0
 {target-lm32 => target/lm32}/op_helper.c   | 0
 {target-lm32 => target/lm32}/translate.c   | 0
 14 files changed, 1 insertion(+), 1 deletion(-)
 rename {target-lm32 => target/lm32}/Makefile.objs (100%)
 rename {target-lm32 => target/lm32}/README (100%)
 rename {target-lm32 => target/lm32}/TODO (100%)
 rename {target-lm32 => target/lm32}/cpu-qom.h (100%)
 rename {target-lm32 => target/lm32}/cpu.c (100%)
 rename {target-lm32 => target/lm32}/cpu.h (100%)
 rename {target-lm32 => target/lm32}/gdbstub.c (100%)
 rename {target-lm32 => target/lm32}/helper.c (100%)
 rename {target-lm32 => target/lm32}/helper.h (100%)
 rename {target-lm32 => target/lm32}/lm32-semi.c (100%)
 rename {target-lm32 => target/lm32}/machine.c (100%)
 rename {target-lm32 => target/lm32}/op_helper.c (100%)
 rename {target-lm32 => target/lm32}/translate.c (100%)


Acked-by: Michael Walle 



[Qemu-devel] [PATCH 05/20] arm: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS| 4 ++--
 Makefile.objs  | 2 +-
 hw/arm/strongarm.h | 2 +-
 hw/arm/virt-acpi-build.c   | 2 +-
 include/hw/arm/arm.h   | 2 +-
 include/hw/arm/exynos4210.h| 2 +-
 include/hw/arm/omap.h  | 2 +-
 include/hw/arm/pxa.h   | 2 +-
 {target-arm => target/arm}/Makefile.objs   | 0
 {target-arm => target/arm}/arch_dump.c | 0
 {target-arm => target/arm}/arm-powerctl.c  | 0
 {target-arm => target/arm}/arm-powerctl.h  | 0
 {target-arm => target/arm}/arm-semi.c  | 0
 {target-arm => target/arm}/arm_ldst.h  | 0
 {target-arm => target/arm}/cpu-qom.h   | 0
 {target-arm => target/arm}/cpu.c   | 0
 {target-arm => target/arm}/cpu.h   | 0
 {target-arm => target/arm}/cpu64.c | 0
 {target-arm => target/arm}/crypto_helper.c | 0
 {target-arm => target/arm}/gdbstub.c   | 0
 {target-arm => target/arm}/gdbstub64.c | 0
 {target-arm => target/arm}/helper-a64.c| 0
 {target-arm => target/arm}/helper-a64.h| 0
 {target-arm => target/arm}/helper.c| 0
 {target-arm => target/arm}/helper.h| 0
 {target-arm => target/arm}/internals.h | 0
 {target-arm => target/arm}/iwmmxt_helper.c | 0
 {target-arm => target/arm}/kvm-consts.h| 0
 {target-arm => target/arm}/kvm-stub.c  | 0
 {target-arm => target/arm}/kvm.c   | 0
 {target-arm => target/arm}/kvm32.c | 0
 {target-arm => target/arm}/kvm64.c | 0
 {target-arm => target/arm}/kvm_arm.h   | 0
 {target-arm => target/arm}/machine.c   | 0
 {target-arm => target/arm}/monitor.c   | 0
 {target-arm => target/arm}/neon_helper.c   | 0
 {target-arm => target/arm}/op_addsub.h | 0
 {target-arm => target/arm}/op_helper.c | 0
 {target-arm => target/arm}/psci.c  | 0
 {target-arm => target/arm}/trace-events| 2 +-
 {target-arm => target/arm}/translate-a64.c | 0
 {target-arm => target/arm}/translate.c | 0
 {target-arm => target/arm}/translate.h | 0
 43 files changed, 10 insertions(+), 10 deletions(-)
 rename {target-arm => target/arm}/Makefile.objs (100%)
 rename {target-arm => target/arm}/arch_dump.c (100%)
 rename {target-arm => target/arm}/arm-powerctl.c (100%)
 rename {target-arm => target/arm}/arm-powerctl.h (100%)
 rename {target-arm => target/arm}/arm-semi.c (100%)
 rename {target-arm => target/arm}/arm_ldst.h (100%)
 rename {target-arm => target/arm}/cpu-qom.h (100%)
 rename {target-arm => target/arm}/cpu.c (100%)
 rename {target-arm => target/arm}/cpu.h (100%)
 rename {target-arm => target/arm}/cpu64.c (100%)
 rename {target-arm => target/arm}/crypto_helper.c (100%)
 rename {target-arm => target/arm}/gdbstub.c (100%)
 rename {target-arm => target/arm}/gdbstub64.c (100%)
 rename {target-arm => target/arm}/helper-a64.c (100%)
 rename {target-arm => target/arm}/helper-a64.h (100%)
 rename {target-arm => target/arm}/helper.c (100%)
 rename {target-arm => target/arm}/helper.h (100%)
 rename {target-arm => target/arm}/internals.h (100%)
 rename {target-arm => target/arm}/iwmmxt_helper.c (100%)
 rename {target-arm => target/arm}/kvm-consts.h (100%)
 rename {target-arm => target/arm}/kvm-stub.c (100%)
 rename {target-arm => target/arm}/kvm.c (100%)
 rename {target-arm => target/arm}/kvm32.c (100%)
 rename {target-arm => target/arm}/kvm64.c (100%)
 rename {target-arm => target/arm}/kvm_arm.h (100%)
 rename {target-arm => target/arm}/machine.c (100%)
 rename {target-arm => target/arm}/monitor.c (100%)
 rename {target-arm => target/arm}/neon_helper.c (100%)
 rename {target-arm => target/arm}/op_addsub.h (100%)
 rename {target-arm => target/arm}/op_helper.c (100%)
 rename {target-arm => target/arm}/psci.c (100%)
 rename {target-arm => target/arm}/trace-events (96%)
 rename {target-arm => target/arm}/translate-a64.c (100%)
 rename {target-arm => target/arm}/translate.c (100%)
 rename {target-arm => target/arm}/translate.h (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 37deb43..2760146 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -115,7 +115,7 @@ ARM
 M: Peter Maydell 
 L: qemu-...@nongnu.org
 S: Maintained
-F: target-arm/
+F: target/arm/
 F: hw/arm/
 F: hw/cpu/a*mpcore.c
 F: include/hw/cpu/a*mpcore.h
@@ -269,7 +269,7 @@ ARM
 M: Peter Maydell 
 L: qemu-...@nongnu.org
 S: Maintained
-F: target-arm/kvm.c
+F: target/arm/kvm.c
 
 MIPS
 M: James Hogan 
diff --git a/Makefile.objs b/Makefile.objs
index 06f74b8..6d2b36e 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -155,7 +155,7 @@ trace-events-y += hw/alpha/trace-events
 trace-events-y += ui/trace-events
 trace-events-y += audio/trace-events
 trace-events-y += net/trace-events
-trace-events-y += target-arm/trace-events
+trace-events-y += target/arm/trace-events
 trace-events-y += target-i386/trace-events
 trace-events-y += 

Re: [Qemu-devel] [PATCH 17/20] tricore: Move CPU files to target/ folder

2016-12-09 Thread Bastian Koppelmann
On 12/09/2016 01:17 PM, Thomas Huth wrote:
> Signed-off-by: Thomas Huth 
> ---
>  MAINTAINERS  | 2 +-
>  {target-tricore => target/tricore}/Makefile.objs | 0
>  {target-tricore => target/tricore}/cpu-qom.h | 0
>  {target-tricore => target/tricore}/cpu.c | 0
>  {target-tricore => target/tricore}/cpu.h | 0
>  {target-tricore => target/tricore}/csfr.def  | 0
>  {target-tricore => target/tricore}/fpu_helper.c  | 0
>  {target-tricore => target/tricore}/helper.c  | 0
>  {target-tricore => target/tricore}/helper.h  | 0
>  {target-tricore => target/tricore}/op_helper.c   | 0
>  {target-tricore => target/tricore}/translate.c   | 0
>  {target-tricore => target/tricore}/tricore-defs.h| 0
>  {target-tricore => target/tricore}/tricore-opcodes.h | 0
>  13 files changed, 1 insertion(+), 1 deletion(-)
>  rename {target-tricore => target/tricore}/Makefile.objs (100%)
>  rename {target-tricore => target/tricore}/cpu-qom.h (100%)
>  rename {target-tricore => target/tricore}/cpu.c (100%)
>  rename {target-tricore => target/tricore}/cpu.h (100%)
>  rename {target-tricore => target/tricore}/csfr.def (100%)
>  rename {target-tricore => target/tricore}/fpu_helper.c (100%)
>  rename {target-tricore => target/tricore}/helper.c (100%)
>  rename {target-tricore => target/tricore}/helper.h (100%)
>  rename {target-tricore => target/tricore}/op_helper.c (100%)
>  rename {target-tricore => target/tricore}/translate.c (100%)
>  rename {target-tricore => target/tricore}/tricore-defs.h (100%)
>  rename {target-tricore => target/tricore}/tricore-opcodes.h (100%)
> 

Acked-by: Bastian Koppelmann 

Cheers,
Bastian




[Qemu-devel] [PATCH 08/20] microblaze: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS  | 2 +-
 {target-microblaze => target/microblaze}/Makefile.objs   | 0
 {target-microblaze => target/microblaze}/cpu-qom.h   | 0
 {target-microblaze => target/microblaze}/cpu.c   | 0
 {target-microblaze => target/microblaze}/cpu.h   | 0
 {target-microblaze => target/microblaze}/gdbstub.c   | 0
 {target-microblaze => target/microblaze}/helper.c| 0
 {target-microblaze => target/microblaze}/helper.h| 0
 {target-microblaze => target/microblaze}/microblaze-decode.h | 0
 {target-microblaze => target/microblaze}/mmu.c   | 0
 {target-microblaze => target/microblaze}/mmu.h   | 0
 {target-microblaze => target/microblaze}/op_helper.c | 0
 {target-microblaze => target/microblaze}/translate.c | 0
 13 files changed, 1 insertion(+), 1 deletion(-)
 rename {target-microblaze => target/microblaze}/Makefile.objs (100%)
 rename {target-microblaze => target/microblaze}/cpu-qom.h (100%)
 rename {target-microblaze => target/microblaze}/cpu.c (100%)
 rename {target-microblaze => target/microblaze}/cpu.h (100%)
 rename {target-microblaze => target/microblaze}/gdbstub.c (100%)
 rename {target-microblaze => target/microblaze}/helper.c (100%)
 rename {target-microblaze => target/microblaze}/helper.h (100%)
 rename {target-microblaze => target/microblaze}/microblaze-decode.h (100%)
 rename {target-microblaze => target/microblaze}/mmu.c (100%)
 rename {target-microblaze => target/microblaze}/mmu.h (100%)
 rename {target-microblaze => target/microblaze}/op_helper.c (100%)
 rename {target-microblaze => target/microblaze}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 1b064ac..c7b1a3f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -153,7 +153,7 @@ F: disas/m68k.c
 MicroBlaze
 M: Edgar E. Iglesias 
 S: Maintained
-F: target-microblaze/
+F: target/microblaze/
 F: hw/microblaze/
 F: disas/microblaze.c
 
diff --git a/target-microblaze/Makefile.objs b/target/microblaze/Makefile.objs
similarity index 100%
rename from target-microblaze/Makefile.objs
rename to target/microblaze/Makefile.objs
diff --git a/target-microblaze/cpu-qom.h b/target/microblaze/cpu-qom.h
similarity index 100%
rename from target-microblaze/cpu-qom.h
rename to target/microblaze/cpu-qom.h
diff --git a/target-microblaze/cpu.c b/target/microblaze/cpu.c
similarity index 100%
rename from target-microblaze/cpu.c
rename to target/microblaze/cpu.c
diff --git a/target-microblaze/cpu.h b/target/microblaze/cpu.h
similarity index 100%
rename from target-microblaze/cpu.h
rename to target/microblaze/cpu.h
diff --git a/target-microblaze/gdbstub.c b/target/microblaze/gdbstub.c
similarity index 100%
rename from target-microblaze/gdbstub.c
rename to target/microblaze/gdbstub.c
diff --git a/target-microblaze/helper.c b/target/microblaze/helper.c
similarity index 100%
rename from target-microblaze/helper.c
rename to target/microblaze/helper.c
diff --git a/target-microblaze/helper.h b/target/microblaze/helper.h
similarity index 100%
rename from target-microblaze/helper.h
rename to target/microblaze/helper.h
diff --git a/target-microblaze/microblaze-decode.h 
b/target/microblaze/microblaze-decode.h
similarity index 100%
rename from target-microblaze/microblaze-decode.h
rename to target/microblaze/microblaze-decode.h
diff --git a/target-microblaze/mmu.c b/target/microblaze/mmu.c
similarity index 100%
rename from target-microblaze/mmu.c
rename to target/microblaze/mmu.c
diff --git a/target-microblaze/mmu.h b/target/microblaze/mmu.h
similarity index 100%
rename from target-microblaze/mmu.h
rename to target/microblaze/mmu.h
diff --git a/target-microblaze/op_helper.c b/target/microblaze/op_helper.c
similarity index 100%
rename from target-microblaze/op_helper.c
rename to target/microblaze/op_helper.c
diff --git a/target-microblaze/translate.c b/target/microblaze/translate.c
similarity index 100%
rename from target-microblaze/translate.c
rename to target/microblaze/translate.c
-- 
1.8.3.1




[Qemu-devel] [PATCH 17/20] tricore: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS  | 2 +-
 {target-tricore => target/tricore}/Makefile.objs | 0
 {target-tricore => target/tricore}/cpu-qom.h | 0
 {target-tricore => target/tricore}/cpu.c | 0
 {target-tricore => target/tricore}/cpu.h | 0
 {target-tricore => target/tricore}/csfr.def  | 0
 {target-tricore => target/tricore}/fpu_helper.c  | 0
 {target-tricore => target/tricore}/helper.c  | 0
 {target-tricore => target/tricore}/helper.h  | 0
 {target-tricore => target/tricore}/op_helper.c   | 0
 {target-tricore => target/tricore}/translate.c   | 0
 {target-tricore => target/tricore}/tricore-defs.h| 0
 {target-tricore => target/tricore}/tricore-opcodes.h | 0
 13 files changed, 1 insertion(+), 1 deletion(-)
 rename {target-tricore => target/tricore}/Makefile.objs (100%)
 rename {target-tricore => target/tricore}/cpu-qom.h (100%)
 rename {target-tricore => target/tricore}/cpu.c (100%)
 rename {target-tricore => target/tricore}/cpu.h (100%)
 rename {target-tricore => target/tricore}/csfr.def (100%)
 rename {target-tricore => target/tricore}/fpu_helper.c (100%)
 rename {target-tricore => target/tricore}/helper.c (100%)
 rename {target-tricore => target/tricore}/helper.h (100%)
 rename {target-tricore => target/tricore}/op_helper.c (100%)
 rename {target-tricore => target/tricore}/translate.c (100%)
 rename {target-tricore => target/tricore}/tricore-defs.h (100%)
 rename {target-tricore => target/tricore}/tricore-opcodes.h (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 31597bc..7733ccc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -250,7 +250,7 @@ F: tests/tcg/xtensa/
 TriCore
 M: Bastian Koppelmann 
 S: Maintained
-F: target-tricore/
+F: target/tricore/
 F: hw/tricore/
 F: include/hw/tricore/
 
diff --git a/target-tricore/Makefile.objs b/target/tricore/Makefile.objs
similarity index 100%
rename from target-tricore/Makefile.objs
rename to target/tricore/Makefile.objs
diff --git a/target-tricore/cpu-qom.h b/target/tricore/cpu-qom.h
similarity index 100%
rename from target-tricore/cpu-qom.h
rename to target/tricore/cpu-qom.h
diff --git a/target-tricore/cpu.c b/target/tricore/cpu.c
similarity index 100%
rename from target-tricore/cpu.c
rename to target/tricore/cpu.c
diff --git a/target-tricore/cpu.h b/target/tricore/cpu.h
similarity index 100%
rename from target-tricore/cpu.h
rename to target/tricore/cpu.h
diff --git a/target-tricore/csfr.def b/target/tricore/csfr.def
similarity index 100%
rename from target-tricore/csfr.def
rename to target/tricore/csfr.def
diff --git a/target-tricore/fpu_helper.c b/target/tricore/fpu_helper.c
similarity index 100%
rename from target-tricore/fpu_helper.c
rename to target/tricore/fpu_helper.c
diff --git a/target-tricore/helper.c b/target/tricore/helper.c
similarity index 100%
rename from target-tricore/helper.c
rename to target/tricore/helper.c
diff --git a/target-tricore/helper.h b/target/tricore/helper.h
similarity index 100%
rename from target-tricore/helper.h
rename to target/tricore/helper.h
diff --git a/target-tricore/op_helper.c b/target/tricore/op_helper.c
similarity index 100%
rename from target-tricore/op_helper.c
rename to target/tricore/op_helper.c
diff --git a/target-tricore/translate.c b/target/tricore/translate.c
similarity index 100%
rename from target-tricore/translate.c
rename to target/tricore/translate.c
diff --git a/target-tricore/tricore-defs.h b/target/tricore/tricore-defs.h
similarity index 100%
rename from target-tricore/tricore-defs.h
rename to target/tricore/tricore-defs.h
diff --git a/target-tricore/tricore-opcodes.h b/target/tricore/tricore-opcodes.h
similarity index 100%
rename from target-tricore/tricore-opcodes.h
rename to target/tricore/tricore-opcodes.h
-- 
1.8.3.1




[Qemu-devel] [PATCH 03/20] m68k: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS| 2 +-
 include/hw/m68k/mcf.h  | 2 +-
 {target-m68k => target/m68k}/Makefile.objs | 0
 {target-m68k => target/m68k}/cpu-qom.h | 0
 {target-m68k => target/m68k}/cpu.c | 0
 {target-m68k => target/m68k}/cpu.h | 0
 {target-m68k => target/m68k}/gdbstub.c | 0
 {target-m68k => target/m68k}/helper.c  | 0
 {target-m68k => target/m68k}/helper.h  | 0
 {target-m68k => target/m68k}/m68k-semi.c   | 0
 {target-m68k => target/m68k}/op_helper.c   | 0
 {target-m68k => target/m68k}/qregs.def | 0
 {target-m68k => target/m68k}/translate.c   | 0
 13 files changed, 2 insertions(+), 2 deletions(-)
 rename {target-m68k => target/m68k}/Makefile.objs (100%)
 rename {target-m68k => target/m68k}/cpu-qom.h (100%)
 rename {target-m68k => target/m68k}/cpu.c (100%)
 rename {target-m68k => target/m68k}/cpu.h (100%)
 rename {target-m68k => target/m68k}/gdbstub.c (100%)
 rename {target-m68k => target/m68k}/helper.c (100%)
 rename {target-m68k => target/m68k}/helper.h (100%)
 rename {target-m68k => target/m68k}/m68k-semi.c (100%)
 rename {target-m68k => target/m68k}/op_helper.c (100%)
 rename {target-m68k => target/m68k}/qregs.def (100%)
 rename {target-m68k => target/m68k}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4a60579..ce1ee35 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -147,7 +147,7 @@ F: tests/tcg/lm32/
 M68K
 M: Laurent Vivier 
 S: Maintained
-F: target-m68k/
+F: target/m68k/
 F: disas/m68k.c
 
 MicroBlaze
diff --git a/include/hw/m68k/mcf.h b/include/hw/m68k/mcf.h
index 0f0d228..ef8963d 100644
--- a/include/hw/m68k/mcf.h
+++ b/include/hw/m68k/mcf.h
@@ -2,7 +2,7 @@
 #define HW_MCF_H
 /* Motorola ColdFire device prototypes.  */
 
-#include "target-m68k/cpu-qom.h"
+#include "cpu-qom.h"
 
 struct MemoryRegion;
 
diff --git a/target-m68k/Makefile.objs b/target/m68k/Makefile.objs
similarity index 100%
rename from target-m68k/Makefile.objs
rename to target/m68k/Makefile.objs
diff --git a/target-m68k/cpu-qom.h b/target/m68k/cpu-qom.h
similarity index 100%
rename from target-m68k/cpu-qom.h
rename to target/m68k/cpu-qom.h
diff --git a/target-m68k/cpu.c b/target/m68k/cpu.c
similarity index 100%
rename from target-m68k/cpu.c
rename to target/m68k/cpu.c
diff --git a/target-m68k/cpu.h b/target/m68k/cpu.h
similarity index 100%
rename from target-m68k/cpu.h
rename to target/m68k/cpu.h
diff --git a/target-m68k/gdbstub.c b/target/m68k/gdbstub.c
similarity index 100%
rename from target-m68k/gdbstub.c
rename to target/m68k/gdbstub.c
diff --git a/target-m68k/helper.c b/target/m68k/helper.c
similarity index 100%
rename from target-m68k/helper.c
rename to target/m68k/helper.c
diff --git a/target-m68k/helper.h b/target/m68k/helper.h
similarity index 100%
rename from target-m68k/helper.h
rename to target/m68k/helper.h
diff --git a/target-m68k/m68k-semi.c b/target/m68k/m68k-semi.c
similarity index 100%
rename from target-m68k/m68k-semi.c
rename to target/m68k/m68k-semi.c
diff --git a/target-m68k/op_helper.c b/target/m68k/op_helper.c
similarity index 100%
rename from target-m68k/op_helper.c
rename to target/m68k/op_helper.c
diff --git a/target-m68k/qregs.def b/target/m68k/qregs.def
similarity index 100%
rename from target-m68k/qregs.def
rename to target/m68k/qregs.def
diff --git a/target-m68k/translate.c b/target/m68k/translate.c
similarity index 100%
rename from target-m68k/translate.c
rename to target/m68k/translate.c
-- 
1.8.3.1




Re: [Qemu-devel] [PATCH 20/20] Makefile.target: Targets now have to reside in the target/ folder

2016-12-09 Thread Laurent Vivier
Le 09/12/2016 à 13:17, Thomas Huth a écrit :
> Now that all target CPU folders have been moved to target/, we
> do not need to support the old naming scheme of target-xxx
> anymore.
> 
> Signed-off-by: Thomas Huth 
> ---
>  Makefile.target | 4 
>  1 file changed, 4 deletions(-)
> 
> diff --git a/Makefile.target b/Makefile.target
> index 90b25ae..1da789c 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -7,11 +7,7 @@ include config-target.mak
>  include config-devices.mak
>  include $(SRC_PATH)/rules.mak
>  
> -ifneq ($(wildcard $(SRC_PATH)/target/$(TARGET_BASE_ARCH)),)
>  TARGET_FOLDER=target/$(TARGET_BASE_ARCH)
> -else
> -TARGET_FOLDER=target-$(TARGET_BASE_ARCH)
> -endif
>  
>  $(call set-vpath, $(SRC_PATH):$(BUILD_DIR))
>  ifdef CONFIG_LINUX
> 
Reviewed-by: Laurent Vivier 




[Qemu-devel] [PATCH 07/20] i386: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS  | 4 ++--
 Makefile.objs| 2 +-
 hw/i386/acpi-build.c | 2 +-
 hw/i386/kvm/apic.c   | 2 +-
 hw/intc/ioapic.c | 2 +-
 hw/misc/hyperv_testdev.c | 2 +-
 scripts/analyze-inclusions   | 6 +++---
 {target-i386 => target/i386}/Makefile.objs   | 0
 {target-i386 => target/i386}/TODO| 0
 {target-i386 => target/i386}/arch_dump.c | 0
 {target-i386 => target/i386}/arch_memory_mapping.c   | 0
 {target-i386 => target/i386}/bpt_helper.c| 0
 {target-i386 => target/i386}/cc_helper.c | 0
 {target-i386 => target/i386}/cc_helper_template.h| 0
 {target-i386 => target/i386}/cpu-qom.h   | 0
 {target-i386 => target/i386}/cpu.c   | 0
 {target-i386 => target/i386}/cpu.h   | 0
 {target-i386 => target/i386}/excp_helper.c   | 0
 {target-i386 => target/i386}/fpu_helper.c| 0
 {target-i386 => target/i386}/gdbstub.c   | 0
 {target-i386 => target/i386}/helper.c| 0
 {target-i386 => target/i386}/helper.h| 0
 {target-i386 => target/i386}/hyperv.c| 0
 {target-i386 => target/i386}/hyperv.h| 0
 {target-i386 => target/i386}/int_helper.c| 0
 {target-i386 => target/i386}/kvm-stub.c  | 0
 {target-i386 => target/i386}/kvm.c   | 0
 {target-i386 => target/i386}/kvm_i386.h  | 0
 {target-i386 => target/i386}/machine.c   | 0
 {target-i386 => target/i386}/mem_helper.c| 0
 {target-i386 => target/i386}/misc_helper.c   | 0
 {target-i386 => target/i386}/monitor.c   | 0
 {target-i386 => target/i386}/mpx_helper.c| 0
 {target-i386 => target/i386}/ops_sse.h   | 0
 {target-i386 => target/i386}/ops_sse_header.h| 0
 {target-i386 => target/i386}/seg_helper.c| 0
 {target-i386 => target/i386}/shift_helper_template.h | 0
 {target-i386 => target/i386}/smm_helper.c| 0
 {target-i386 => target/i386}/svm.h   | 0
 {target-i386 => target/i386}/svm_helper.c| 0
 {target-i386 => target/i386}/trace-events| 2 +-
 {target-i386 => target/i386}/translate.c | 0
 42 files changed, 11 insertions(+), 11 deletions(-)
 rename {target-i386 => target/i386}/Makefile.objs (100%)
 rename {target-i386 => target/i386}/TODO (100%)
 rename {target-i386 => target/i386}/arch_dump.c (100%)
 rename {target-i386 => target/i386}/arch_memory_mapping.c (100%)
 rename {target-i386 => target/i386}/bpt_helper.c (100%)
 rename {target-i386 => target/i386}/cc_helper.c (100%)
 rename {target-i386 => target/i386}/cc_helper_template.h (100%)
 rename {target-i386 => target/i386}/cpu-qom.h (100%)
 rename {target-i386 => target/i386}/cpu.c (100%)
 rename {target-i386 => target/i386}/cpu.h (100%)
 rename {target-i386 => target/i386}/excp_helper.c (100%)
 rename {target-i386 => target/i386}/fpu_helper.c (100%)
 rename {target-i386 => target/i386}/gdbstub.c (100%)
 rename {target-i386 => target/i386}/helper.c (100%)
 rename {target-i386 => target/i386}/helper.h (100%)
 rename {target-i386 => target/i386}/hyperv.c (100%)
 rename {target-i386 => target/i386}/hyperv.h (100%)
 rename {target-i386 => target/i386}/int_helper.c (100%)
 rename {target-i386 => target/i386}/kvm-stub.c (100%)
 rename {target-i386 => target/i386}/kvm.c (100%)
 rename {target-i386 => target/i386}/kvm_i386.h (100%)
 rename {target-i386 => target/i386}/machine.c (100%)
 rename {target-i386 => target/i386}/mem_helper.c (100%)
 rename {target-i386 => target/i386}/misc_helper.c (100%)
 rename {target-i386 => target/i386}/monitor.c (100%)
 rename {target-i386 => target/i386}/mpx_helper.c (100%)
 rename {target-i386 => target/i386}/ops_sse.h (100%)
 rename {target-i386 => target/i386}/ops_sse_header.h (100%)
 rename {target-i386 => target/i386}/seg_helper.c (100%)
 rename {target-i386 => target/i386}/shift_helper_template.h (100%)
 rename {target-i386 => target/i386}/smm_helper.c (100%)
 rename {target-i386 => target/i386}/svm.h (100%)
 rename {target-i386 => target/i386}/svm_helper.c (100%)
 rename {target-i386 => target/i386}/trace-events (94%)
 rename {target-i386 => target/i386}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index da65284..1b064ac 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -235,7 +235,7 @@ M: Paolo Bonzini 
 M: Richard Henderson 
 M: Eduardo Habkost 
 S: Maintained
-F: target-i386/
+F: target/i386/
 F: hw/i386/
 F: disas/i386.c
 
@@ -301,7 +301,7 @@ M: Paolo Bonzini 
 M: Marcelo Tosatti 
 L: k...@vger.kernel.org
 S: Supported
-F: 

[Qemu-devel] [PATCH 16/20] sh4: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS  | 2 +-
 hw/sh4/shix.c| 2 +-
 include/hw/sh4/sh.h  | 2 +-
 {target-sh4 => target/sh4}/Makefile.objs | 0
 {target-sh4 => target/sh4}/README.sh4| 2 +-
 {target-sh4 => target/sh4}/cpu-qom.h | 0
 {target-sh4 => target/sh4}/cpu.c | 0
 {target-sh4 => target/sh4}/cpu.h | 0
 {target-sh4 => target/sh4}/gdbstub.c | 0
 {target-sh4 => target/sh4}/helper.c  | 0
 {target-sh4 => target/sh4}/helper.h  | 0
 {target-sh4 => target/sh4}/monitor.c | 0
 {target-sh4 => target/sh4}/op_helper.c   | 0
 {target-sh4 => target/sh4}/translate.c   | 0
 14 files changed, 4 insertions(+), 4 deletions(-)
 rename {target-sh4 => target/sh4}/Makefile.objs (100%)
 rename {target-sh4 => target/sh4}/README.sh4 (98%)
 rename {target-sh4 => target/sh4}/cpu-qom.h (100%)
 rename {target-sh4 => target/sh4}/cpu.c (100%)
 rename {target-sh4 => target/sh4}/cpu.h (100%)
 rename {target-sh4 => target/sh4}/gdbstub.c (100%)
 rename {target-sh4 => target/sh4}/helper.c (100%)
 rename {target-sh4 => target/sh4}/helper.h (100%)
 rename {target-sh4 => target/sh4}/monitor.c (100%)
 rename {target-sh4 => target/sh4}/op_helper.c (100%)
 rename {target-sh4 => target/sh4}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index d4d5605..31597bc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -209,7 +209,7 @@ F: disas/s390.c
 SH4
 M: Aurelien Jarno 
 S: Odd Fixes
-F: target-sh4/
+F: target/sh4/
 F: hw/sh4/
 F: disas/sh4.c
 F: include/hw/sh4/
diff --git a/hw/sh4/shix.c b/hw/sh4/shix.c
index 14d4007..fd00cc5 100644
--- a/hw/sh4/shix.c
+++ b/hw/sh4/shix.c
@@ -25,7 +25,7 @@
Shix 2.0 board by Alexis Polti, described at

https://web.archive.org/web/20070917001736/perso.enst.fr/~polti/realisations/shix20
 
-   More information in target-sh4/README.sh4
+   More information in target/sh4/README.sh4
 */
 #include "qemu/osdep.h"
 #include "qapi/error.h"
diff --git a/include/hw/sh4/sh.h b/include/hw/sh4/sh.h
index 070312d..e50651a 100644
--- a/include/hw/sh4/sh.h
+++ b/include/hw/sh4/sh.h
@@ -3,7 +3,7 @@
 /* Definitions for SH board emulation.  */
 
 #include "hw/sh4/sh_intc.h"
-#include "target-sh4/cpu-qom.h"
+#include "cpu-qom.h"
 
 #define A7ADDR(x) ((x) & 0x1fff)
 #define P4ADDR(x) ((x) | 0xe000)
diff --git a/target-sh4/Makefile.objs b/target/sh4/Makefile.objs
similarity index 100%
rename from target-sh4/Makefile.objs
rename to target/sh4/Makefile.objs
diff --git a/target-sh4/README.sh4 b/target/sh4/README.sh4
similarity index 98%
rename from target-sh4/README.sh4
rename to target/sh4/README.sh4
index ece0464..a192ca7 100644
--- a/target-sh4/README.sh4
+++ b/target/sh4/README.sh4
@@ -8,7 +8,7 @@ file describes the current state of implementation.
 Most places requiring attention and/or modification can be detected by
 looking for "X" or "abort()".
 
-The sh4 core is located in target-sh4/*, while the 7750 peripheral
+The sh4 core is located in target/sh4/*, while the 7750 peripheral
 features (IO ports for example) are located in hw/sh7750.[ch]. The
 main board description is in hw/shix.c, and the NAND flash in
 hw/tc58128.[ch].
diff --git a/target-sh4/cpu-qom.h b/target/sh4/cpu-qom.h
similarity index 100%
rename from target-sh4/cpu-qom.h
rename to target/sh4/cpu-qom.h
diff --git a/target-sh4/cpu.c b/target/sh4/cpu.c
similarity index 100%
rename from target-sh4/cpu.c
rename to target/sh4/cpu.c
diff --git a/target-sh4/cpu.h b/target/sh4/cpu.h
similarity index 100%
rename from target-sh4/cpu.h
rename to target/sh4/cpu.h
diff --git a/target-sh4/gdbstub.c b/target/sh4/gdbstub.c
similarity index 100%
rename from target-sh4/gdbstub.c
rename to target/sh4/gdbstub.c
diff --git a/target-sh4/helper.c b/target/sh4/helper.c
similarity index 100%
rename from target-sh4/helper.c
rename to target/sh4/helper.c
diff --git a/target-sh4/helper.h b/target/sh4/helper.h
similarity index 100%
rename from target-sh4/helper.h
rename to target/sh4/helper.h
diff --git a/target-sh4/monitor.c b/target/sh4/monitor.c
similarity index 100%
rename from target-sh4/monitor.c
rename to target/sh4/monitor.c
diff --git a/target-sh4/op_helper.c b/target/sh4/op_helper.c
similarity index 100%
rename from target-sh4/op_helper.c
rename to target/sh4/op_helper.c
diff --git a/target-sh4/translate.c b/target/sh4/translate.c
similarity index 100%
rename from target-sh4/translate.c
rename to target/sh4/translate.c
-- 
1.8.3.1




[Qemu-devel] [PATCH v2 5/6] target-ppc: implement xxextractuw instruction

2016-12-09 Thread Nikunj A Dadhania
xxextractuw: VSX Vector Extract Unsigned Word

Signed-off-by: Nikunj A Dadhania 
---
 target-ppc/helper.h |  1 +
 target-ppc/int_helper.c | 21 +
 target-ppc/translate/vsx-impl.inc.c | 27 +++
 target-ppc/translate/vsx-ops.inc.c  |  5 +
 4 files changed, 54 insertions(+)

diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index 4707db4..8b30420 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -540,6 +540,7 @@ DEF_HELPER_2(xvrspip, void, env, i32)
 DEF_HELPER_2(xvrspiz, void, env, i32)
 DEF_HELPER_2(xxperm, void, env, i32)
 DEF_HELPER_2(xxpermr, void, env, i32)
+DEF_HELPER_4(xxextractuw, void, env, tl, tl, i32)
 
 DEF_HELPER_2(efscfsi, i32, env, i32)
 DEF_HELPER_2(efscfui, i32, env, i32)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index 7989b1f..e3f66ac 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -2033,6 +2033,27 @@ VEXTRACT(uw, u32)
 VEXTRACT(d, u64)
 #undef VEXTRACT
 
+void helper_xxextractuw(CPUPPCState *env, target_ulong xtn,
+target_ulong xbn, uint32_t index)
+{
+ppc_vsr_t xt, xb;
+size_t es = sizeof(uint32_t);
+uint32_t ext_index;
+
+getVSR(xbn, , env);
+memset(, 0, sizeof(xt));
+
+#if defined(HOST_WORDS_BIGENDIAN)
+ext_index = index;
+memcpy([8 - es], [ext_index], es);
+#else
+ext_index = (16 - index) - es;
+memcpy([8], [ext_index], es);
+#endif
+
+putVSR(xtn, , env);
+}
+
 #define VEXT_SIGNED(name, element, mask, cast, recast)  \
 void helper_##name(ppc_avr_t *r, ppc_avr_t *b)  \
 {   \
diff --git a/target-ppc/translate/vsx-impl.inc.c 
b/target-ppc/translate/vsx-impl.inc.c
index 2a17c35..1c40a35 100644
--- a/target-ppc/translate/vsx-impl.inc.c
+++ b/target-ppc/translate/vsx-impl.inc.c
@@ -1180,6 +1180,33 @@ static void gen_xxsldwi(DisasContext *ctx)
 tcg_temp_free_i64(xtl);
 }
 
+#define VSX_EXTRACT(name)   \
+static void gen_##name(DisasContext *ctx)   \
+{   \
+TCGv xt, xb;\
+TCGv_i32 t0 = tcg_temp_new_i32();   \
+uint8_t uimm = UIMM4(ctx->opcode);  \
+\
+if (unlikely(!ctx->vsx_enabled)) {  \
+gen_exception(ctx, POWERPC_EXCP_VSXU);  \
+return; \
+}   \
+if (uimm > 12) {\
+tcg_gen_movi_i64(cpu_vsrh(xT(ctx->opcode)), 0); \
+tcg_gen_movi_i64(cpu_vsrl(xT(ctx->opcode)), 0); \
+return; \
+}   \
+xt = tcg_const_tl(xT(ctx->opcode)); \
+xb = tcg_const_tl(xB(ctx->opcode)); \
+tcg_gen_movi_i32(t0, uimm); \
+gen_helper_##name(cpu_env, xt, xb, t0); \
+tcg_temp_free(xb);  \
+tcg_temp_free(xt);  \
+tcg_temp_free_i32(t0);  \
+}
+
+VSX_EXTRACT(xxextractuw)
+
 #undef GEN_XX2FORM
 #undef GEN_XX3FORM
 #undef GEN_XX2IFORM
diff --git a/target-ppc/translate/vsx-ops.inc.c 
b/target-ppc/translate/vsx-ops.inc.c
index 46b95e3..473d925 100644
--- a/target-ppc/translate/vsx-ops.inc.c
+++ b/target-ppc/translate/vsx-ops.inc.c
@@ -49,6 +49,10 @@ GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, 
PPC_NONE, fl2)
 GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 0, PPC_NONE, fl2), \
 GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0, PPC_NONE, fl2)
 
+#define GEN_XX2FORM_EXT(name, opc2, opc3, fl2)  \
+GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 0, opc3, 0x0010, PPC_NONE, fl2), \
+GEN_HANDLER2_E(name, #name, 0x3C, opc2 | 1, opc3, 0x0010, PPC_NONE, fl2)
+
 #define GEN_XX2FORM_EO(name, opc2, opc3, opc4, fl2)  \
 GEN_HANDLER2_E_2(name, #name, 0x3C, opc2 | 0, opc3, opc4, 0, PPC_NONE, fl2), \
 GEN_HANDLER2_E_2(name, #name, 0x3C, opc2 | 1, opc3, opc4, 0, PPC_NONE, fl2)
@@ -280,6 +284,7 @@ GEN_XX3FORM(xxpermr, 0x08, 0x07, PPC2_ISA300),
 GEN_XX2FORM(xxspltw, 0x08, 0x0A, PPC2_VSX),
 GEN_XX1FORM(xxspltib, 0x08, 0x0B, PPC2_ISA300),
 GEN_XX3FORM_DM(xxsldwi, 0x08, 0x00),
+GEN_XX2FORM_EXT(xxextractuw, 0x0A, 0x0A, PPC2_ISA300),
 
 #define GEN_XXSEL_ROW(opc3) \
 GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x18, opc3, 0, PPC_NONE, PPC2_VSX), \
-- 
2.7.4




Re: [Qemu-devel] [PATCH 01/20] Makefile: Allow CPU targets to reside in target/ folder, too

2016-12-09 Thread Laurent Vivier
Le 09/12/2016 à 13:17, Thomas Huth a écrit :
> To be able to compile the CPU targets from within a subfolder
> of the target/ folder, we've got to adapt the Makefile.target
> a little bit first. After this change, target CPUs can either
> reside in a target/xxx folder or continue to use the target-xxx
> scheme. The latter will be disabled once all targets have been
> moved.
> 
> Signed-off-by: Thomas Huth 
> ---
>  Makefile.target | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/Makefile.target b/Makefile.target
> index 7a5080e..90b25ae 100644
> --- a/Makefile.target
> +++ b/Makefile.target
> @@ -7,11 +7,17 @@ include config-target.mak
>  include config-devices.mak
>  include $(SRC_PATH)/rules.mak
>  
> +ifneq ($(wildcard $(SRC_PATH)/target/$(TARGET_BASE_ARCH)),)
> +TARGET_FOLDER=target/$(TARGET_BASE_ARCH)
> +else
> +TARGET_FOLDER=target-$(TARGET_BASE_ARCH)
> +endif

Perhaps you should consider to use ':=' instead of '='.

Laurent



[Qemu-devel] [PATCH 06/20] ppc: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS | 4 ++--
 Makefile.objs   | 2 +-
 hw/ppc/fdt.c| 2 +-
 hw/ppc/pnv.c| 2 +-
 hw/ppc/pnv_core.c   | 2 +-
 hw/ppc/pnv_lpc.c| 2 +-
 hw/ppc/pnv_xscom.c  | 2 +-
 hw/ppc/spapr_cpu_core.c | 6 +++---
 include/hw/ppc/fdt.h| 2 +-
 include/hw/ppc/ppc.h| 2 +-
 include/hw/ppc/spapr_cpu_core.h | 2 +-
 {target-ppc => target/ppc}/Makefile.objs| 0
 {target-ppc => target/ppc}/STATUS   | 0
 {target-ppc => target/ppc}/arch_dump.c  | 0
 {target-ppc => target/ppc}/cpu-models.c | 0
 {target-ppc => target/ppc}/cpu-models.h | 0
 {target-ppc => target/ppc}/cpu-qom.h| 0
 {target-ppc => target/ppc}/cpu.h| 0
 {target-ppc => target/ppc}/dfp_helper.c | 0
 {target-ppc => target/ppc}/excp_helper.c| 0
 {target-ppc => target/ppc}/fpu_helper.c | 0
 {target-ppc => target/ppc}/gdbstub.c| 0
 {target-ppc => target/ppc}/helper.h | 0
 {target-ppc => target/ppc}/helper_regs.h| 0
 {target-ppc => target/ppc}/int_helper.c | 0
 {target-ppc => target/ppc}/internal.h   | 0
 {target-ppc => target/ppc}/kvm-stub.c   | 0
 {target-ppc => target/ppc}/kvm.c| 0
 {target-ppc => target/ppc}/kvm_ppc.h| 0
 {target-ppc => target/ppc}/machine.c| 0
 {target-ppc => target/ppc}/mem_helper.c | 0
 {target-ppc => target/ppc}/mfrom_table.c| 0
 {target-ppc => target/ppc}/mfrom_table_gen.c| 0
 {target-ppc => target/ppc}/misc_helper.c| 0
 {target-ppc => target/ppc}/mmu-hash32.c | 0
 {target-ppc => target/ppc}/mmu-hash32.h | 0
 {target-ppc => target/ppc}/mmu-hash64.c | 0
 {target-ppc => target/ppc}/mmu-hash64.h | 0
 {target-ppc => target/ppc}/mmu_helper.c | 0
 {target-ppc => target/ppc}/monitor.c| 0
 {target-ppc => target/ppc}/timebase_helper.c| 0
 {target-ppc => target/ppc}/trace-events | 2 +-
 {target-ppc => target/ppc}/translate.c  | 0
 {target-ppc => target/ppc}/translate/dfp-impl.inc.c | 0
 {target-ppc => target/ppc}/translate/dfp-ops.inc.c  | 0
 {target-ppc => target/ppc}/translate/fp-impl.inc.c  | 0
 {target-ppc => target/ppc}/translate/fp-ops.inc.c   | 0
 {target-ppc => target/ppc}/translate/spe-impl.inc.c | 0
 {target-ppc => target/ppc}/translate/spe-ops.inc.c  | 0
 {target-ppc => target/ppc}/translate/vmx-impl.inc.c | 0
 {target-ppc => target/ppc}/translate/vmx-ops.inc.c  | 0
 {target-ppc => target/ppc}/translate/vsx-impl.inc.c | 0
 {target-ppc => target/ppc}/translate/vsx-ops.inc.c  | 0
 {target-ppc => target/ppc}/translate_init.c | 0
 {target-ppc => target/ppc}/user_only_helper.c   | 0
 55 files changed, 15 insertions(+), 15 deletions(-)
 rename {target-ppc => target/ppc}/Makefile.objs (100%)
 rename {target-ppc => target/ppc}/STATUS (100%)
 rename {target-ppc => target/ppc}/arch_dump.c (100%)
 rename {target-ppc => target/ppc}/cpu-models.c (100%)
 rename {target-ppc => target/ppc}/cpu-models.h (100%)
 rename {target-ppc => target/ppc}/cpu-qom.h (100%)
 rename {target-ppc => target/ppc}/cpu.h (100%)
 rename {target-ppc => target/ppc}/dfp_helper.c (100%)
 rename {target-ppc => target/ppc}/excp_helper.c (100%)
 rename {target-ppc => target/ppc}/fpu_helper.c (100%)
 rename {target-ppc => target/ppc}/gdbstub.c (100%)
 rename {target-ppc => target/ppc}/helper.h (100%)
 rename {target-ppc => target/ppc}/helper_regs.h (100%)
 rename {target-ppc => target/ppc}/int_helper.c (100%)
 rename {target-ppc => target/ppc}/internal.h (100%)
 rename {target-ppc => target/ppc}/kvm-stub.c (100%)
 rename {target-ppc => target/ppc}/kvm.c (100%)
 rename {target-ppc => target/ppc}/kvm_ppc.h (100%)
 rename {target-ppc => target/ppc}/machine.c (100%)
 rename {target-ppc => target/ppc}/mem_helper.c (100%)
 rename {target-ppc => target/ppc}/mfrom_table.c (100%)
 rename {target-ppc => target/ppc}/mfrom_table_gen.c (100%)
 rename {target-ppc => target/ppc}/misc_helper.c (100%)
 rename {target-ppc => target/ppc}/mmu-hash32.c (100%)
 rename {target-ppc => target/ppc}/mmu-hash32.h (100%)
 rename {target-ppc => target/ppc}/mmu-hash64.c (100%)
 rename {target-ppc => target/ppc}/mmu-hash64.h (100%)
 rename {target-ppc => target/ppc}/mmu_helper.c (100%)
 rename {target-ppc => target/ppc}/monitor.c (100%)
 rename {target-ppc => target/ppc}/timebase_helper.c (100%)
 rename {target-ppc => target/ppc}/trace-events (92%)
 rename {target-ppc => 

[Qemu-devel] [PATCH 02/20] tilegx: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 {target-tilegx => target/tilegx}/Makefile.objs   | 0
 {target-tilegx => target/tilegx}/cpu.c   | 0
 {target-tilegx => target/tilegx}/cpu.h   | 0
 {target-tilegx => target/tilegx}/helper.c| 0
 {target-tilegx => target/tilegx}/helper.h| 0
 {target-tilegx => target/tilegx}/opcode_tilegx.h | 0
 {target-tilegx => target/tilegx}/simd_helper.c   | 0
 {target-tilegx => target/tilegx}/spr_def_64.h| 0
 {target-tilegx => target/tilegx}/translate.c | 0
 9 files changed, 0 insertions(+), 0 deletions(-)
 rename {target-tilegx => target/tilegx}/Makefile.objs (100%)
 rename {target-tilegx => target/tilegx}/cpu.c (100%)
 rename {target-tilegx => target/tilegx}/cpu.h (100%)
 rename {target-tilegx => target/tilegx}/helper.c (100%)
 rename {target-tilegx => target/tilegx}/helper.h (100%)
 rename {target-tilegx => target/tilegx}/opcode_tilegx.h (100%)
 rename {target-tilegx => target/tilegx}/simd_helper.c (100%)
 rename {target-tilegx => target/tilegx}/spr_def_64.h (100%)
 rename {target-tilegx => target/tilegx}/translate.c (100%)

diff --git a/target-tilegx/Makefile.objs b/target/tilegx/Makefile.objs
similarity index 100%
rename from target-tilegx/Makefile.objs
rename to target/tilegx/Makefile.objs
diff --git a/target-tilegx/cpu.c b/target/tilegx/cpu.c
similarity index 100%
rename from target-tilegx/cpu.c
rename to target/tilegx/cpu.c
diff --git a/target-tilegx/cpu.h b/target/tilegx/cpu.h
similarity index 100%
rename from target-tilegx/cpu.h
rename to target/tilegx/cpu.h
diff --git a/target-tilegx/helper.c b/target/tilegx/helper.c
similarity index 100%
rename from target-tilegx/helper.c
rename to target/tilegx/helper.c
diff --git a/target-tilegx/helper.h b/target/tilegx/helper.h
similarity index 100%
rename from target-tilegx/helper.h
rename to target/tilegx/helper.h
diff --git a/target-tilegx/opcode_tilegx.h b/target/tilegx/opcode_tilegx.h
similarity index 100%
rename from target-tilegx/opcode_tilegx.h
rename to target/tilegx/opcode_tilegx.h
diff --git a/target-tilegx/simd_helper.c b/target/tilegx/simd_helper.c
similarity index 100%
rename from target-tilegx/simd_helper.c
rename to target/tilegx/simd_helper.c
diff --git a/target-tilegx/spr_def_64.h b/target/tilegx/spr_def_64.h
similarity index 100%
rename from target-tilegx/spr_def_64.h
rename to target/tilegx/spr_def_64.h
diff --git a/target-tilegx/translate.c b/target/tilegx/translate.c
similarity index 100%
rename from target-tilegx/translate.c
rename to target/tilegx/translate.c
-- 
1.8.3.1




[Qemu-devel] [PATCH 12/20] cris: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS   | 2 +-
 disas/cris.c  | 4 +---
 {target-cris => target/cris}/Makefile.objs| 0
 {target-cris => target/cris}/cpu-qom.h| 0
 {target-cris => target/cris}/cpu.c| 0
 {target-cris => target/cris}/cpu.h| 0
 {target-cris => target/cris}/crisv10-decode.h | 0
 {target-cris => target/cris}/crisv32-decode.h | 0
 {target-cris => target/cris}/gdbstub.c| 0
 {target-cris => target/cris}/helper.c | 0
 {target-cris => target/cris}/helper.h | 0
 {target-cris => target/cris}/machine.c| 0
 {target-cris => target/cris}/mmu.c| 0
 {target-cris => target/cris}/mmu.h| 0
 {target-cris => target/cris}/op_helper.c  | 0
 {target-cris => target/cris}/opcode-cris.h| 0
 {target-cris => target/cris}/translate.c  | 0
 {target-cris => target/cris}/translate_v10.c  | 0
 18 files changed, 2 insertions(+), 4 deletions(-)
 rename {target-cris => target/cris}/Makefile.objs (100%)
 rename {target-cris => target/cris}/cpu-qom.h (100%)
 rename {target-cris => target/cris}/cpu.c (100%)
 rename {target-cris => target/cris}/cpu.h (100%)
 rename {target-cris => target/cris}/crisv10-decode.h (100%)
 rename {target-cris => target/cris}/crisv32-decode.h (100%)
 rename {target-cris => target/cris}/gdbstub.c (100%)
 rename {target-cris => target/cris}/helper.c (100%)
 rename {target-cris => target/cris}/helper.h (100%)
 rename {target-cris => target/cris}/machine.c (100%)
 rename {target-cris => target/cris}/mmu.c (100%)
 rename {target-cris => target/cris}/mmu.h (100%)
 rename {target-cris => target/cris}/op_helper.c (100%)
 rename {target-cris => target/cris}/opcode-cris.h (100%)
 rename {target-cris => target/cris}/translate.c (100%)
 rename {target-cris => target/cris}/translate_v10.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index f8959d8..ccb841f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -126,7 +126,7 @@ F: disas/libvixl/
 CRIS
 M: Edgar E. Iglesias 
 S: Maintained
-F: target-cris/
+F: target/cris/
 F: hw/cris/
 F: include/hw/cris/
 F: tests/tcg/cris/
diff --git a/disas/cris.c b/disas/cris.c
index 7f35bc0..08161d1 100644
--- a/disas/cris.c
+++ b/disas/cris.c
@@ -21,9 +21,7 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 #include "disas/bfd.h"
-//#include "sysdep.h"
-#include "target-cris/opcode-cris.h"
-//#include "libiberty.h"
+#include "target/cris/opcode-cris.h"
 
 #define CONST_STRNEQ(STR1,STR2) (strncmp ((STR1), (STR2), sizeof (STR2) - 1) 
== 0)
 
diff --git a/target-cris/Makefile.objs b/target/cris/Makefile.objs
similarity index 100%
rename from target-cris/Makefile.objs
rename to target/cris/Makefile.objs
diff --git a/target-cris/cpu-qom.h b/target/cris/cpu-qom.h
similarity index 100%
rename from target-cris/cpu-qom.h
rename to target/cris/cpu-qom.h
diff --git a/target-cris/cpu.c b/target/cris/cpu.c
similarity index 100%
rename from target-cris/cpu.c
rename to target/cris/cpu.c
diff --git a/target-cris/cpu.h b/target/cris/cpu.h
similarity index 100%
rename from target-cris/cpu.h
rename to target/cris/cpu.h
diff --git a/target-cris/crisv10-decode.h b/target/cris/crisv10-decode.h
similarity index 100%
rename from target-cris/crisv10-decode.h
rename to target/cris/crisv10-decode.h
diff --git a/target-cris/crisv32-decode.h b/target/cris/crisv32-decode.h
similarity index 100%
rename from target-cris/crisv32-decode.h
rename to target/cris/crisv32-decode.h
diff --git a/target-cris/gdbstub.c b/target/cris/gdbstub.c
similarity index 100%
rename from target-cris/gdbstub.c
rename to target/cris/gdbstub.c
diff --git a/target-cris/helper.c b/target/cris/helper.c
similarity index 100%
rename from target-cris/helper.c
rename to target/cris/helper.c
diff --git a/target-cris/helper.h b/target/cris/helper.h
similarity index 100%
rename from target-cris/helper.h
rename to target/cris/helper.h
diff --git a/target-cris/machine.c b/target/cris/machine.c
similarity index 100%
rename from target-cris/machine.c
rename to target/cris/machine.c
diff --git a/target-cris/mmu.c b/target/cris/mmu.c
similarity index 100%
rename from target-cris/mmu.c
rename to target/cris/mmu.c
diff --git a/target-cris/mmu.h b/target/cris/mmu.h
similarity index 100%
rename from target-cris/mmu.h
rename to target/cris/mmu.h
diff --git a/target-cris/op_helper.c b/target/cris/op_helper.c
similarity index 100%
rename from target-cris/op_helper.c
rename to target/cris/op_helper.c
diff --git a/target-cris/opcode-cris.h b/target/cris/opcode-cris.h
similarity index 100%
rename from target-cris/opcode-cris.h
rename to target/cris/opcode-cris.h
diff --git a/target-cris/translate.c b/target/cris/translate.c
similarity index 100%
rename from target-cris/translate.c
rename to target/cris/translate.c
diff --git a/target-cris/translate_v10.c b/target/cris/translate_v10.c
similarity index 100%
rename from target-cris/translate_v10.c

[Qemu-devel] [PATCH 18/20] unicore32: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS   | 2 +-
 {target-unicore32 => target/unicore32}/Makefile.objs  | 0
 {target-unicore32 => target/unicore32}/cpu-qom.h  | 0
 {target-unicore32 => target/unicore32}/cpu.c  | 0
 {target-unicore32 => target/unicore32}/cpu.h  | 0
 {target-unicore32 => target/unicore32}/helper.c   | 0
 {target-unicore32 => target/unicore32}/helper.h   | 0
 {target-unicore32 => target/unicore32}/op_helper.c| 0
 {target-unicore32 => target/unicore32}/softmmu.c  | 0
 {target-unicore32 => target/unicore32}/translate.c| 0
 {target-unicore32 => target/unicore32}/ucf64_helper.c | 0
 11 files changed, 1 insertion(+), 1 deletion(-)
 rename {target-unicore32 => target/unicore32}/Makefile.objs (100%)
 rename {target-unicore32 => target/unicore32}/cpu-qom.h (100%)
 rename {target-unicore32 => target/unicore32}/cpu.c (100%)
 rename {target-unicore32 => target/unicore32}/cpu.h (100%)
 rename {target-unicore32 => target/unicore32}/helper.c (100%)
 rename {target-unicore32 => target/unicore32}/helper.h (100%)
 rename {target-unicore32 => target/unicore32}/op_helper.c (100%)
 rename {target-unicore32 => target/unicore32}/softmmu.c (100%)
 rename {target-unicore32 => target/unicore32}/translate.c (100%)
 rename {target-unicore32 => target/unicore32}/ucf64_helper.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 7733ccc..9e9607c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -226,7 +226,7 @@ F: disas/sparc.c
 UniCore32
 M: Guan Xuetao 
 S: Maintained
-F: target-unicore32/
+F: target/unicore32/
 F: hw/unicore32/
 F: include/hw/unicore32/
 
diff --git a/target-unicore32/Makefile.objs b/target/unicore32/Makefile.objs
similarity index 100%
rename from target-unicore32/Makefile.objs
rename to target/unicore32/Makefile.objs
diff --git a/target-unicore32/cpu-qom.h b/target/unicore32/cpu-qom.h
similarity index 100%
rename from target-unicore32/cpu-qom.h
rename to target/unicore32/cpu-qom.h
diff --git a/target-unicore32/cpu.c b/target/unicore32/cpu.c
similarity index 100%
rename from target-unicore32/cpu.c
rename to target/unicore32/cpu.c
diff --git a/target-unicore32/cpu.h b/target/unicore32/cpu.h
similarity index 100%
rename from target-unicore32/cpu.h
rename to target/unicore32/cpu.h
diff --git a/target-unicore32/helper.c b/target/unicore32/helper.c
similarity index 100%
rename from target-unicore32/helper.c
rename to target/unicore32/helper.c
diff --git a/target-unicore32/helper.h b/target/unicore32/helper.h
similarity index 100%
rename from target-unicore32/helper.h
rename to target/unicore32/helper.h
diff --git a/target-unicore32/op_helper.c b/target/unicore32/op_helper.c
similarity index 100%
rename from target-unicore32/op_helper.c
rename to target/unicore32/op_helper.c
diff --git a/target-unicore32/softmmu.c b/target/unicore32/softmmu.c
similarity index 100%
rename from target-unicore32/softmmu.c
rename to target/unicore32/softmmu.c
diff --git a/target-unicore32/translate.c b/target/unicore32/translate.c
similarity index 100%
rename from target-unicore32/translate.c
rename to target/unicore32/translate.c
diff --git a/target-unicore32/ucf64_helper.c b/target/unicore32/ucf64_helper.c
similarity index 100%
rename from target-unicore32/ucf64_helper.c
rename to target/unicore32/ucf64_helper.c
-- 
1.8.3.1




[Qemu-devel] [PATCH 04/20] alpha: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS  | 2 +-
 hw/alpha/alpha_sys.h | 2 +-
 {target-alpha => target/alpha}/Makefile.objs | 0
 {target-alpha => target/alpha}/STATUS| 0
 {target-alpha => target/alpha}/cpu-qom.h | 0
 {target-alpha => target/alpha}/cpu.c | 0
 {target-alpha => target/alpha}/cpu.h | 0
 {target-alpha => target/alpha}/fpu_helper.c  | 0
 {target-alpha => target/alpha}/gdbstub.c | 0
 {target-alpha => target/alpha}/helper.c  | 0
 {target-alpha => target/alpha}/helper.h  | 0
 {target-alpha => target/alpha}/int_helper.c  | 0
 {target-alpha => target/alpha}/machine.c | 0
 {target-alpha => target/alpha}/mem_helper.c  | 0
 {target-alpha => target/alpha}/sys_helper.c  | 0
 {target-alpha => target/alpha}/translate.c   | 0
 {target-alpha => target/alpha}/vax_helper.c  | 0
 17 files changed, 2 insertions(+), 2 deletions(-)
 rename {target-alpha => target/alpha}/Makefile.objs (100%)
 rename {target-alpha => target/alpha}/STATUS (100%)
 rename {target-alpha => target/alpha}/cpu-qom.h (100%)
 rename {target-alpha => target/alpha}/cpu.c (100%)
 rename {target-alpha => target/alpha}/cpu.h (100%)
 rename {target-alpha => target/alpha}/fpu_helper.c (100%)
 rename {target-alpha => target/alpha}/gdbstub.c (100%)
 rename {target-alpha => target/alpha}/helper.c (100%)
 rename {target-alpha => target/alpha}/helper.h (100%)
 rename {target-alpha => target/alpha}/int_helper.c (100%)
 rename {target-alpha => target/alpha}/machine.c (100%)
 rename {target-alpha => target/alpha}/mem_helper.c (100%)
 rename {target-alpha => target/alpha}/sys_helper.c (100%)
 rename {target-alpha => target/alpha}/translate.c (100%)
 rename {target-alpha => target/alpha}/vax_helper.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index ce1ee35..37deb43 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -106,7 +106,7 @@ F: include/fpu/
 Alpha
 M: Richard Henderson 
 S: Maintained
-F: target-alpha/
+F: target/alpha/
 F: hw/alpha/
 F: tests/tcg/alpha/
 F: disas/alpha.c
diff --git a/hw/alpha/alpha_sys.h b/hw/alpha/alpha_sys.h
index ed911f2..bdabf41 100644
--- a/hw/alpha/alpha_sys.h
+++ b/hw/alpha/alpha_sys.h
@@ -3,7 +3,7 @@
 #ifndef HW_ALPHA_SYS_H
 #define HW_ALPHA_SYS_H
 
-#include "target-alpha/cpu-qom.h"
+#include "cpu-qom.h"
 #include "hw/pci/pci.h"
 #include "hw/pci/pci_host.h"
 #include "hw/ide.h"
diff --git a/target-alpha/Makefile.objs b/target/alpha/Makefile.objs
similarity index 100%
rename from target-alpha/Makefile.objs
rename to target/alpha/Makefile.objs
diff --git a/target-alpha/STATUS b/target/alpha/STATUS
similarity index 100%
rename from target-alpha/STATUS
rename to target/alpha/STATUS
diff --git a/target-alpha/cpu-qom.h b/target/alpha/cpu-qom.h
similarity index 100%
rename from target-alpha/cpu-qom.h
rename to target/alpha/cpu-qom.h
diff --git a/target-alpha/cpu.c b/target/alpha/cpu.c
similarity index 100%
rename from target-alpha/cpu.c
rename to target/alpha/cpu.c
diff --git a/target-alpha/cpu.h b/target/alpha/cpu.h
similarity index 100%
rename from target-alpha/cpu.h
rename to target/alpha/cpu.h
diff --git a/target-alpha/fpu_helper.c b/target/alpha/fpu_helper.c
similarity index 100%
rename from target-alpha/fpu_helper.c
rename to target/alpha/fpu_helper.c
diff --git a/target-alpha/gdbstub.c b/target/alpha/gdbstub.c
similarity index 100%
rename from target-alpha/gdbstub.c
rename to target/alpha/gdbstub.c
diff --git a/target-alpha/helper.c b/target/alpha/helper.c
similarity index 100%
rename from target-alpha/helper.c
rename to target/alpha/helper.c
diff --git a/target-alpha/helper.h b/target/alpha/helper.h
similarity index 100%
rename from target-alpha/helper.h
rename to target/alpha/helper.h
diff --git a/target-alpha/int_helper.c b/target/alpha/int_helper.c
similarity index 100%
rename from target-alpha/int_helper.c
rename to target/alpha/int_helper.c
diff --git a/target-alpha/machine.c b/target/alpha/machine.c
similarity index 100%
rename from target-alpha/machine.c
rename to target/alpha/machine.c
diff --git a/target-alpha/mem_helper.c b/target/alpha/mem_helper.c
similarity index 100%
rename from target-alpha/mem_helper.c
rename to target/alpha/mem_helper.c
diff --git a/target-alpha/sys_helper.c b/target/alpha/sys_helper.c
similarity index 100%
rename from target-alpha/sys_helper.c
rename to target/alpha/sys_helper.c
diff --git a/target-alpha/translate.c b/target/alpha/translate.c
similarity index 100%
rename from target-alpha/translate.c
rename to target/alpha/translate.c
diff --git a/target-alpha/vax_helper.c b/target/alpha/vax_helper.c
similarity index 100%
rename from target-alpha/vax_helper.c
rename to target/alpha/vax_helper.c
-- 
1.8.3.1




[Qemu-devel] [PATCH v2 6/6] target-ppc: implement xxinsertw instruction

2016-12-09 Thread Nikunj A Dadhania
xxinsertw: VSX Vector Insert Word

Signed-off-by: Nikunj A Dadhania 
---
 target-ppc/helper.h |  1 +
 target-ppc/int_helper.c | 21 +
 target-ppc/translate/vsx-impl.inc.c |  5 +++--
 target-ppc/translate/vsx-ops.inc.c  |  1 +
 4 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index 8b30420..6c5b194 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -541,6 +541,7 @@ DEF_HELPER_2(xvrspiz, void, env, i32)
 DEF_HELPER_2(xxperm, void, env, i32)
 DEF_HELPER_2(xxpermr, void, env, i32)
 DEF_HELPER_4(xxextractuw, void, env, tl, tl, i32)
+DEF_HELPER_4(xxinsertw, void, env, tl, tl, i32)
 
 DEF_HELPER_2(efscfsi, i32, env, i32)
 DEF_HELPER_2(efscfui, i32, env, i32)
diff --git a/target-ppc/int_helper.c b/target-ppc/int_helper.c
index e3f66ac..4d7eab6 100644
--- a/target-ppc/int_helper.c
+++ b/target-ppc/int_helper.c
@@ -2054,6 +2054,27 @@ void helper_xxextractuw(CPUPPCState *env, target_ulong 
xtn,
 putVSR(xtn, , env);
 }
 
+void helper_xxinsertw(CPUPPCState *env, target_ulong xtn,
+  target_ulong xbn, uint32_t index)
+{
+ppc_vsr_t xt, xb;
+size_t es = sizeof(uint32_t);
+uint32_t ins_index;
+
+getVSR(xbn, , env);
+getVSR(xtn, , env);
+
+#if defined(HOST_WORDS_BIGENDIAN)
+ins_index = index;
+memcpy([ins_index], [8 - es], es);
+#else
+ins_index = (16 - index) - es;
+memcpy([ins_index], [8], es);
+#endif
+
+putVSR(xtn, , env);
+}
+
 #define VEXT_SIGNED(name, element, mask, cast, recast)  \
 void helper_##name(ppc_avr_t *r, ppc_avr_t *b)  \
 {   \
diff --git a/target-ppc/translate/vsx-impl.inc.c 
b/target-ppc/translate/vsx-impl.inc.c
index 1c40a35..9124e99 100644
--- a/target-ppc/translate/vsx-impl.inc.c
+++ b/target-ppc/translate/vsx-impl.inc.c
@@ -1180,7 +1180,7 @@ static void gen_xxsldwi(DisasContext *ctx)
 tcg_temp_free_i64(xtl);
 }
 
-#define VSX_EXTRACT(name)   \
+#define VSX_EXTRACT_INSERT(name)\
 static void gen_##name(DisasContext *ctx)   \
 {   \
 TCGv xt, xb;\
@@ -1205,7 +1205,8 @@ static void gen_##name(DisasContext *ctx) 
  \
 tcg_temp_free_i32(t0);  \
 }
 
-VSX_EXTRACT(xxextractuw)
+VSX_EXTRACT_INSERT(xxextractuw)
+VSX_EXTRACT_INSERT(xxinsertw)
 
 #undef GEN_XX2FORM
 #undef GEN_XX3FORM
diff --git a/target-ppc/translate/vsx-ops.inc.c 
b/target-ppc/translate/vsx-ops.inc.c
index 473d925..096d358 100644
--- a/target-ppc/translate/vsx-ops.inc.c
+++ b/target-ppc/translate/vsx-ops.inc.c
@@ -285,6 +285,7 @@ GEN_XX2FORM(xxspltw, 0x08, 0x0A, PPC2_VSX),
 GEN_XX1FORM(xxspltib, 0x08, 0x0B, PPC2_ISA300),
 GEN_XX3FORM_DM(xxsldwi, 0x08, 0x00),
 GEN_XX2FORM_EXT(xxextractuw, 0x0A, 0x0A, PPC2_ISA300),
+GEN_XX2FORM_EXT(xxinsertw, 0x0A, 0x0B, PPC2_ISA300),
 
 #define GEN_XXSEL_ROW(opc3) \
 GEN_HANDLER2_E(xxsel, "xxsel", 0x3C, 0x18, opc3, 0, PPC_NONE, PPC2_VSX), \
-- 
2.7.4




[Qemu-devel] [PATCH v2 4/6] target-ppc: implement stxvll instructions

2016-12-09 Thread Nikunj A Dadhania
stxvll: Store VSX Vector Left-justified with Length

Vector (8-bit elements) in BE/LE:
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+
|“T”|“h”|“i”|“s”|“ ”|“i”|“s”|“ ”|“a”|“ ”|“T”|“E”|“S”|“T”|00|00|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+

Storing 14 bytes would result in following Little/Big-endian Storage:
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+
|“T”|“h”|“i”|“s”|“ ”|“i”|“s”|“ ”|“a”|“ ”|“T”|“E”|“S”|“T”|FF|FF|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+

Signed-off-by: Nikunj A Dadhania 
---
 target-ppc/helper.h | 1 +
 target-ppc/mem_helper.c | 1 +
 target-ppc/translate/vsx-impl.inc.c | 1 +
 target-ppc/translate/vsx-ops.inc.c  | 1 +
 4 files changed, 4 insertions(+)

diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index 211313d..4707db4 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -321,6 +321,7 @@ DEF_HELPER_3(stvewx, void, env, avr, tl)
 DEF_HELPER_4(lxvl, void, env, tl, tl, tl)
 DEF_HELPER_4(lxvll, void, env, tl, tl, tl)
 DEF_HELPER_4(stxvl, void, env, tl, tl, tl)
+DEF_HELPER_4(stxvll, void, env, tl, tl, tl)
 #endif
 DEF_HELPER_4(vsumsws, void, env, avr, avr, avr)
 DEF_HELPER_4(vsum2sws, void, env, avr, avr, avr)
diff --git a/target-ppc/mem_helper.c b/target-ppc/mem_helper.c
index 2427b49..e6383c6 100644
--- a/target-ppc/mem_helper.c
+++ b/target-ppc/mem_helper.c
@@ -345,6 +345,7 @@ void helper_##name(CPUPPCState *env, target_ulong addr, 
  \
 }
 
 VSX_STXVL(stxvl, 0)
+VSX_STXVL(stxvll, 1)
 #undef VSX_STXVL
 #undef GET_NB
 #endif /* TARGET_PPC64 */
diff --git a/target-ppc/translate/vsx-impl.inc.c 
b/target-ppc/translate/vsx-impl.inc.c
index 5099d44..2a17c35 100644
--- a/target-ppc/translate/vsx-impl.inc.c
+++ b/target-ppc/translate/vsx-impl.inc.c
@@ -269,6 +269,7 @@ static void gen_##name(DisasContext *ctx)   
\
 VSX_VECTOR_LOAD_STORE_LENGTH(lxvl)
 VSX_VECTOR_LOAD_STORE_LENGTH(lxvll)
 VSX_VECTOR_LOAD_STORE_LENGTH(stxvl)
+VSX_VECTOR_LOAD_STORE_LENGTH(stxvll)
 #endif
 
 #define VSX_LOAD_SCALAR_DS(name, operation)   \
diff --git a/target-ppc/translate/vsx-ops.inc.c 
b/target-ppc/translate/vsx-ops.inc.c
index 3afded2..46b95e3 100644
--- a/target-ppc/translate/vsx-ops.inc.c
+++ b/target-ppc/translate/vsx-ops.inc.c
@@ -27,6 +27,7 @@ GEN_HANDLER_E(stxvb16x, 0x1F, 0x0C, 0x1F, 0, PPC_NONE, 
PPC2_ISA300),
 GEN_HANDLER_E(stxvx, 0x1F, 0x0C, 0x0C, 0, PPC_NONE, PPC2_ISA300),
 #if defined(TARGET_PPC64)
 GEN_HANDLER_E(stxvl, 0x1F, 0x0D, 0x0C, 0, PPC_NONE, PPC2_ISA300),
+GEN_HANDLER_E(stxvll, 0x1F, 0x0D, 0x0D, 0, PPC_NONE, PPC2_ISA300),
 #endif
 
 GEN_HANDLER_E(mfvsrwz, 0x1F, 0x13, 0x03, 0xF800, PPC_NONE, PPC2_VSX207),
-- 
2.7.4




[Qemu-devel] [PATCH 14/20] moxie: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS  | 2 +-
 {target-moxie => target/moxie}/Makefile.objs | 0
 {target-moxie => target/moxie}/cpu.c | 0
 {target-moxie => target/moxie}/cpu.h | 0
 {target-moxie => target/moxie}/helper.c  | 0
 {target-moxie => target/moxie}/helper.h  | 0
 {target-moxie => target/moxie}/machine.c | 0
 {target-moxie => target/moxie}/machine.h | 0
 {target-moxie => target/moxie}/mmu.c | 0
 {target-moxie => target/moxie}/mmu.h | 0
 {target-moxie => target/moxie}/translate.c   | 0
 11 files changed, 1 insertion(+), 1 deletion(-)
 rename {target-moxie => target/moxie}/Makefile.objs (100%)
 rename {target-moxie => target/moxie}/cpu.c (100%)
 rename {target-moxie => target/moxie}/cpu.h (100%)
 rename {target-moxie => target/moxie}/helper.c (100%)
 rename {target-moxie => target/moxie}/helper.h (100%)
 rename {target-moxie => target/moxie}/machine.c (100%)
 rename {target-moxie => target/moxie}/machine.h (100%)
 rename {target-moxie => target/moxie}/mmu.c (100%)
 rename {target-moxie => target/moxie}/mmu.h (100%)
 rename {target-moxie => target/moxie}/translate.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0d6b5fe..f172df9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -176,7 +176,7 @@ F: disas/mips.c
 Moxie
 M: Anthony Green 
 S: Maintained
-F: target-moxie/
+F: target/moxie/
 F: disas/moxie.c
 F: hw/moxie/
 F: default-configs/moxie-softmmu.mak
diff --git a/target-moxie/Makefile.objs b/target/moxie/Makefile.objs
similarity index 100%
rename from target-moxie/Makefile.objs
rename to target/moxie/Makefile.objs
diff --git a/target-moxie/cpu.c b/target/moxie/cpu.c
similarity index 100%
rename from target-moxie/cpu.c
rename to target/moxie/cpu.c
diff --git a/target-moxie/cpu.h b/target/moxie/cpu.h
similarity index 100%
rename from target-moxie/cpu.h
rename to target/moxie/cpu.h
diff --git a/target-moxie/helper.c b/target/moxie/helper.c
similarity index 100%
rename from target-moxie/helper.c
rename to target/moxie/helper.c
diff --git a/target-moxie/helper.h b/target/moxie/helper.h
similarity index 100%
rename from target-moxie/helper.h
rename to target/moxie/helper.h
diff --git a/target-moxie/machine.c b/target/moxie/machine.c
similarity index 100%
rename from target-moxie/machine.c
rename to target/moxie/machine.c
diff --git a/target-moxie/machine.h b/target/moxie/machine.h
similarity index 100%
rename from target-moxie/machine.h
rename to target/moxie/machine.h
diff --git a/target-moxie/mmu.c b/target/moxie/mmu.c
similarity index 100%
rename from target-moxie/mmu.c
rename to target/moxie/mmu.c
diff --git a/target-moxie/mmu.h b/target/moxie/mmu.h
similarity index 100%
rename from target-moxie/mmu.h
rename to target/moxie/mmu.h
diff --git a/target-moxie/translate.c b/target/moxie/translate.c
similarity index 100%
rename from target-moxie/translate.c
rename to target/moxie/translate.c
-- 
1.8.3.1




[Qemu-devel] [PATCH for-2.9 00/20] Move target-* CPU file into a target/ folder

2016-12-09 Thread Thomas Huth
After my RFC last week that did not move all folder yet, here's now
a patch series that moves all target-* folders into one subfolder:

We've currently got 18 architectures in QEMU, and thus 18 target-xxx
folders in the root folder of the QEMU source tree. More architectures
(e.g. RISC-V, AVR) are likely to be included soon, too, so the main
folder of the QEMU sources slowly gets quite overcrowded with the
target-xxx folders.
Thus I'd like to suggest that we move the target-xxx folders into
a dedicated target/ folder, so that target-xxx/ simply becomes
target/xxx/ instead.

The first patch prepares the build system to be able to deal with both,
target-xxx and target/xxx folders. Once that has been applied, each
target architecture can be moved individually into the target/ folder.

The final patch then removes the possibility of using the old scheme
for a CPU target - all targets now have to reside in the target/ folder.

Thomas Huth (20):
  Makefile: Allow CPU targets to reside in target/ folder, too
  tilegx: Move CPU files to target/ folder
  m68k: Move CPU files to target/ folder
  alpha: Move CPU files to target/ folder
  arm: Move CPU files to target/ folder
  ppc: Move CPU files to target/ folder
  i386: Move CPU files to target/ folder
  microblaze: Move CPU files to target/ folder
  mips: Move CPU files to target/ folder
  s390x: Move CPU files to target/ folder
  sparc: Move CPU files to target/ folder
  cris: Move CPU files to target/ folder
  lm32: Move CPU files to target/ folder
  moxie: Move CPU files to target/ folder
  openrisc: Move CPU files to target/ folder
  sh4: Move CPU files to target/ folder
  tricore: Move CPU files to target/ folder
  unicore32: Move CPU files to target/ folder
  xtensa: Move CPU files to target/ folder
  Makefile.target: Targets now have to reside in the target/ folder

 MAINTAINERS| 48 +++---
 Makefile.objs  | 10 ++---
 Makefile.target|  6 ++-
 disas/cris.c   |  4 +-
 hw/alpha/alpha_sys.h   |  2 +-
 hw/arm/strongarm.h |  2 +-
 hw/arm/virt-acpi-build.c   |  2 +-
 hw/i386/acpi-build.c   |  2 +-
 hw/i386/kvm/apic.c |  2 +-
 hw/intc/ioapic.c   |  2 +-
 hw/misc/hyperv_testdev.c   |  2 +-
 hw/ppc/fdt.c   |  2 +-
 hw/ppc/pnv.c   |  2 +-
 hw/ppc/pnv_core.c  |  2 +-
 hw/ppc/pnv_lpc.c   |  2 +-
 hw/ppc/pnv_xscom.c |  2 +-
 hw/ppc/spapr_cpu_core.c|  6 +--
 hw/sh4/shix.c  |  2 +-
 include/hw/arm/arm.h   |  2 +-
 include/hw/arm/exynos4210.h|  2 +-
 include/hw/arm/omap.h  |  2 +-
 include/hw/arm/pxa.h   |  2 +-
 include/hw/m68k/mcf.h  |  2 +-
 include/hw/mips/cpudevs.h  |  2 +-
 include/hw/ppc/fdt.h   |  2 +-
 include/hw/ppc/ppc.h   |  2 +-
 include/hw/ppc/spapr_cpu_core.h|  2 +-
 include/hw/sh4/sh.h|  2 +-
 scripts/analyze-inclusions |  6 +--
 {target-alpha => target/alpha}/Makefile.objs   |  0
 {target-alpha => target/alpha}/STATUS  |  0
 {target-alpha => target/alpha}/cpu-qom.h   |  0
 {target-alpha => target/alpha}/cpu.c   |  0
 {target-alpha => target/alpha}/cpu.h   |  0
 {target-alpha => target/alpha}/fpu_helper.c|  0
 {target-alpha => target/alpha}/gdbstub.c   |  0
 {target-alpha => target/alpha}/helper.c|  0
 {target-alpha => target/alpha}/helper.h|  0
 {target-alpha => target/alpha}/int_helper.c|  0
 {target-alpha => target/alpha}/machine.c   |  0
 {target-alpha => target/alpha}/mem_helper.c|  0
 {target-alpha => target/alpha}/sys_helper.c|  0
 {target-alpha => target/alpha}/translate.c |  0
 {target-alpha => target/alpha}/vax_helper.c|  0
 {target-arm => target/arm}/Makefile.objs   |  0
 {target-arm => target/arm}/arch_dump.c |  0
 {target-arm => target/arm}/arm-powerctl.c  |  0
 {target-arm => target/arm}/arm-powerctl.h  |  0
 {target-arm => target/arm}/arm-semi.c  |  0
 {target-arm => target/arm}/arm_ldst.h  |  0
 {target-arm => target/arm}/cpu-qom.h   |  0
 {target-arm => target/arm}/cpu.c   |  0
 {target-arm => target/arm}/cpu.h   |  0
 {target-arm => 

[Qemu-devel] [PATCH v2 3/6] target-ppc: implement stxvl instruction

2016-12-09 Thread Nikunj A Dadhania
stxvl: Store VSX Vector with Length

Vector (8-bit elements) in BE:
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+
|“T”|“h”|“i”|“s”|“ ”|“i”|“s”|“ ”|“a”|“ ”|“T”|“E”|“S”|“T”|00|00|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+

Vector (8-bit elements) in LE:
+--+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|00|00|“T”|“S”|“E”|“T”|“ ”|“a”|“ ”|“s”|“i”|“ ”|“s”|“i”|"h"|"T"|
+--+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

Storing 14 bytes would result in following Little/Big-endian Storage:
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+
|“T”|“h”|“i”|“s”|“ ”|“i”|“s”|“ ”|“a”|“ ”|“T”|“E”|“S”|“T”|FF|FF|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+

Signed-off-by: Nikunj A Dadhania 
---
 target-ppc/helper.h |  1 +
 target-ppc/mem_helper.c | 29 +
 target-ppc/translate/vsx-impl.inc.c |  1 +
 target-ppc/translate/vsx-ops.inc.c  |  3 +++
 4 files changed, 34 insertions(+)

diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index 6c44731..211313d 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -320,6 +320,7 @@ DEF_HELPER_3(stvewx, void, env, avr, tl)
 #if defined(TARGET_PPC64)
 DEF_HELPER_4(lxvl, void, env, tl, tl, tl)
 DEF_HELPER_4(lxvll, void, env, tl, tl, tl)
+DEF_HELPER_4(stxvl, void, env, tl, tl, tl)
 #endif
 DEF_HELPER_4(vsumsws, void, env, avr, avr, avr)
 DEF_HELPER_4(vsum2sws, void, env, avr, avr, avr)
diff --git a/target-ppc/mem_helper.c b/target-ppc/mem_helper.c
index da51465..2427b49 100644
--- a/target-ppc/mem_helper.c
+++ b/target-ppc/mem_helper.c
@@ -317,6 +317,35 @@ void helper_##name(CPUPPCState *env, target_ulong addr,
 \
 VSX_LXVL(lxvl, 0)
 VSX_LXVL(lxvll, 1)
 #undef VSX_LXVL
+
+#define VSX_STXVL(name, lj)   \
+void helper_##name(CPUPPCState *env, target_ulong addr,   \
+   target_ulong xt_num, target_ulong rb)  \
+{ \
+int i;\
+ppc_vsr_t xt; \
+target_ulong nb = GET_NB(rb); \
+  \
+if (!nb) {\
+return;   \
+} \
+getVSR(xt_num, , env); \
+nb = (nb >= 16) ? 16 : nb;\
+if (msr_le && !lj) {  \
+for (i = 16; i > 16 - nb; i--) {  \
+cpu_stb_data_ra(env, addr, xt.VsrB(i - 1), GETPC());  \
+addr = addr_add(env, addr, 1);\
+} \
+} else {  \
+for (i = 0; i < nb; i++) {\
+cpu_stb_data_ra(env, addr, xt.VsrB(i), GETPC());  \
+addr = addr_add(env, addr, 1);\
+} \
+} \
+}
+
+VSX_STXVL(stxvl, 0)
+#undef VSX_STXVL
 #undef GET_NB
 #endif /* TARGET_PPC64 */
 
diff --git a/target-ppc/translate/vsx-impl.inc.c 
b/target-ppc/translate/vsx-impl.inc.c
index ce20579..5099d44 100644
--- a/target-ppc/translate/vsx-impl.inc.c
+++ b/target-ppc/translate/vsx-impl.inc.c
@@ -268,6 +268,7 @@ static void gen_##name(DisasContext *ctx)   
\
 
 VSX_VECTOR_LOAD_STORE_LENGTH(lxvl)
 VSX_VECTOR_LOAD_STORE_LENGTH(lxvll)
+VSX_VECTOR_LOAD_STORE_LENGTH(stxvl)
 #endif
 
 #define VSX_LOAD_SCALAR_DS(name, operation)   \
diff --git a/target-ppc/translate/vsx-ops.inc.c 
b/target-ppc/translate/vsx-ops.inc.c
index c207804..3afded2 100644
--- a/target-ppc/translate/vsx-ops.inc.c
+++ b/target-ppc/translate/vsx-ops.inc.c
@@ -25,6 +25,9 @@ GEN_HANDLER_E(stxvw4x, 0x1F, 0xC, 0x1C, 0, PPC_NONE, 
PPC2_VSX),
 GEN_HANDLER_E(stxvh8x, 0x1F, 0x0C, 0x1D, 0, PPC_NONE,  PPC2_ISA300),
 GEN_HANDLER_E(stxvb16x, 0x1F, 0x0C, 0x1F, 0, PPC_NONE, PPC2_ISA300),
 GEN_HANDLER_E(stxvx, 0x1F, 0x0C, 0x0C, 0, PPC_NONE, PPC2_ISA300),
+#if defined(TARGET_PPC64)
+GEN_HANDLER_E(stxvl, 0x1F, 0x0D, 0x0C, 0, PPC_NONE, PPC2_ISA300),
+#endif
 
 GEN_HANDLER_E(mfvsrwz, 0x1F, 0x13, 0x03, 0xF800, PPC_NONE, PPC2_VSX207),
 GEN_HANDLER_E(mtvsrwa, 0x1F, 0x13, 0x06, 0xF800, PPC_NONE, PPC2_VSX207),
-- 
2.7.4




[Qemu-devel] [PATCH 01/20] Makefile: Allow CPU targets to reside in target/ folder, too

2016-12-09 Thread Thomas Huth
To be able to compile the CPU targets from within a subfolder
of the target/ folder, we've got to adapt the Makefile.target
a little bit first. After this change, target CPUs can either
reside in a target/xxx folder or continue to use the target-xxx
scheme. The latter will be disabled once all targets have been
moved.

Signed-off-by: Thomas Huth 
---
 Makefile.target | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/Makefile.target b/Makefile.target
index 7a5080e..90b25ae 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -7,11 +7,17 @@ include config-target.mak
 include config-devices.mak
 include $(SRC_PATH)/rules.mak
 
+ifneq ($(wildcard $(SRC_PATH)/target/$(TARGET_BASE_ARCH)),)
+TARGET_FOLDER=target/$(TARGET_BASE_ARCH)
+else
+TARGET_FOLDER=target-$(TARGET_BASE_ARCH)
+endif
+
 $(call set-vpath, $(SRC_PATH):$(BUILD_DIR))
 ifdef CONFIG_LINUX
 QEMU_CFLAGS += -I../linux-headers
 endif
-QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H
+QEMU_CFLAGS += -I.. -I$(SRC_PATH)/$(TARGET_FOLDER) -DNEED_CPU_H
 
 QEMU_CFLAGS+=-I$(SRC_PATH)/include
 
@@ -92,7 +98,7 @@ obj-$(CONFIG_TCG_INTERPRETER) += tci.o
 obj-y += tcg/tcg-common.o
 obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
 obj-y += fpu/softfloat.o
-obj-y += target-$(TARGET_BASE_ARCH)/
+obj-y += $(TARGET_FOLDER)/
 obj-y += disas.o
 obj-y += tcg-runtime.o
 obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
-- 
1.8.3.1




[Qemu-devel] [PATCH 11/20] sparc: Move CPU files to target/ folder

2016-12-09 Thread Thomas Huth
Signed-off-by: Thomas Huth 
---
 MAINTAINERS   | 2 +-
 Makefile.objs | 2 +-
 {target-sparc => target/sparc}/Makefile.objs  | 0
 {target-sparc => target/sparc}/TODO   | 0
 {target-sparc => target/sparc}/asi.h  | 0
 {target-sparc => target/sparc}/cc_helper.c| 0
 {target-sparc => target/sparc}/cpu-qom.h  | 0
 {target-sparc => target/sparc}/cpu.c  | 0
 {target-sparc => target/sparc}/cpu.h  | 0
 {target-sparc => target/sparc}/fop_helper.c   | 0
 {target-sparc => target/sparc}/gdbstub.c  | 0
 {target-sparc => target/sparc}/helper.c   | 0
 {target-sparc => target/sparc}/helper.h   | 0
 {target-sparc => target/sparc}/int32_helper.c | 0
 {target-sparc => target/sparc}/int64_helper.c | 0
 {target-sparc => target/sparc}/ldst_helper.c  | 0
 {target-sparc => target/sparc}/machine.c  | 0
 {target-sparc => target/sparc}/mmu_helper.c   | 0
 {target-sparc => target/sparc}/monitor.c  | 0
 {target-sparc => target/sparc}/trace-events   | 8 
 {target-sparc => target/sparc}/translate.c| 0
 {target-sparc => target/sparc}/vis_helper.c   | 0
 {target-sparc => target/sparc}/win_helper.c   | 0
 23 files changed, 6 insertions(+), 6 deletions(-)
 rename {target-sparc => target/sparc}/Makefile.objs (100%)
 rename {target-sparc => target/sparc}/TODO (100%)
 rename {target-sparc => target/sparc}/asi.h (100%)
 rename {target-sparc => target/sparc}/cc_helper.c (100%)
 rename {target-sparc => target/sparc}/cpu-qom.h (100%)
 rename {target-sparc => target/sparc}/cpu.c (100%)
 rename {target-sparc => target/sparc}/cpu.h (100%)
 rename {target-sparc => target/sparc}/fop_helper.c (100%)
 rename {target-sparc => target/sparc}/gdbstub.c (100%)
 rename {target-sparc => target/sparc}/helper.c (100%)
 rename {target-sparc => target/sparc}/helper.h (100%)
 rename {target-sparc => target/sparc}/int32_helper.c (100%)
 rename {target-sparc => target/sparc}/int64_helper.c (100%)
 rename {target-sparc => target/sparc}/ldst_helper.c (100%)
 rename {target-sparc => target/sparc}/machine.c (100%)
 rename {target-sparc => target/sparc}/mmu_helper.c (100%)
 rename {target-sparc => target/sparc}/monitor.c (100%)
 rename {target-sparc => target/sparc}/trace-events (94%)
 rename {target-sparc => target/sparc}/translate.c (100%)
 rename {target-sparc => target/sparc}/vis_helper.c (100%)
 rename {target-sparc => target/sparc}/win_helper.c (100%)

diff --git a/MAINTAINERS b/MAINTAINERS
index 48b0a7b..f8959d8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -218,7 +218,7 @@ SPARC
 M: Mark Cave-Ayland 
 M: Artyom Tarasenko 
 S: Maintained
-F: target-sparc/
+F: target/sparc/
 F: hw/sparc/
 F: hw/sparc64/
 F: disas/sparc.c
diff --git a/Makefile.objs b/Makefile.objs
index c5ebb80..e59b979 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -157,7 +157,7 @@ trace-events-y += audio/trace-events
 trace-events-y += net/trace-events
 trace-events-y += target/arm/trace-events
 trace-events-y += target/i386/trace-events
-trace-events-y += target-sparc/trace-events
+trace-events-y += target/sparc/trace-events
 trace-events-y += target/s390x/trace-events
 trace-events-y += target/ppc/trace-events
 trace-events-y += qom/trace-events
diff --git a/target-sparc/Makefile.objs b/target/sparc/Makefile.objs
similarity index 100%
rename from target-sparc/Makefile.objs
rename to target/sparc/Makefile.objs
diff --git a/target-sparc/TODO b/target/sparc/TODO
similarity index 100%
rename from target-sparc/TODO
rename to target/sparc/TODO
diff --git a/target-sparc/asi.h b/target/sparc/asi.h
similarity index 100%
rename from target-sparc/asi.h
rename to target/sparc/asi.h
diff --git a/target-sparc/cc_helper.c b/target/sparc/cc_helper.c
similarity index 100%
rename from target-sparc/cc_helper.c
rename to target/sparc/cc_helper.c
diff --git a/target-sparc/cpu-qom.h b/target/sparc/cpu-qom.h
similarity index 100%
rename from target-sparc/cpu-qom.h
rename to target/sparc/cpu-qom.h
diff --git a/target-sparc/cpu.c b/target/sparc/cpu.c
similarity index 100%
rename from target-sparc/cpu.c
rename to target/sparc/cpu.c
diff --git a/target-sparc/cpu.h b/target/sparc/cpu.h
similarity index 100%
rename from target-sparc/cpu.h
rename to target/sparc/cpu.h
diff --git a/target-sparc/fop_helper.c b/target/sparc/fop_helper.c
similarity index 100%
rename from target-sparc/fop_helper.c
rename to target/sparc/fop_helper.c
diff --git a/target-sparc/gdbstub.c b/target/sparc/gdbstub.c
similarity index 100%
rename from target-sparc/gdbstub.c
rename to target/sparc/gdbstub.c
diff --git a/target-sparc/helper.c b/target/sparc/helper.c
similarity index 100%
rename from target-sparc/helper.c
rename to target/sparc/helper.c
diff --git a/target-sparc/helper.h b/target/sparc/helper.h
similarity index 100%
rename from target-sparc/helper.h
rename to target/sparc/helper.h
diff --git a/target-sparc/int32_helper.c 

[Qemu-devel] [PATCH v2 2/6] target-ppc: implement lxvll instruction

2016-12-09 Thread Nikunj A Dadhania
lxvll: Load VSX Vector Left-justified with Length

Little/Big-endian Storage:
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+
|“T”|“h”|“i”|“s”|“ ”|“i”|“s”|“ ”|“a”|“ ”|“T”|“E”|“S”|“T”|FF|FF|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+

Loading 14 bytes to vector (8-bit elements) in BE/LE:
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+
|“T”|“h”|“i”|“s”|“ ”|“i”|“s”|“ ”|“a”|“ ”|“T”|“E”|“S”|“T”|00|00|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+

Signed-off-by: Nikunj A Dadhania 
---
 target-ppc/helper.h | 1 +
 target-ppc/mem_helper.c | 1 +
 target-ppc/translate/vsx-impl.inc.c | 1 +
 target-ppc/translate/vsx-ops.inc.c  | 1 +
 4 files changed, 4 insertions(+)

diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index 16ed2c1..6c44731 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -319,6 +319,7 @@ DEF_HELPER_3(stvehx, void, env, avr, tl)
 DEF_HELPER_3(stvewx, void, env, avr, tl)
 #if defined(TARGET_PPC64)
 DEF_HELPER_4(lxvl, void, env, tl, tl, tl)
+DEF_HELPER_4(lxvll, void, env, tl, tl, tl)
 #endif
 DEF_HELPER_4(vsumsws, void, env, avr, avr, avr)
 DEF_HELPER_4(vsum2sws, void, env, avr, avr, avr)
diff --git a/target-ppc/mem_helper.c b/target-ppc/mem_helper.c
index c4ddc5b..da51465 100644
--- a/target-ppc/mem_helper.c
+++ b/target-ppc/mem_helper.c
@@ -315,6 +315,7 @@ void helper_##name(CPUPPCState *env, target_ulong addr, 
\
 }
 
 VSX_LXVL(lxvl, 0)
+VSX_LXVL(lxvll, 1)
 #undef VSX_LXVL
 #undef GET_NB
 #endif /* TARGET_PPC64 */
diff --git a/target-ppc/translate/vsx-impl.inc.c 
b/target-ppc/translate/vsx-impl.inc.c
index 1f64fb7..ce20579 100644
--- a/target-ppc/translate/vsx-impl.inc.c
+++ b/target-ppc/translate/vsx-impl.inc.c
@@ -267,6 +267,7 @@ static void gen_##name(DisasContext *ctx)   
\
 }
 
 VSX_VECTOR_LOAD_STORE_LENGTH(lxvl)
+VSX_VECTOR_LOAD_STORE_LENGTH(lxvll)
 #endif
 
 #define VSX_LOAD_SCALAR_DS(name, operation)   \
diff --git a/target-ppc/translate/vsx-ops.inc.c 
b/target-ppc/translate/vsx-ops.inc.c
index 62a0afc..c207804 100644
--- a/target-ppc/translate/vsx-ops.inc.c
+++ b/target-ppc/translate/vsx-ops.inc.c
@@ -12,6 +12,7 @@ GEN_HANDLER_E(lxvb16x, 0x1F, 0x0C, 0x1B, 0, PPC_NONE, 
PPC2_ISA300),
 GEN_HANDLER_E(lxvx, 0x1F, 0x0C, 0x08, 0x0040, PPC_NONE, PPC2_ISA300),
 #if defined(TARGET_PPC64)
 GEN_HANDLER_E(lxvl, 0x1F, 0x0D, 0x08, 0, PPC_NONE, PPC2_ISA300),
+GEN_HANDLER_E(lxvll, 0x1F, 0x0D, 0x09, 0, PPC_NONE, PPC2_ISA300),
 #endif
 
 GEN_HANDLER_E(stxsdx, 0x1F, 0xC, 0x16, 0, PPC_NONE, PPC2_VSX),
-- 
2.7.4




[Qemu-devel] [PATCH v2 1/6] target-ppc: implement lxvl instruction

2016-12-09 Thread Nikunj A Dadhania
lxvl: Load VSX Vector with Length

Little/Big-endian Storage:
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+
|“T”|“h”|“i”|“s”|“ ”|“i”|“s”|“ ”|“a”|“ ”|“T”|“E”|“S”|“T”|FF|FF|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+

Loading 14 bytes results in:

Vector (8-bit elements) in BE:
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+
|“T”|“h”|“i”|“s”|“ ”|“i”|“s”|“ ”|“a”|“ ”|“T”|“E”|“S”|“T”|00|00|
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--+--+

Vector (8-bit elements) in LE:
+--+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
|00|00|“T”|“S”|“E”|“T”|“ ”|“a”|“ ”|“s”|“i”|“ ”|“s”|“i”|"h"|"T"|
+--+--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

Signed-off-by: Nikunj A Dadhania 
---
 target-ppc/helper.h |  3 +++
 target-ppc/mem_helper.c | 35 +++
 target-ppc/translate/vsx-impl.inc.c | 29 +
 target-ppc/translate/vsx-ops.inc.c  |  3 +++
 4 files changed, 70 insertions(+)

diff --git a/target-ppc/helper.h b/target-ppc/helper.h
index c3df982..16ed2c1 100644
--- a/target-ppc/helper.h
+++ b/target-ppc/helper.h
@@ -317,6 +317,9 @@ DEF_HELPER_3(lvewx, void, env, avr, tl)
 DEF_HELPER_3(stvebx, void, env, avr, tl)
 DEF_HELPER_3(stvehx, void, env, avr, tl)
 DEF_HELPER_3(stvewx, void, env, avr, tl)
+#if defined(TARGET_PPC64)
+DEF_HELPER_4(lxvl, void, env, tl, tl, tl)
+#endif
 DEF_HELPER_4(vsumsws, void, env, avr, avr, avr)
 DEF_HELPER_4(vsum2sws, void, env, avr, avr, avr)
 DEF_HELPER_4(vsum4sbs, void, env, avr, avr, avr)
diff --git a/target-ppc/mem_helper.c b/target-ppc/mem_helper.c
index 1ab8a6e..c4ddc5b 100644
--- a/target-ppc/mem_helper.c
+++ b/target-ppc/mem_helper.c
@@ -24,6 +24,7 @@
 
 #include "helper_regs.h"
 #include "exec/cpu_ldst.h"
+#include "internal.h"
 
 //#define DEBUG_OP
 
@@ -284,6 +285,40 @@ STVE(stvewx, cpu_stl_data_ra, bswap32, u32)
 #undef I
 #undef LVE
 
+#ifdef TARGET_PPC64
+#define GET_NB(rb) ((rb >> 56) & 0xFF)
+
+#define VSX_LXVL(name, lj)  \
+void helper_##name(CPUPPCState *env, target_ulong addr, \
+   target_ulong xt_num, target_ulong rb)\
+{   \
+int i;  \
+ppc_vsr_t xt;   \
+uint64_t nb = GET_NB(rb);   \
+\
+xt.s128 = int128_zero();\
+if (nb) {   \
+nb = (nb >= 16) ? 16 : nb;  \
+if (msr_le && !lj) {\
+for (i = 16; i > 16 - nb; i--) {\
+xt.VsrB(i - 1) = cpu_ldub_data_ra(env, addr, GETPC());  \
+addr = addr_add(env, addr, 1);  \
+}   \
+} else {\
+for (i = 0; i < nb; i++) {  \
+xt.VsrB(i) = cpu_ldub_data_ra(env, addr, GETPC());  \
+addr = addr_add(env, addr, 1);  \
+}   \
+}   \
+}   \
+putVSR(xt_num, , env);   \
+}
+
+VSX_LXVL(lxvl, 0)
+#undef VSX_LXVL
+#undef GET_NB
+#endif /* TARGET_PPC64 */
+
 #undef HI_IDX
 #undef LO_IDX
 
diff --git a/target-ppc/translate/vsx-impl.inc.c 
b/target-ppc/translate/vsx-impl.inc.c
index 735..1f64fb7 100644
--- a/target-ppc/translate/vsx-impl.inc.c
+++ b/target-ppc/translate/vsx-impl.inc.c
@@ -240,6 +240,35 @@ VSX_VECTOR_LOAD_STORE(stxv, st_i64, 0)
 VSX_VECTOR_LOAD_STORE(lxvx, ld_i64, 1)
 VSX_VECTOR_LOAD_STORE(stxvx, st_i64, 1)
 
+#ifdef TARGET_PPC64
+#define VSX_VECTOR_LOAD_STORE_LENGTH(name)  \
+static void gen_##name(DisasContext *ctx)   \
+{   \
+TCGv EA, xt;\
+\
+if (xT(ctx->opcode) < 32) { \
+if (unlikely(!ctx->vsx_enabled)) {  \
+gen_exception(ctx, POWERPC_EXCP_VSXU);  \
+return; \
+}  

[Qemu-devel] [PATCH v2 ppc-for-2.9 0/6] POWER9 TCG enablements - part9

2016-12-09 Thread Nikunj A Dadhania
This series contains 6 new instructions for POWER9 ISA3.0
 VSX Vector Insert/Extract Word
 VSX Load/Store with length

Although, lxvl/lxvll and stxvl/stxvll can be combined as single patch,
have left it for detailed commit log for instruction explanation.

Changelog:
v1:
* Combine helpers of lxvl and lxvll
* Combine helpers of stxvl and stxvll
* Rework xxextractuw and xxinsertw to simplify helper

v0:
* Fixed lxvl/lxvll and stxvl/stxvll as suggested by Richard
* Dropped mask_u128, which is not needed anymore
* Prevent UIMM > 12 in xxextractuw
* Drop xori from xsnegqp
* Rewrite xxperm/xxpermr without double copy

Nikunj A Dadhania (6):
  target-ppc: implement lxvl instruction
  target-ppc: implement lxvll instruction
  target-ppc: implement stxvl instruction
  target-ppc: implement stxvll instructions
  target-ppc: implement xxextractuw instruction
  target-ppc: implement xxinsertw instruction

 target-ppc/helper.h |  8 +
 target-ppc/int_helper.c | 42 +++
 target-ppc/mem_helper.c | 66 +
 target-ppc/translate/vsx-impl.inc.c | 60 +
 target-ppc/translate/vsx-ops.inc.c  | 14 
 5 files changed, 190 insertions(+)

-- 
2.7.4




  1   2   >