OSDN Git Service

qmiga/qemu.git
7 years agohmp: info migrate_capability format tunes
Peter Xu [Sat, 1 Apr 2017 08:18:44 +0000 (16:18 +0800)]
hmp: info migrate_capability format tunes

Dump the info in a single line is hard to read. Do it one per line.
Also, the first "capabilities:" didn't help much. Let's remove it.

CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
7 years agomigration: rename max_size to threshold_size
Peter Xu [Sat, 1 Apr 2017 08:18:43 +0000 (16:18 +0800)]
migration: rename max_size to threshold_size

In migration codes (especially in migration_thread()), max_size is used
in many place for the threshold value that we will start to do the final
flush and jump to the next stage to dump the whole rest things to
destination. However its name is confusing to first readers. Let's
rename it to "threshold_size" when proper and add a comment for it. No
functional change is made.

CC: Juan Quintela <quintela@redhat.com>
CC: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
7 years agomigration: set current_active_state once
Peter Xu [Sat, 1 Apr 2017 08:18:42 +0000 (16:18 +0800)]
migration: set current_active_state once

We set it right above this one. No need to set it twice.

CC: Juan Quintela <quintela@redhat.com>
CC: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
7 years agovirtio-rng: stop virtqueue while the CPU is stopped
Laurent Vivier [Wed, 12 Apr 2017 13:53:12 +0000 (15:53 +0200)]
virtio-rng: stop virtqueue while the CPU is stopped

If we modify the virtio-rng virqueue while the
vmstate is already migrated we can have some
inconsistencies between the virtqueue state and
the memory content.

To avoid this, stop the virtqueue while the CPU
is stopped.

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Amit Shah <amit@kernel.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
7 years agomigration: don't close a file descriptor while it can be in use
Laurent Vivier [Wed, 12 Apr 2017 13:53:11 +0000 (15:53 +0200)]
migration: don't close a file descriptor while it can be in use

If we close the QEMUFile descriptor in process_incoming_migration_co()
while it has been stopped by an error, the postcopy_ram_listen_thread()
can try to continue to use it. And as the memory has been freed
it is working with an invalid pointer and crashes.

Fix this by releasing the memory after having managed the error
case (which, in fact, calls exit())

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Amit Shah <amit@kernel.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
7 years agoram: Remove migration_bitmap_extend()
Juan Quintela [Wed, 22 Mar 2017 16:42:01 +0000 (17:42 +0100)]
ram: Remove migration_bitmap_extend()

We have disabled memory hotplug, so we don't need to handle
migration_bitamp there.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
7 years agomigration: Disable hotplug/unplug during migration
Juan Quintela [Wed, 22 Mar 2017 16:34:27 +0000 (17:34 +0100)]
migration: Disable hotplug/unplug during migration

Until we have reviewed what can/can't be hotplugged during migration,
disable it.  We can enable it later for the things that we know that
work.  For instance, memory hotplug during postcopy doesn't work
currently.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
--

- Fix typo.  Thanks Thomas.
- Delay migration check after we have checked that we can hotplug that
  device.
- more typos

7 years agoqdev: Move qdev_unplug() to qdev-monitor.c
Juan Quintela [Tue, 28 Mar 2017 09:22:51 +0000 (11:22 +0200)]
qdev: Move qdev_unplug() to qdev-monitor.c

It is not used by linux-user, otherwise I need to to create one stub
for migration_is_idle() on following patch.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
7 years agoqdev: Export qdev_hot_removed
Juan Quintela [Tue, 28 Mar 2017 09:22:10 +0000 (11:22 +0200)]
qdev: Export qdev_hot_removed

I need to move qdev_unplug to qdev-monitor in the following patch, and
it needs access to this variable.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
7 years agoqdev: qdev_hotplug is really a bool
Juan Quintela [Tue, 28 Mar 2017 09:08:52 +0000 (11:08 +0200)]
qdev: qdev_hotplug is really a bool

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7 years agomigration: Remove MigrationState parameter from migration_is_idle()
Juan Quintela [Wed, 22 Mar 2017 16:36:57 +0000 (17:36 +0100)]
migration: Remove MigrationState parameter from migration_is_idle()

Only user don't have a MigrationState handly.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: Use RAMBitmap type for coherence
Juan Quintela [Tue, 21 Mar 2017 17:03:49 +0000 (18:03 +0100)]
ram: Use RAMBitmap type for coherence

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: rename last_ram_offset() last_ram_pages()
Juan Quintela [Tue, 21 Mar 2017 16:44:30 +0000 (17:44 +0100)]
ram: rename last_ram_offset() last_ram_pages()

We always use it as pages anyways.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: Use ramblock and page offset instead of absolute offset
Juan Quintela [Tue, 21 Mar 2017 15:19:05 +0000 (16:19 +0100)]
ram: Use ramblock and page offset instead of absolute offset

This removes the needto pass also the absolute offset.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: Change offset field in PageSearchStatus to page
Juan Quintela [Tue, 21 Mar 2017 14:36:51 +0000 (15:36 +0100)]
ram: Change offset field in PageSearchStatus to page

We are moving everything to work on pages, not addresses.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: Remember last_page instead of last_offset
Juan Quintela [Tue, 21 Mar 2017 14:23:31 +0000 (15:23 +0100)]
ram: Remember last_page instead of last_offset

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
--

Improve comment
Fix typo

7 years agoram: Use page number instead of an address for the bitmap operations
Juan Quintela [Tue, 21 Mar 2017 14:18:05 +0000 (15:18 +0100)]
ram: Use page number instead of an address for the bitmap operations

