Commit Graph

4471 Commits

Author SHA1 Message Date
Lioncash
a81439c7ca
exec: Drop unnecessary code for unicorn
The dirty memory code isn't strictly necessary
2018-03-12 10:11:46 -04:00
Lioncash
b28c64ed34
tcg/i386: Amend bad merge 2018-03-12 10:11:03 -04:00
Richard Henderson
a16ee979fc
tcg/i386: Always use TZCNT when available
I think this is cleaner than sometimes using BSF.

Backports commit 39f099ec9d6d420b6fe6f7f4f8ed80ae29c65ff2 from qemu
2018-03-12 05:11:42 -04:00
Lioncash
8e161bb723
target/arm: Use the any cpu model instead of cortex-a57
The Cortex-A57 doesn't allow use of v8.1+ architecture instructions
2018-03-12 03:42:57 -04:00
Alexey Kardashevskiy
b90333a531
memory: Share special empty FlatView
This shares an cached empty FlatView among address spaces. The empty
FV is used every time when a root MR renders into a FV without memory
sections which happens when MR or its children are not enabled or
zero-sized. The empty_view is not NULL to keep the rest of memory
API intact; it also has a dispatch tree for the same reason.

On POWER8 with 255 CPUs, 255 virtio-net, 40 PCI bridges guest this halves
the amount of FlatView's in use (557 -> 260) and dispatch tables
(~800000 -> ~370000). In an unrelated experiment with 112 non-virtio
devices on x86 ("-M pc"), only 4 FlatViews are alive, and about ~2000
are created at startup.

Backports commit 092aa2fc65b7a35121616aad8f39d47b8f921618 from qemu
2018-03-11 22:34:28 -04:00
Paolo Bonzini
20b1bd767f
memory: seek FlatView sharing candidates among children subregions
A container can be used instead of an alias to allow switching between
multiple subregions. In this case we cannot directly share the
subregions (since they only belong to a single parent), but if the
subregions are aliases we can in turn walk those.

This is not enough to remove all source of quadratic FlatView creation,
but it enables sharing of the PCI bus master FlatViews (and their
AddressSpaceDispatch structures) across all PCI devices. For 112
virtio-net-pci devices, boot time is reduced from 25 to 10 seconds and
memory consumption from 1.4 to 1 G.

Backports commit e673ba9af9bf8fd8e0f44025ac738b8285b3ed27 from qemu
2018-03-11 22:19:55 -04:00
Alexey Kardashevskiy
7eab335b2e
memory: Create FlatView directly
This avoids usual memory_region_transaction_commit() which rebuilds
all FVs.

On POWER8 with 255 CPUs, 255 virtio-net, 40 PCI bridges guest this brings
down the boot time from 25s to 20s and reduces the amount of temporary FVs
allocated during machine constructon (~800000 -> ~640000) and amount of
temporary dispatch trees (~370000 -> ~300000), the total memory footprint
goes down (18G -> 17G).

Backports commit 202fc01b05572ecb258fdf4c5bd56cf6de8140c7 from qemu
2018-03-11 22:17:48 -04:00
Alexey Kardashevskiy
1fd8b64072
memory: Get rid of address_space_init_shareable
Since FlatViews are shared now and ASes not, this gets rid of
address_space_init_shareable().

This should cause no behavioural change.

Backports commit b516572f31c0ea0937cd9d11d9bd72dd83809886 from qemu
2018-03-11 22:12:38 -04:00
Alexey Kardashevskiy
34709f52ee
memory: Do not allocate FlatView in address_space_init
This creates a new AS object without any FlatView as
memory_region_transaction_commit() may want to reuse the empty FV.

Backports commit 67ace39b253ed5ae465275bc870f7e495547658b from qemu
2018-03-11 22:07:36 -04:00
Alexey Kardashevskiy
f2c72dc278
memory: Share FlatView's and dispatch trees between address spaces
This allows sharing flat views between address spaces (AS) when
the same root memory region is used when creating a new address space.
This is done by walking through all ASes and caching one FlatView per
a physical root MR (i.e. not aliased).