We use an unsigned long for the page number.  Notice that our bitmaps
already got that for the index, so we have that limit.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
--

rename page to page_abs everywhere.
fix trace types for pages

7 years agoram: reorganize last_sent_block
Juan Quintela [Tue, 21 Mar 2017 10:45:01 +0000 (11:45 +0100)]
ram: reorganize last_sent_block

We were setting it far away of when we changed it.  Now everything is
done inside save_page_header.  Once there, reorganize code to pass
RAMState.  We also set CONTINUE flag in a single place.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: ram_discard_range() don't use the mis parameter
Juan Quintela [Tue, 21 Mar 2017 10:35:24 +0000 (11:35 +0100)]
ram: ram_discard_range() don't use the mis parameter

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Pass RAMBlock to bitmap_sync
Juan Quintela [Tue, 21 Mar 2017 08:35:04 +0000 (09:35 +0100)]
ram: Pass RAMBlock to bitmap_sync

We change the meaning of start to be the offset from the beggining of
the block.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: Add page-size to output in 'info migrate'
Chao Fan [Tue, 21 Mar 2017 02:22:43 +0000 (10:22 +0800)]
ram: Add page-size to output in 'info migrate'

The number of dirty pages is output in 'pages' in the command
'info migrate', so add page-size to calculate the number of dirty
pages in bytes.

Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
7 years agoram: Rename qemu_target_page_bits() to qemu_target_page_size()
Juan Quintela [Tue, 21 Mar 2017 08:09:14 +0000 (09:09 +0100)]
ram: Rename qemu_target_page_bits() to qemu_target_page_size()

It was used as a size in all cases except one.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: We don't need MigrationState parameter anymore
Juan Quintela [Mon, 20 Mar 2017 21:29:07 +0000 (22:29 +0100)]
ram: We don't need MigrationState parameter anymore

Remove it from callers and callees.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agomigration: Remove MigrationState from migration_in_postcopy
Juan Quintela [Mon, 20 Mar 2017 21:25:28 +0000 (22:25 +0100)]
migration: Remove MigrationState from migration_in_postcopy

We need to call for the migrate_get_current() in more that half of the
uses, so call that inside.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Remove compression_switch and inline its logic
Juan Quintela [Thu, 16 Mar 2017 20:29:34 +0000 (21:29 +0100)]
ram: Remove compression_switch and inline its logic

We can calculate its value, so we don't create a variable for it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
--

After Peter and Dave review, I dropped the variable and just inlined
the condition.

Fix typo

7 years agoram: Move QEMUFile into RAMState
Juan Quintela [Wed, 15 Mar 2017 10:00:51 +0000 (11:00 +0100)]
ram: Move QEMUFile into RAMState

We receive the file from save_live operations and we don't use it
until 3 or 4 levels of calls down.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: Add QEMUFile to RAMState
Juan Quintela [Wed, 15 Mar 2017 08:16:57 +0000 (09:16 +0100)]
ram: Add QEMUFile to RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: Move postcopy_requests into RAMState
Juan Quintela [Tue, 14 Mar 2017 17:41:03 +0000 (18:41 +0100)]
ram: Move postcopy_requests into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move dirty_pages_rate to RAMState
Juan Quintela [Tue, 14 Mar 2017 17:20:30 +0000 (18:20 +0100)]
ram: Move dirty_pages_rate to RAMState

Treat it like the rest of ram stats counters.  Export its value the
same way.  As an added bonus, no more MigrationState used in
migration_bitmap_sync();

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
--

Again, dave was the one reviewing it

7 years agoram: Remove dirty_bytes_rate
Juan Quintela [Tue, 14 Mar 2017 17:10:16 +0000 (18:10 +0100)]
ram: Remove dirty_bytes_rate

It can be recalculated from dirty_pages_rate.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
--

Dave was the one that reviewed it O:-)

7 years agoram: Create ram_dirty_sync_count()
Juan Quintela [Tue, 14 Mar 2017 17:01:38 +0000 (18:01 +0100)]
ram: Create ram_dirty_sync_count()

This is a ram field that was inside MigrationState.  Move it to
RAMState and make it the same that the other ram stats.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move src_page_req* to RAMState
Juan Quintela [Mon, 20 Mar 2017 21:12:40 +0000 (22:12 +0100)]
ram: Move src_page_req* to RAMState

This are the last postcopy fields still at MigrationState.  Once there
Move MigrationSrcPageRequest to ram.c and remove MigrationState
parameters where appropiate.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move last_req_rb to RAMState
Juan Quintela [Tue, 14 Mar 2017 12:48:42 +0000 (13:48 +0100)]
ram: Move last_req_rb to RAMState

It was on MigrationState when it is only used inside ram.c for
postcopy.  Problem is that we need to access it without being able to
pass it RAMState directly.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Remove ram_save_remaining
Juan Quintela [Tue, 14 Mar 2017 11:02:16 +0000 (12:02 +0100)]
ram: Remove ram_save_remaining

Just unfold it.  Move ram_bytes_remaining() with the rest of exported
functions.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Use the RAMState bytes_transferred parameter
Juan Quintela [Tue, 14 Mar 2017 09:27:31 +0000 (10:27 +0100)]
ram: Use the RAMState bytes_transferred parameter

Somewhere it was passed by reference, just use it from RAMState.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move bytes_transferred into RAMState
Juan Quintela [Mon, 13 Mar 2017 20:58:11 +0000 (21:58 +0100)]
ram: Move bytes_transferred into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move migration_bitmap_rcu into RAMState
Juan Quintela [Mon, 13 Mar 2017 20:51:55 +0000 (21:51 +0100)]
ram: Move migration_bitmap_rcu into RAMState