This removes search for duplicates from address_space_init_shareable() as
FlatViews are shared elsewhere and keeping as::ref_count correct seems
an unnecessary and useless complication.

This should cause no change and memory use or boot time yet.

Backports commit 967dc9b1194a9281124b2e1ce67b6c3359a2138f from qemu
2018-03-11 22:05:44 -04:00
Alexey Kardashevskiy
0d9fe8e20c
memory: Alloc dispatch tree where topology is generared
This is to make next patches simpler.

Backports commit 9bf561e36cf8fed9565011a19ba9ea0100e1811e from qemu
2018-03-11 21:43:23 -04:00
Alexey Kardashevskiy
037d039a4d
memory: Store physical root MR in FlatView
Address spaces get to keep a root MR (alias or not) but FlatView stores
the actual MR as this is going to be used later on to decide whether to
share a particular FlatView or not.

Backports commit 89c177bbdd6cf8e50b3fd4831697d50e195d6432 from qemu
2018-03-11 21:39:37 -04:00
Alexey Kardashevskiy
d9bc1bcc8c
memory: Rename mem_begin/mem_commit/mem_add helpers
This renames some helpers to reflect better what they do.

This should cause no behavioural change.

Backports commit 8629d3fcb77e9775e44d9051bad0fb5187925eae from qemu
2018-03-11 21:36:50 -04:00
Alexey Kardashevskiy
489abbbd8b
memory: Cleanup after switching to FlatView
We store AddressSpaceDispatch* in FlatView anyway so there is no need
to carry it from mem_add() to register_subpage/register_multipage.

This should cause no behavioural change.

Backports commit 9950322a593ff900a860fb52938159461798a831 from qemu
2018-03-11 21:27:51 -04:00
Alexey Kardashevskiy
aa2b76b4e8
memory: Switch memory from using AddressSpace to FlatView
FlatView's will be shared between AddressSpace's and subpage_t
and MemoryRegionSection cannot store AS anymore, hence this change.

In particular, for:

typedef struct subpage_t {
MemoryRegion iomem;
- AddressSpace *as;
+ FlatView *fv;
hwaddr base;
uint16_t sub_section[];
} subpage_t;

struct MemoryRegionSection {
MemoryRegion *mr;
- AddressSpace *address_space;
+ FlatView *fv;
hwaddr offset_within_region;
Int128 size;
hwaddr offset_within_address_space;
bool readonly;
};

This should cause no behavioural change.

Backports commit 166206845f7fd75e720e6feea0bb01957c8da07f from qemu
2018-03-11 21:21:37 -04:00
Alexey Kardashevskiy
06b53d8e40
memory: Remove AddressSpace pointer from AddressSpaceDispatch
AS in ASD is only used to pass AS from mem_begin() to register_subpage()
to store it in MemoryRegionSection, we can do this directly now.

This should cause no behavioural change.

Backports commit c7752523787dc148f5ee976162e80ab594c386a1 from qemu
2018-03-11 20:45:43 -04:00
Lioncash
1591f208c0
memory: Move AddressSpaceDispatch from AddressSpace to FlatView
As we are going to share FlatView's between AddressSpace's,
and AddressSpaceDispatch is a structure to perform quick lookup
in FlatView, this moves ASD to FlatView.

After previosly open coded ASD rendering, we can also remove
as->next_dispatch as the new FlatView pointer is stored
on a stack and set to an AS atomically.

flatview_destroy() is executed under RCU instead of
address_space_dispatch_free() now.

This makes mem_begin/mem_commit to work with ASD and mem_add with FV
as later on mem_add will be taking FV as an argument anyway.

This should cause no behavioural change.

Backports commit 66a6df1dc6d5b28cc3e65db0d71683fbdddc6b62 from qemu
2018-03-11 20:40:24 -04:00
Lioncash
cc8fd90124
unicorn_common: Eliminate memory leaks 2018-03-11 20:20:29 -04:00
Marc-André Lureau
aee9f7327f
machine: use class base init generated name
machine_class_base_init() member name is allocated by
machine_class_base_init(), but not freed by
machine_class_finalize().  Simply freeing there doesn't work,
because DEFINE_PC_MACHINE() overwrites it with a literal string.