Once there, rename the type to be shorter.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move migration_bitmap_mutex into RAMState
Juan Quintela [Mon, 13 Mar 2017 20:38:09 +0000 (21:38 +0100)]
ram: Move migration_bitmap_mutex into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Everything was init to zero, so use memset
Juan Quintela [Mon, 13 Mar 2017 20:29:54 +0000 (21:29 +0100)]
ram: Everything was init to zero, so use memset

And then init only things that are not zero by default.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move migration_dirty_pages to RAMState
Juan Quintela [Mon, 13 Mar 2017 20:21:41 +0000 (21:21 +0100)]
ram: Move migration_dirty_pages to RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move xbzrle_overflows into RAMState
Juan Quintela [Mon, 13 Mar 2017 20:07:03 +0000 (21:07 +0100)]
ram: Move xbzrle_overflows into RAMState

Once there, remove the now unused AccountingInfo struct and var.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move xbzrle_cache_miss_rate into RAMState
Juan Quintela [Mon, 13 Mar 2017 20:04:16 +0000 (21:04 +0100)]
ram: Move xbzrle_cache_miss_rate into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move xbzrle_cache_miss into RAMState
Juan Quintela [Mon, 13 Mar 2017 20:02:08 +0000 (21:02 +0100)]
ram: Move xbzrle_cache_miss into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move xbzrle_pages into RAMState
Juan Quintela [Mon, 13 Mar 2017 19:59:32 +0000 (20:59 +0100)]
ram: Move xbzrle_pages into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
--

Comment why we need bytes and pages

7 years agoram: Move xbzrle_bytes into RAMState
Juan Quintela [Mon, 13 Mar 2017 19:57:27 +0000 (20:57 +0100)]
ram: Move xbzrle_bytes into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: Move iterations into RAMState
Juan Quintela [Mon, 13 Mar 2017 19:51:34 +0000 (20:51 +0100)]
ram: Move iterations into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Remove norm_mig_bytes_transferred
Juan Quintela [Mon, 13 Mar 2017 19:43:34 +0000 (20:43 +0100)]
ram: Remove norm_mig_bytes_transferred

Its value can be calculated by other exported.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: Move norm_pages to RAMState
Juan Quintela [Mon, 13 Mar 2017 19:40:53 +0000 (20:40 +0100)]
ram: Move norm_pages to RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Remove unused pages_skipped variable
Juan Quintela [Mon, 13 Mar 2017 19:35:54 +0000 (20:35 +0100)]
ram: Remove unused pages_skipped variable

For compatibility, we need to still send a value, but just specify it
and comment the fact.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Remove unused dup_mig_bytes_transferred()
Juan Quintela [Mon, 13 Mar 2017 19:33:01 +0000 (20:33 +0100)]
ram: Remove unused dup_mig_bytes_transferred()

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move dup_pages into RAMState
Juan Quintela [Mon, 13 Mar 2017 19:30:21 +0000 (20:30 +0100)]
ram: Move dup_pages into RAMState

Once there rename it to its actual meaning, zero_pages.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move iterations_prev into RAMState
Juan Quintela [Mon, 13 Mar 2017 18:51:13 +0000 (19:51 +0100)]
ram: Move iterations_prev into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7 years agoram: Move xbzrle_cache_miss_prev into RAMState
Juan Quintela [Mon, 13 Mar 2017 18:49:19 +0000 (19:49 +0100)]
ram: Move xbzrle_cache_miss_prev into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
7 years agoram: Change num_dirty_pages_period type to uint64_t
Juan Quintela [Tue, 28 Mar 2017 13:05:53 +0000 (15:05 +0200)]
ram: Change num_dirty_pages_period type to uint64_t

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move num_dirty_pages_period into RAMState
Juan Quintela [Tue, 28 Mar 2017 13:02:43 +0000 (15:02 +0200)]
ram: Move num_dirty_pages_period into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Change byte_xfer_{prev,now} type to uint64_t
Juan Quintela [Tue, 28 Mar 2017 12:59:54 +0000 (14:59 +0200)]
ram: Change byte_xfer_{prev,now} type to uint64_t

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move bytes_xfer_prev into RAMState
Juan Quintela [Tue, 28 Mar 2017 12:59:01 +0000 (14:59 +0200)]
ram: Move bytes_xfer_prev into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Move start time into RAMState
Juan Quintela [Mon, 13 Mar 2017 18:44:57 +0000 (19:44 +0100)]
ram: Move start time into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
--

Renamed start_time to time_last_bitmap_sync(peterx suggestion)

7 years agoram: Move bitmap_sync_count into RAMState
Juan Quintela [Mon, 13 Mar 2017 18:39:02 +0000 (19:39 +0100)]
ram: Move bitmap_sync_count into RAMState

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Add dirty_rate_high_cnt to RAMState
Juan Quintela [Mon, 13 Mar 2017 18:35:50 +0000 (19:35 +0100)]
ram: Add dirty_rate_high_cnt to RAMState

We need to add a parameter to several functions to make this work.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Create RAMState
Juan Quintela [Mon, 13 Mar 2017 18:26:29 +0000 (19:26 +0100)]
ram: Create RAMState

We create a struct where to put all the ram state

Start with the following fields:

last_seen_block, last_sent_block, last_offset, last_version and
ram_bulk_stage are globals that are really related together.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
--

Fix typo and warnings

7 years agoram: Rename block_name to rbname
Juan Quintela [Thu, 23 Mar 2017 14:11:59 +0000 (15:11 +0100)]
ram: Rename block_name to rbname

So all places are consistent on the naming of a block name parameter.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
7 years agoram: Rename flush_page_queue() to migration_page_queue_free()
Juan Quintela [Mon, 3 Apr 2017 20:06:54 +0000 (22:06 +0200)]
ram: Rename flush_page_queue() to migration_page_queue_free()

It reflects better what it does.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
7 years agoram: Update all functions comments
Juan Quintela [Thu, 23 Mar 2017 14:06:39 +0000 (15:06 +0100)]
ram: Update all functions comments

Added doc comments for existing functions comment and rewrite them in
a common style.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
--

Fix Peter Xu comments
Improve postcopy comments as per reviews.

7 years agoDrop QEMU_GNUC_PREREQ() checks for gcc older than 4.1
Peter Maydell [Thu, 20 Apr 2017 17:30:21 +0000 (18:30 +0100)]
Drop QEMU_GNUC_PREREQ() checks for gcc older than 4.1

We already require gcc 4.1 or newer (for the atomic
support), so the fallback codepaths for older gcc
versions than that are now dead code and we can
just delete them.

NB: clang reports itself as gcc 4.2 (regardless of
clang version), so clang won't be using the fallbacks
either.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
7 years agoMerge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20170420' into...
Peter Maydell [Thu, 20 Apr 2017 16:41:34 +0000 (17:41 +0100)]
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20170420' into staging

target-arm queue:
 * implement M profile exception return properly
 * cadence GEM: fix multiqueue handling bugs
 * pxa2xx.c: QOMify a device
 * arm/kvm: Remove trailing newlines from error_report()
 * stellaris: Don't hw_error() on bad register accesses
 * Add assertion about FSC format for syndrome registers
 * Move excnames[] array into arm_log_exceptions()
 * exynos: minor code cleanups
 * hw/arm/boot: take Linux/arm64 TEXT_OFFSET header field into account
 * Fix APSR writes via M profile MSR

# gpg: Signature made Thu 20 Apr 2017 17:39:35 BST
# gpg:                using RSA key 0x3C2525ED14360CDE
# gpg: Good signature from "Peter Maydell <peter.maydell@linaro.org>"
# gpg:                 aka "Peter Maydell <pmaydell@gmail.com>"
# gpg:                 aka "Peter Maydell <pmaydell@chiark.greenend.org.uk>"
# Primary key fingerprint: E1A5 C593 CD41 9DE2 8E83  15CF 3C25 25ED 1436 0CDE

* remotes/pmaydell/tags/pull-target-arm-20170420: (24 commits)
  arm: Remove workarounds for old M-profile exception return implementation
  arm: Implement M profile exception return properly
  arm: Track M profile handler mode state in TB flags
  arm: Abstract out "are we singlestepping" test to utility function
  arm: Move condition-failed codepath generation out of if()
  arm: Move gen_set_condexec() and gen_set_pc_im() up in the file
  arm: Factor out "generate right kind of step exception"
  arm: Thumb shift operations should not permit interworking branches
  arm: Don't implement BXJ on M-profile CPUs
  xlnx-zynqmp: Set the Cadence GEM revision
  cadence_gem: Make the revision a property
  cadence_gem: Correct the interupt logic
  cadence_gem: Correct the multi-queue can rx logic
  cadence_gem: Read the correct queue descriptor
  hw/arm: Qomify pxa2xx.c
  arm/kvm: Remove trailing newlines from error_report()
  stellaris: Don't hw_error() on bad register accesses
  target/arm: Add assertion about FSC format for syndrome registers
  arm: Move excnames[] array into arm_log_exceptions()
  target/arm: Add missing entries to excnames[] for log strings
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoarm: Remove workarounds for old M-profile exception return implementation
Peter Maydell [Thu, 20 Apr 2017 16:32:31 +0000 (17:32 +0100)]
arm: Remove workarounds for old M-profile exception return implementation

Now that we've rewritten M-profile exception return so that the magic
PC values are not visible to other parts of QEMU, we can delete the
special casing of them elsewhere.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-id: 1491844419-12485-10-git-send-email-peter.maydell@linaro.org

7 years agoarm: Implement M profile exception return properly
Peter Maydell [Thu, 20 Apr 2017 16:32:31 +0000 (17:32 +0100)]
arm: Implement M profile exception return properly

On M profile, return from exceptions happen when code in Handler mode
executes one of the following function call return instructions:
 * POP or LDM which loads the PC
 * LDR to PC
 * BX register
and the new PC value is 0xFFxxxxxx.