Fix DEFINE_PC_MACHINE() not to overwrite it, and add the missing
free to machine_class_finalize().

Backports commit 8ea753718b2d1a42e9ce7b8db9f5e4e1f330e827 from qemu
2018-03-11 16:54:40 -04:00
Lioncash
8648b1df4f
include/elf: Update elf.h to commit f71a8eaffba3271cf7cdad95572f6996f7523a5b 2018-03-11 15:34:35 -04:00
Eduardo Habkost
7c7bb4c6d1
machine: Eliminate QEMUMachine and qemu_register_machine()
The struct is not used anymore and can be eliminated.

Backports commit 3b53e45f43825caaaf4fad6a5b85ce6a9949ff02 from qemu
2018-03-11 15:22:25 -04:00
Andreas Färber
048aaf05ca
Revert use of DEFINE_MACHINE() for registrations of multiple machines
The script used for converting from QEMUMachine had used one
DEFINE_MACHINE() per machine registered. In cases where multiple
machines are registered from one source file, avoid the excessive
generation of module init functions by reverting this unrolling.

Backports commit 8a661aea0e7f6e776c6ebc9abe339a85b34fea1d from qemu
2018-03-11 15:17:17 -04:00
Eduardo Habkost
a7f59d7771
Use DEFINE_MACHINE() to register all machines
Convert all machines to use DEFINE_MACHINE() instead of QEMUMachine
automatically using a script.

Backports commit e264d29de28c5b0be3d063307ce9fb613b427cc3 from qemu
2018-03-11 15:12:46 -04:00
Eduardo Habkost
426b961644
machine: DEFINE_MACHINE() macro
The macro will allow easy registration of a TYPE_MACHINE subclass, using
only the machine name and a MachineClass initialization function as
parameter.

Backports commit ed0b6de343448d1014b53bcf541041373322fa1c from qemu
2018-03-11 14:42:12 -04:00
Eduardo Habkost
46e1c5482b
machine: Set MachineClass::name automatically
Now all TYPE_MACHINE subclasses use MACHINE_TYPE_NAME to generate the
class name. So instead of requiring each subclass to set
MachineClass::name manually, we can now set it automatically at the
TYPE_MACHINE class_base_init() function.

Backports commit 98cec76a7076c4a38e16f1a9de170a7942b3be54 from qemu
2018-03-11 14:38:58 -04:00
Eduardo Habkost
0261df973b
machine: Ensure all TYPE_MACHINE subclasses have the right suffix
Now that all non-abstract TYPE_MACHINE subclasses have the -machine
suffix, add an assert to ensure this will be always true.

Backports commit dcb3d601115eed77aef543fe3a920adc17544e06 from qemu
2018-03-11 14:30:38 -04:00
Eduardo Habkost
1b2aee0a86
arm: Rename virt machine class to use MACHINE_TYPE_NAME
Machine class names should use the "-machine" suffix to allow
class-name-based machine class lookup to work. Rename the arm virt
machine class using the MACHINE_TYPE_NAME macro.

Backports commit 64d3459c8586c8821970cbc99450340278507cfe from qemu
2018-03-11 14:20:58 -04:00
Greg Bellows
655b780f48
target-arm: Add virt machine secure property
Add "secure" virt machine specific property to allow override of the
default secure state configuration. By default, when using the QEMU
-kernel command line argument, virt machines boot into NS/SVC. When using
the QEMU -bios command line argument, virt machines boot into S/SVC.

The secure state can be changed from the default specifying the secure
state as a machine property. For example, the below command line would disable
security extensions on a -kernel Linux boot:

aarch64-softmmu/qemu-system-aarch64
-machine type=virt,secure=off
-kernel ...