QEMU tries to implement this by not treating the instruction
specially but then catching the attempt to execute from the magic
address value.  This is not ideal, because:
 * there are guest visible differences from the architecturally
   specified behaviour (for instance jumping to 0xFFxxxxxx via a
   different instruction should not cause an exception return but it
   will in the QEMU implementation)
 * we have to account for it in various places (like refusing to take
   an interrupt if the PC is at a magic value, and making sure that
   the MPU doesn't deny execution at the magic value addresses)

Drop these hacks, and instead implement exception return the way the
architecture specifies -- by having the relevant instructions check
for the magic value and raise the 'do an exception return' QEMU
internal exception immediately.

The effect on the generated code is minor:

 bx lr, old code (and new code for Thread mode):
  TCG:
   mov_i32 tmp5,r14
   movi_i32 tmp6,$0xfffffffffffffffe
   and_i32 pc,tmp5,tmp6
   movi_i32 tmp6,$0x1
   and_i32 tmp5,tmp5,tmp6
   st_i32 tmp5,env,$0x218
   exit_tb $0x0
   set_label $L0
   exit_tb $0x7f2aabd61993
  x86_64 generated code:
   0x7f2aabe87019:  mov    %ebx,%ebp
   0x7f2aabe8701b:  and    $0xfffffffffffffffe,%ebp
   0x7f2aabe8701e:  mov    %ebp,0x3c(%r14)
   0x7f2aabe87022:  and    $0x1,%ebx
   0x7f2aabe87025:  mov    %ebx,0x218(%r14)
   0x7f2aabe8702c:  xor    %eax,%eax
   0x7f2aabe8702e:  jmpq   0x7f2aabe7c016

 bx lr, new code when in Handler mode:
  TCG:
   mov_i32 tmp5,r14
   movi_i32 tmp6,$0xfffffffffffffffe
   and_i32 pc,tmp5,tmp6
   movi_i32 tmp6,$0x1
   and_i32 tmp5,tmp5,tmp6
   st_i32 tmp5,env,$0x218
   movi_i32 tmp5,$0xffffffffff000000
   brcond_i32 pc,tmp5,geu,$L1
   exit_tb $0x0
   set_label $L1
   movi_i32 tmp5,$0x8
   call exception_internal,$0x0,$0,env,tmp5
  x86_64 generated code:
   0x7fe8fa1264e3:  mov    %ebp,%ebx
   0x7fe8fa1264e5:  and    $0xfffffffffffffffe,%ebx
   0x7fe8fa1264e8:  mov    %ebx,0x3c(%r14)
   0x7fe8fa1264ec:  and    $0x1,%ebp
   0x7fe8fa1264ef:  mov    %ebp,0x218(%r14)
   0x7fe8fa1264f6:  cmp    $0xff000000,%ebx
   0x7fe8fa1264fc:  jae    0x7fe8fa126509
   0x7fe8fa126502:  xor    %eax,%eax
   0x7fe8fa126504:  jmpq   0x7fe8fa122016
   0x7fe8fa126509:  mov    %r14,%rdi
   0x7fe8fa12650c:  mov    $0x8,%esi
   0x7fe8fa126511:  mov    $0x56095dbeccf5,%r10
   0x7fe8fa12651b:  callq  *%r10

which is a difference of one cmp/branch-not-taken. This will
be lost in the noise of having to exit generated code and
look up the next TB anyway.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1491844419-12485-9-git-send-email-peter.maydell@linaro.org

7 years agoarm: Track M profile handler mode state in TB flags
Peter Maydell [Thu, 20 Apr 2017 16:32:31 +0000 (17:32 +0100)]
arm: Track M profile handler mode state in TB flags

For M profile exception-return handling we'd like to generate different
code for some instructions depending on whether we are in Handler
mode or Thread mode. This isn't the same as "are we privileged
or user", so we need an extra bit in the TB flags to distinguish.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1491844419-12485-8-git-send-email-peter.maydell@linaro.org

7 years agoarm: Abstract out "are we singlestepping" test to utility function
Peter Maydell [Thu, 20 Apr 2017 16:32:30 +0000 (17:32 +0100)]
arm: Abstract out "are we singlestepping" test to utility function

We now test for "are we singlestepping" in several places and
it's not a trivial check because we need to care about both
architectural singlestep and QEMU gdbstub singlestep. We're
also about to add another place that needs to make this check,
so pull the condition out into a function.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1491844419-12485-7-git-send-email-peter.maydell@linaro.org

7 years agoarm: Move condition-failed codepath generation out of if()
Peter Maydell [Thu, 20 Apr 2017 16:32:30 +0000 (17:32 +0100)]
arm: Move condition-failed codepath generation out of if()

Move the code to generate the "condition failed" instruction
codepath out of the if (singlestepping) {} else {}. This
will allow adding support for handling a new is_jmp type
which can't be neatly split into "singlestepping case"
versus "not singlestepping case".

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-id: 1491844419-12485-6-git-send-email-peter.maydell@linaro.org

7 years agoarm: Move gen_set_condexec() and gen_set_pc_im() up in the file
Peter Maydell [Thu, 20 Apr 2017 16:32:30 +0000 (17:32 +0100)]
arm: Move gen_set_condexec() and gen_set_pc_im() up in the file

Move the utility routines gen_set_condexec() and gen_set_pc_im()
up in the file, as we will want to use them from a function
placed earlier in the file than their current location.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-id: 1491844419-12485-5-git-send-email-peter.maydell@linaro.org

7 years agoarm: Factor out "generate right kind of step exception"
Peter Maydell [Thu, 20 Apr 2017 16:32:30 +0000 (17:32 +0100)]
arm: Factor out "generate right kind of step exception"

We currently have two places that do:
            if (dc->ss_active) {
                gen_step_complete_exception(dc);
            } else {
                gen_exception_internal(EXCP_DEBUG);
            }

Factor this out into its own function, as we're about to add
a third place that needs the same logic.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-id: 1491844419-12485-4-git-send-email-peter.maydell@linaro.org

7 years agoarm: Thumb shift operations should not permit interworking branches
Peter Maydell [Thu, 20 Apr 2017 16:32:30 +0000 (17:32 +0100)]
arm: Thumb shift operations should not permit interworking branches

In Thumb mode, the only instructions which can cause an interworking
branch by writing the PC are BLX, BX, BXJ, LDR, POP and LDM. Unlike
ARM mode, data processing instructions which target the PC do not
cause interworking branches.

When we added support for doing interworking branches on writes to
PC from data processing instructions in commit 21aeb3430ce7ba, we
accidentally changed a Thumb instruction to have interworking
branch behaviour for writes to PC. (MOV, MOVS register-shifted
register, encoding T2; this is the standard encoding for
LSL/LSR/ASR/ROR (register).)

For this encoding, behaviour with Rd == R15 is specified as
UNPREDICTABLE, so allowing an interworking branch is within
spec, but it's confusing and differs from our handling of this
class of UNPREDICTABLE for other Thumb ALU operations. Make
it perform a simple (non-interworking) branch like the others.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1491844419-12485-3-git-send-email-peter.maydell@linaro.org

7 years agoarm: Don't implement BXJ on M-profile CPUs
Peter Maydell [Thu, 20 Apr 2017 16:32:30 +0000 (17:32 +0100)]
arm: Don't implement BXJ on M-profile CPUs

For M-profile CPUs, the BXJ instruction does not exist at all, and
the encoding should always UNDEF. We were accidentally implementing
it to behave like A-profile BXJ; correct the error.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Message-id: 1491844419-12485-2-git-send-email-peter.maydell@linaro.org

7 years agoxlnx-zynqmp: Set the Cadence GEM revision
Alistair Francis [Thu, 20 Apr 2017 16:32:30 +0000 (17:32 +0100)]
xlnx-zynqmp: Set the Cadence GEM revision

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 026dbe01a1d42619eee30ce3f2079741bf04bc73.1491947224.git.alistair.francis@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agocadence_gem: Make the revision a property
Alistair Francis [Thu, 20 Apr 2017 16:32:29 +0000 (17:32 +0100)]
cadence_gem: Make the revision a property

Expose the Cadence GEM revision as a property.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 541324373cf87b50f8be0439a0cb89f5028b016f.1491947224.git.alistair.francis@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agocadence_gem: Correct the interupt logic
Alistair Francis [Thu, 20 Apr 2017 16:32:29 +0000 (17:32 +0100)]
cadence_gem: Correct the interupt logic

This patch fixes two mistakes in the interrupt logic.

First we only trigger single-queue or multi-queue interrupts if the status
register is set. This logic was already used for non multi-queue interrupts
but it also applies to multi-queue interrupts.

Secondly we need to lower the interrupts if the ISR isn't set. As part
of this we can remove the other interrupt lowering logic and consolidate
it inside gem_update_int_status().

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Message-id: 438bcc014f8f8a2f8f68f322cb6a53f4c04688c2.1491947224.git.alistair.francis@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7 years agocadence_gem: Correct the multi-queue can rx logic
Alistair Francis [Thu, 20 Apr 2017 16:32:29 +0000 (17:32 +0100)]
cadence_gem: Correct the multi-queue can rx logic

Correct the buffer descriptor busy logic to work correctly when using
multiple queues.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Message-id: 8a7e8059984e27d46a276a66299d035a0afd280f.1491947224.git.alistair.francis@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
7 years agocadence_gem: Read the correct queue descriptor
Alistair Francis [Thu, 20 Apr 2017 16:32:29 +0000 (17:32 +0100)]
cadence_gem: Read the correct queue descriptor

Read the correct descriptor instead of hardcoding the first (q=0).

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 988b183dcf951856d8b3379f7e911ec95233bbf4.1491947224.git.alistair.francis@xilinx.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agohw/arm: Qomify pxa2xx.c
Suramya Shah [Thu, 20 Apr 2017 16:32:29 +0000 (17:32 +0100)]
hw/arm: Qomify pxa2xx.c

Signed-off-by: Suramya Shah <shah.suramya@gmail.com>
Message-id: 20170415180316.2694-1-shah.suramya@gmail.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoarm/kvm: Remove trailing newlines from error_report()
Ishani Chugh [Thu, 20 Apr 2017 16:32:29 +0000 (17:32 +0100)]
arm/kvm: Remove trailing newlines from error_report()

Signed-off-by: Ishani Chugh <chugh.ishani@research.iiit.ac.in>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 1491629987-6826-1-git-send-email-chugh.ishani@research.iiit.ac.in
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agostellaris: Don't hw_error() on bad register accesses
Peter Maydell [Thu, 20 Apr 2017 16:32:29 +0000 (17:32 +0100)]
stellaris: Don't hw_error() on bad register accesses

Current recommended style is to log a guest error on bad register
accesses, not kill the whole system with hw_error().  Change the
hw_error() calls to log as LOG_GUEST_ERROR or LOG_UNIMP or use
g_assert_not_reached() as appropriate.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1491486314-25823-1-git-send-email-peter.maydell@linaro.org

7 years agotarget/arm: Add assertion about FSC format for syndrome registers
Peter Maydell [Thu, 20 Apr 2017 16:32:29 +0000 (17:32 +0100)]
target/arm: Add assertion about FSC format for syndrome registers

In tlb_fill() we construct a syndrome register value from a
fault status register value which is filled in by arm_tlb_fill().
arm_tlb_fill() returns FSR values which might be in the format
used with short-format page descriptors, or the format used
with long-format (LPAE) descriptors. The syndrome register
always uses LPAE-format FSR status codes.

It isn't actually possible to end up delivering a syndrome
register value to the guest for a fault which is reported
with a short-format FSR (that kind of stage 1 fault will only
happen for an AArch32 translation regime which doesn't have
a syndrome register, and can never be redirected to an AArch64
or Hyp exception level). Add an assertion which checks this,
and adjust the code so that we construct a syndrome with
an invalid status code, rather than allowing set bits in
the FSR input to randomly corrupt other fields in the syndrome.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1491486152-24304-1-git-send-email-peter.maydell@linaro.org

7 years agoarm: Move excnames[] array into arm_log_exceptions()
Peter Maydell [Thu, 20 Apr 2017 16:32:28 +0000 (17:32 +0100)]
arm: Move excnames[] array into arm_log_exceptions()

The excnames[] array is defined in internals.h because we used
to use it from two different source files for handling logging
of AArch32 and AArch64 exception entry. Refactoring means that
it's now used only in arm_log_exception() in helper.c, so move
the array into that function.

Suggested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1491821097-5647-1-git-send-email-peter.maydell@linaro.org

7 years agotarget/arm: Add missing entries to excnames[] for log strings
Peter Maydell [Thu, 20 Apr 2017 16:32:28 +0000 (17:32 +0100)]
target/arm: Add missing entries to excnames[] for log strings

Recent changes have added new EXCP_ values to ARM but forgot
to update the excnames[] array which is used to provide
human-readable strings when printing information about the
exception for debug logging. Add the missing entries, and
add a comment to the list of #defines to help avoid the mistake
being repeated in future.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1491486340-25988-1-git-send-email-peter.maydell@linaro.org

7 years agohw/misc/exynos4210_pmu: Reorder local variables for readability
Krzysztof Kozlowski [Thu, 20 Apr 2017 16:32:28 +0000 (17:32 +0100)]
hw/misc/exynos4210_pmu: Reorder local variables for readability

Short declaration of 'i' was in the middle of declarations with
assignments.  Make it a little bit more readable.  Additionally switch
from "unsigned" to "unsigned int" as this pattern is more widely used.
No functional change.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20170313184750.429-4-krzk@kernel.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agohw/char/exynos4210_uart: Constify static array and few arguments
Krzysztof Kozlowski [Thu, 20 Apr 2017 16:32:28 +0000 (17:32 +0100)]
hw/char/exynos4210_uart: Constify static array and few arguments

The static array exynos4210_uart_regs with register values is not
modified so it can be made const.

Few other functions accept driver or uart state as an argument but they
do not change it and do not cast it so this can be made const for code
safeness.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Message-id: 20170313184750.429-3-krzk@kernel.org
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agohw/arm/exynos: Convert fprintf to qemu_log_mask/error_report
Krzysztof Kozlowski [Thu, 20 Apr 2017 16:32:28 +0000 (17:32 +0100)]
hw/arm/exynos: Convert fprintf to qemu_log_mask/error_report

qemu_log_mask() and error_report() are preferred over fprintf() for
logging errors.  Also remove square brackets [] and additional new line
characters in printed messages.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 20170313184750.429-2-krzk@kernel.org
[PMM: wrapped long line]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agohw/arm/boot: take Linux/arm64 TEXT_OFFSET header field into account
Ard Biesheuvel [Thu, 20 Apr 2017 16:32:28 +0000 (17:32 +0100)]
hw/arm/boot: take Linux/arm64 TEXT_OFFSET header field into account

The arm64 boot protocol stipulates that the kernel must be loaded
TEXT_OFFSET bytes beyond a 2 MB aligned base address, where TEXT_OFFSET
could be any 4 KB multiple between 0 and 2 MB, and whose value can be
found in the header of the Image file.

So after attempts to load the arm64 kernel image as an ELF file or as a
U-Boot image have failed (both of which have their own way of specifying
the load offset), try to determine the TEXT_OFFSET from the image after
loading it but before mapping it as a ROM mapping into the guest address
space.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1489414630-21609-1-git-send-email-ard.biesheuvel@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoOpen 2.10 development tree
Peter Maydell [Thu, 20 Apr 2017 14:42:31 +0000 (15:42 +0100)]
Open 2.10 development tree

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoUpdate version for v2.9.0 release
Peter Maydell [Thu, 20 Apr 2017 14:31:34 +0000 (15:31 +0100)]
Update version for v2.9.0 release

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoUpdate version for v2.9.0-rc5 release
Peter Maydell [Tue, 18 Apr 2017 16:13:50 +0000 (17:13 +0100)]
Update version for v2.9.0-rc5 release

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoMerge remote-tracking branch 'remotes/famz/tags/block-pull-request' into staging
Peter Maydell [Tue, 18 Apr 2017 15:18:15 +0000 (16:18 +0100)]
Merge remote-tracking branch 'remotes/famz/tags/block-pull-request' into staging

# gpg: Signature made Tue 18 Apr 2017 15:58:32 BST
# gpg:                using RSA key 0xCA35624C6A9171C6
# gpg: Good signature from "Fam Zheng <famz@redhat.com>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 5003 7CB7 9706 0F76 F021  AD56 CA35 624C 6A91 71C6

* remotes/famz/tags/block-pull-request:
  block: Drain BH in bdrv_drained_begin
  block: Walk bs->children carefully in bdrv_drain_recurse

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoblock: Drain BH in bdrv_drained_begin
Fam Zheng [Tue, 18 Apr 2017 14:30:44 +0000 (22:30 +0800)]
block: Drain BH in bdrv_drained_begin

During block job completion, nothing is preventing
block_job_defer_to_main_loop_bh from being called in a nested
aio_poll(), which is a trouble, such as in this code path:

    qmp_block_commit
      commit_active_start
        bdrv_reopen
          bdrv_reopen_multiple
            bdrv_reopen_prepare
              bdrv_flush
                aio_poll
                  aio_bh_poll
                    aio_bh_call
                      block_job_defer_to_main_loop_bh
                        stream_complete
                          bdrv_reopen

block_job_defer_to_main_loop_bh is the last step of the stream job,
which should have been "paused" by the bdrv_drained_begin/end in
bdrv_reopen_multiple, but it is not done because it's in the form of a
main loop BH.

Similar to why block jobs should be paused between drained_begin and
drained_end, BHs they schedule must be excluded as well.  To achieve
this, this patch forces draining the BH in BDRV_POLL_WHILE.

As a side effect this fixes a hang in block_job_detach_aio_context
during system_reset when a block job is ready:

    #0  0x0000555555aa79f3 in bdrv_drain_recurse
    #1  0x0000555555aa825d in bdrv_drained_begin
    #2  0x0000555555aa8449 in bdrv_drain
    #3  0x0000555555a9c356 in blk_drain
    #4  0x0000555555aa3cfd in mirror_drain
    #5  0x0000555555a66e11 in block_job_detach_aio_context
    #6  0x0000555555a62f4d in bdrv_detach_aio_context
    #7  0x0000555555a63116 in bdrv_set_aio_context
    #8  0x0000555555a9d326 in blk_set_aio_context
    #9  0x00005555557e38da in virtio_blk_data_plane_stop
    #10 0x00005555559f9d5f in virtio_bus_stop_ioeventfd
    #11 0x00005555559fa49b in virtio_bus_stop_ioeventfd
    #12 0x00005555559f6a18 in virtio_pci_stop_ioeventfd
    #13 0x00005555559f6a18 in virtio_pci_reset
    #14 0x00005555559139a9 in qdev_reset_one
    #15 0x0000555555916738 in qbus_walk_children
    #16 0x0000555555913318 in qdev_walk_children
    #17 0x0000555555916738 in qbus_walk_children
    #18 0x00005555559168ca in qemu_devices_reset
    #19 0x000055555581fcbb in pc_machine_reset
    #20 0x00005555558a4d96 in qemu_system_reset
    #21 0x000055555577157a in main_loop_should_exit
    #22 0x000055555577157a in main_loop
    #23 0x000055555577157a in main

The rationale is that the loop in block_job_detach_aio_context cannot
make any progress in pausing/completing the job, because bs->in_flight
is 0, so bdrv_drain doesn't process the block_job_defer_to_main_loop
BH. With this patch, it does.

Reported-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170418143044.12187-3-famz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Tested-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
7 years agoblock: Walk bs->children carefully in bdrv_drain_recurse
Fam Zheng [Tue, 18 Apr 2017 14:30:43 +0000 (22:30 +0800)]
block: Walk bs->children carefully in bdrv_drain_recurse

The recursive bdrv_drain_recurse may run a block job completion BH that
drops nodes. The coming changes will make that more likely and use-after-free
would happen without this patch

Stash the bs pointer and use bdrv_ref/bdrv_unref in addition to
QLIST_FOREACH_SAFE to prevent such a case from happening.

Since bdrv_unref accesses global state that is not protected by the AioContext
lock, we cannot use bdrv_ref/bdrv_unref unconditionally.  Fortunately the
protection is not needed in IOThread because only main loop can modify a graph
with the AioContext lock held.

Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170418143044.12187-2-famz@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Tested-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
7 years ago9pfs: local: set the path of the export root to "."
Greg Kurz [Mon, 17 Apr 2017 08:53:23 +0000 (10:53 +0200)]
9pfs: local: set the path of the export root to "."

The local backend was recently converted to using "at*()" syscalls in order
to ensure all accesses happen below the shared directory. This requires that
we only pass relative paths, otherwise the dirfd argument to the "at*()"
syscalls is ignored and the path is treated as an absolute path in the host.
This is actually the case for paths in all fids, with the notable exception
of the root fid, whose path is "/". This causes the following backend ops to
act on the "/" directory of the host instead of the virtfs shared directory
when the export root is involved:
- lstat
- chmod
- chown
- utimensat

ie, chmod /9p_mount_point in the guest will be converted to chmod / in the
host for example. This could cause security issues with a privileged QEMU.

All "*at()" syscalls are being passed an open file descriptor. In the case
of the export root, this file descriptor points to the path in the host that
was passed to -fsdev.

The fix is thus as simple as changing the path of the export root fid to be
"." instead of "/".

This is CVE-2017-7471.

Cc: qemu-stable@nongnu.org
Reported-by: Léo Gaspard <leo@gaspard.io>
Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoUpdate version for v2.9.0-rc4 release
Peter Maydell [Tue, 11 Apr 2017 16:18:03 +0000 (17:18 +0100)]
Update version for v2.9.0-rc4 release

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agoblock/io: Comment out permission assertions
Max Reitz [Tue, 11 Apr 2017 14:50:50 +0000 (16:50 +0200)]
block/io: Comment out permission assertions

In case of block migration, there may be writes to BlockBackends that do
not have the write permission taken. Before this issue is fixed (which
is not going to happen in 2.9), we therefore cannot assert that this is
the case.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Tested-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20170411145050.31290-1-mreitz@redhat.com
Tested-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
7 years agosheepdog: Fix crash in co_read_response()
Kevin Wolf [Tue, 11 Apr 2017 14:08:53 +0000 (16:08 +0200)]
sheepdog: Fix crash in co_read_response()

This fixes a regression introduced in commit 9d456654.

aio_co_wake() can only be used to reenter a coroutine that was already
previously entered, otherwise co->ctx is uninitialised and we access
garbage. Using it immediately after qemu_coroutine_create() like in
co_read_response() is wrong and causes segfaults.

Replace the call with aio_co_enter(), which gets an explicit AioContext
parameter and works even for new coroutines.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Tested-by: Kashyap Chamarthy <kchamart@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 1491919733-21065-1-git-send-email-kwolf@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>