Backports commit 083a58906cb32731dd98a93fcf451ec7718c0924 from qemu
2018-03-11 14:11:17 -04:00
Greg Bellows
125bd964d9
target-arm: Add virt class and machine types
Switch virt qemu machine support to use the newer object type, class, and
instance model. Added virt TypeInfo with static registration along with virt
specific class and machine structs. Also added virt class initialization
method.

Backports commit c29196904b2bad015edc553a5693c5c9e6f8177a from qemu
2018-03-11 14:03:34 -04:00
Eduardo Habkost
df4cfe6804
machine: MACHINE_TYPE_NAME macro
The macro will be useful to ensure the machine class names follow the
right format to make machine class lookup by class name work correctly.

Backports commit c84a8f01b2a5d8bf98c447796d4a747333a5b1fd from qemu
2018-03-11 13:44:26 -04:00
Eduardo Habkost
ba09afc8b5
pc: Generate init functions with a macro
All pc-i440fx and pc-q35 init functions simply call the corresponding
compat function and then call the main init function. Use a macro to
generate that code.

Backports commit 99fbeafee8b568e796863980365080abdb8d675e from qemu
2018-03-11 13:42:19 -04:00
Eduardo Habkost
6a287ba88e
piix: Eliminate pc_init_pci()
Backports commit 211b5b1d0a31f2f7593d6858a0b10487fb7b7fac from qemu
2018-03-11 13:38:06 -04:00
Eduardo Habkost
940d2371ea
machine: Remove unused fields from QEMUMachine
This removes the following fields from QEMUMachine: family, alias,
reset, hot_add_cpu, units_per_default_bus, no_serial, no_parallel,
use_virtcon, use_sclp, no_floppy, no_cdrom, default_display,
compat_props, and hw_version.

The only users of those fields were already converted to use QOM and
MachineClass directly, so they are not needed anymore.

Backports commit d48f4fa69eb3efb03a2efe2e4606a97a17cf222f from qemu
2018-03-09 14:26:23 -05:00
Eduardo Habkost
12acb995fa
pc: Don't use QEMUMachine anymore
Now that we have a DEFINE_PC_MACHINE helper macro that just requires an
initialization function, it is trivial to convert them to register a QOM
machine class directly, instead of using QEMUMachine.

Backports commit 865906f7fdadd2732441ab158787f81f6a212bfe from qemu
2018-03-09 14:22:43 -05:00
Eduardo Habkost
b65a3ece3b
machine: Remove unused fields from QEMUMachine
This removes the following fields from QEMUMachine: family, alias,
reset, hot_add_cpu, units_per_default_bus, no_serial, no_parallel,
use_virtcon, use_sclp, no_floppy, no_cdrom, default_display,
compat_props, and hw_version.

The only users of those fields were already converted to use QOM and
MachineClass directly, so they are not needed anymore.

Backports commit d48f4fa69eb3efb03a2efe2e4606a97a17cf222f from qemu
2018-03-09 13:41:30 -05:00
Marc-André Lureau
9ec040b74d
bus: simplify name handling
Simplify a bit the code by using g_strdup_printf() and store it in a
non-const value so casting is no longer needed, and ownership is
clearer.

Backports commit f73480c36f49562556b80bb5bf8acc45e20dcca1 from qemu
2018-03-09 13:02:15 -05:00
Thomas Huth
af3cd62c4b
Introduce DEVICE_CATEGORY_CPU for CPU devices
Now that CPUs show up in the help text of "-device ?",
we should group them into an appropriate category.

Backports commit ba31cc7226ebcee639f18faa90c1542bd364fba3 from qemu
2018-03-09 13:00:32 -05:00
Peter Maydell
714781d9e0
configure: Never use 'uname' to identify target OS
For a very long time we have used 'uname -s' as our fallback if
we don't identify the target OS using a compiler #define. This
obviously doesn't work for cross-compilation, and we've had
a comment suggesting we fix this in configure for a long time.
Since we now have an exhaustive list of which OSes we can run
on (thanks to commit 898be3e0415 making an unrecognized OS
be a fatal error), we know which ones we're missing.

Add check_define tests for the remaining OSes we support. The
defines checked are based on ones we already use in the codebase for
identifying the host OS (with the exception of GNU/kFreeBSD).
We can now set bogus_os immediately rather than doing it later.

We leave the comment about uname being bad untouched, since
there is still a use of it for the fallback for unrecognized
host CPU type.

Backports commit 951fedfceeda1b09ac8aa1f5263288b65e13caca from qemu
2018-03-09 12:37:21 -05:00
Peter Maydell
9601f82746
configure: Diagnose broken linkers directly
Currently if the user's compiler works for creating .o files but
their linker is broken such that compiling an executable from a
C file does not work, we will report a misleading error message
about the compiler not supporting __thread (since that happens
to be the first test we run which requires a working linker).
Explicitly check that compile_prog works as well as compile_object,
so that people whose toolchain setup is broken get a more helpful
error message.

Backports commit 0ef74c7496fd3c526b2259f86326eca4b3a03b78 from qemu
2018-03-09 12:26:21 -05:00
Peter Maydell
91de4878f7
configure: Don't claim 'unsupported host OS' when better message available
The change in commit 898be3e0415c6d which made completely
unrecognized OSes cause an error_exit "Unsupported host OS"
has some unfortunate unintended effects:
* if you run 'configure --help' on an unsupported host OS
(eg if intending to use it as a build machine for a
cross compile to a supported host) then the message
is printed instead of --help
* if the C compiler doesn't work or is missing (eg if
you passed an incorrect --cross-prefix by mistake)
the message is printed instead of the more useful
'compiler does not exist or does not work' message

Fix this by postponing the error_exit in this situation
until later, when we have already identified the more
useful cases for this.

The long term fix for this would be to move handling
of --help much further up in the configure script,
and make its output not dependent on checks that configure
runs. However for 2.9 this would be too invasive.

Backports commit fb59dabd4fa7e6586824ac3012073b943fc8dc79 from qemu
2018-03-09 12:25:14 -05:00
Peter Maydell
a3ae5a783f
configure: Warn about deprecated hosts
We plan to drop support in a future QEMU release for host OSes
and host architectures for which we have no test machine where
we can build and run tests. For the 2.9 release, make configure
print a warning if it is run on such a host, so that the user
has some warning of the plans and can volunteer to help us
maintain the port if they need it to continue to function.

This commit flags up as deprecated the CPU architectures:
* ia64
* sparc
* anything which we don't have a TCG port for
(and which was presumably using TCI)
and the OSes:
* GNU/kFreeBSD
* DragonFly BSD
* NetBSD
* OpenBSD
* Solaris
* AIX
* Haiku

It also makes entirely unrecognized host OS strings be
rejected rather than treated as if they were Linux (which
likely never worked).

Backports commit 898be3e0415c6d614395c087ef1e91210797cda7 from qemu
2018-03-09 12:21:12 -05:00
Peter Maydell
4149e877c4
configure: Drop ancient Solaris 9 and earlier support
Solaris 9 was released in 2002, its successor Solaris 10 was
released in 2005, and Solaris 9 was end-of-lifed in 2014.
Nobody has stepped forward to express interest in supporting
Solaris of any flavour, so removing support for the ancient
versions seems uncontroversial.

In particular, this allows us to remove a use of 'uname'
in configure that won't work if you're cross-compiling.

Backports commit 91939262ffcd3c85ea6a4793d3029326eea1d649 from qemu
2018-03-09 12:14:21 -05:00
Richard Henderson
7e327aaf84
util: Introduce include/qemu/cpuid.h
Clang 3.9 passes the CONFIG_AVX2_OPT configure test. However, the
supplied <cpuid.h> does not contain the bit_AVX2 define that we use
when detecting whether the routine can be enabled.

Introduce a qemu-specific header that uses the compiler's definition
of __cpuid et al, but supplies any missing bit_* definitions needed.
This avoids introducing any extra ifdefs to util/bufferiszero.c, and
allows quite a few to be removed from tcg/i386/tcg-target.inc.c.

Backports commit 5dd8990841a9e331d9d4838a116291698208cbb6 from qemu
2018-03-09 12:12:00 -05:00
Peter Maydell
6d0e83d218
Drop remaining bits of ia64 host support
We dropped support for ia64 host CPUs in the 2.11 release (removing
the TCG backend for it, and advertising the support as being
completely removed in the changelog).  However there are a few bits
and pieces of code still floating about.  Remove those, too.

We can drop the check in configure for "ia64 or hppa host?"
entirely, because we don't support hppa hosts either any more.

Backports commit b1cef6d02f84bd842fb94a6109ad4e2ad873e8e5 from qemu
2018-03-09 11:54:57 -05:00
Marc-André Lureau
234f2ca184
build-sys: fix -fsanitize=address check
Since 218bb57dd79d6843e0592c30a82ea8c1fddc74a5, the -fsanitize=address
check fails with:
config-temp/qemu-conf.c:3:20: error: integer overflow in expression [-Werror=overflow]
return INT32_MIN / -1;

Interestingly, UBSAN check doesn't produce a compile time warning.
Use a test that doesn't have compile time warnings, and make it
specific to UBSAN check.

Backports commit b9f44da2f2cdc1a1a1be5aed0c46bd7fcc69cf4a from qemu
2018-03-09 11:52:00 -05:00
John Snow
0aa640a303
configure: factor out supported flag check
Factor out the function that checks if a compiler
flag is supported or not.

Backports commit 93b25869228a3c0c632a6aa66624cc4e549ba14a from qemu
2018-03-09 11:49:37 -05:00
Stef O'Rear
d25e1a6216
softfloat: fix crash on int conversion of SNaN
Backports commit cffad426f520d39c19db64485d8a429fc95b8aca from qemu
2018-03-09 11:40:17 -05:00
Markus Armbruster
4b61859c3c
qapi: Don't create useless directory qapi-generated
We used to generate first test and later QGA QAPI code into
qapi-generated/. Commit b93b63f574 moved the test code to tests/.
Commit 54c2e50205 moved the QGA code to qga/qapi-generated/. The
directory has been unused since.

Backports commit 418b1d0ae3a2cc992659f626a2a3f11944e0b259 from qemu
2018-03-09 11:36:49 -05:00
Markus Armbruster
3277400723
qapi: Move qapi-schema.json to qapi/, rename generated files
Move qapi-schema.json to qapi/, so it's next to its modules, and all
files get generated to qapi/, not just the ones generated for modules.

Consistently name the generated files qapi-MODULE.EXT:
qmp-commands.[ch] become qapi-commands.[ch], qapi-event.[ch] become
qapi-events.[ch], and qmp-introspect.[ch] become qapi-introspect.[ch].
This gets rid of the temporary hacks in scripts/qapi/commands.py,
scripts/qapi/events.py, and scripts/qapi/common.py.

Backports commit eb815e248f50cde9ab86eddd57eca5019b71ca78 from qemu
2018-03-09 11:35:11 -05:00
Markus Armbruster
311d659acf
qapi: Empty out qapi-schema.json
The previous commit improved compile time by including less of the
generated QAPI headers. This is impossible for stuff defined directly
in qapi-schema.json, because that ends up in headers that that pull in
everything.

Move everything but include directives from qapi-schema.json to new
sub-module qapi/misc.json, then include just the "misc" shard where
possible.

It's possible everywhere, except:

* monitor.c needs qmp-command.h to get qmp_init_marshal()

* monitor.c, ui/vnc.c and the generated qapi-event-FOO.c need
qapi-event.h to get enum QAPIEvent

Perhaps we'll get rid of those some other day.

Adding a type to qapi/migration.json now recompiles some 120 instead
of 2300 out of 5100 objects.

Backports commit 112ed241f5d9a411dbca92bdf597151cb853c6a7 from qemu
2018-03-09 10:23:27 -05:00