]> git.proxmox.com Git - mirror_qemu.git/log
mirror_qemu.git
6 years agotarget/arm: Factor out fault delivery code
Peter Maydell [Mon, 4 Sep 2017 14:21:55 +0000 (15:21 +0100)]
target/arm: Factor out fault delivery code

We currently have some similar code in tlb_fill() and in
arm_cpu_do_unaligned_access() for delivering a data abort or prefetch
abort.  We're also going to want to do the same thing to handle
external aborts.  Factor out the common code into a new function
deliver_fault().

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Acked-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
6 years agocputlb: Support generating CPU exceptions on memory transaction failures
Peter Maydell [Mon, 4 Sep 2017 14:21:55 +0000 (15:21 +0100)]
cputlb: Support generating CPU exceptions on memory transaction failures

Call the new cpu_transaction_failed() hook at the places where
CPU generated code interacts with the memory system:
 io_readx()
 io_writex()
 get_page_addr_code()

Any access from C code (eg via cpu_physical_memory_rw(),
address_space_rw(), ld/st_*_phys()) will *not* trigger CPU exceptions
via cpu_transaction_failed().  Handling for transactions failures for
this kind of call should be done by using a function which returns a
MemTxResult and treating the failure case appropriately in the
calling code.

In an ideal world we would not generate CPU exceptions for
instruction fetch failures in get_page_addr_code() but instead wait
until the code translation process tried a load and it failed;
however that change would require too great a restructuring and
redesign to attempt at this point.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
6 years agocpu: Define new cpu_transaction_failed() hook
Peter Maydell [Mon, 4 Sep 2017 14:21:54 +0000 (15:21 +0100)]
cpu: Define new cpu_transaction_failed() hook

Currently we have a rather half-baked setup for allowing CPUs to
generate exceptions on accesses to invalid memory: the CPU has a
cpu_unassigned_access() hook which the memory system calls in
unassigned_mem_write() and unassigned_mem_read() if the current_cpu
pointer is non-NULL.  This was originally designed before we
implemented the MemTxResult type that allows memory operations to
report a success or failure code, which is why the hook is called
right at the bottom of the memory system.  The major problem with
this is that it means that the hook can be called even when the
access was not actually done by the CPU: for instance if the CPU
writes to a DMA engine register which causes the DMA engine to begin
a transaction which has been set up by the guest to operate on
invalid memory then this will casue the CPU to take an exception
incorrectly.  Another minor problem is that currently if a device
returns a transaction error then this won't turn into a CPU exception
at all.

The right way to do this is to have allow the CPU to respond
to memory system transaction failures at the point where the
CPU specific code calls into the memory system.

Define a new QOM CPU method and utility function
cpu_transaction_failed() which is called in these cases.
The functionality here overlaps with the existing
cpu_unassigned_access() because individual target CPUs will
need some work to convert them to the new system. When this
transition is complete we can remove the old cpu_unassigned_access()
code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
6 years agomemory.h: Move MemTxResult type to memattrs.h
Peter Maydell [Mon, 4 Sep 2017 14:21:54 +0000 (15:21 +0100)]
memory.h: Move MemTxResult type to memattrs.h

Move the MemTxResult type to memattrs.h. We're going to want to
use it in cpu/qom.h, which doesn't want to include all of
memory.h. In practice MemTxResult and MemTxAttrs are pretty
closely linked since both are used for the new-style
read_with_attrs and write_with_attrs callbacks, so memattrs.h
is a reasonable home for this rather than creating a whole
new header file for it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Alistair Francis <alistair.francis@xilinx.com>
6 years agoaspeed_soc: Propagate silicon-rev to watchdog
Andrew Jeffery [Mon, 4 Sep 2017 14:21:54 +0000 (15:21 +0100)]
aspeed_soc: Propagate silicon-rev to watchdog

This is required to configure differences in behaviour between the
AST2400 and AST2500 watchdog IPs.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agowatchdog: wdt_aspeed: Add support for the reset width register
Andrew Jeffery [Mon, 4 Sep 2017 14:21:54 +0000 (15:21 +0100)]
watchdog: wdt_aspeed: Add support for the reset width register

The reset width register controls how the pulse on the SoC's WDTRST{1,2}
pins behaves. A pulse is emitted if the external reset bit is set in
WDT_CTRL. On the AST2500 WDT_RESET_WIDTH can consume magic bit patterns
to configure push-pull/open-drain and active-high/active-low
behaviours and thus needs some special handling in the write path.

As some of the capabilities depend on the SoC version a silicon-rev
property is introduced, which is used to guard version-specific
behaviour.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agotarget/arm/kvm: pmu: improve error handling
Andrew Jones [Mon, 4 Sep 2017 14:21:54 +0000 (15:21 +0100)]
target/arm/kvm: pmu: improve error handling

If a KVM PMU init or set-irq attr call fails we just silently stop
the PMU DT node generation. The only way they could fail, though,
is if the attr's respective KVM has-attr call fails. But that should
never happen if KVM advertises the PMU capability, because both
attrs have been available since the capability was introduced. Let's
just abort if this should-never-happen stuff does happen, because,
if it does, then something is obviously horribly wrong.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Christoffer Dall <cdall@linaro.org>
Message-id: 1500471597-2517-5-git-send-email-drjones@redhat.com
[PMM: change kvm32.c kvm_arm_pmu_init() to the new API too]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agohw/arm/virt: allow pmu instantiation with userspace irqchip
Andrew Jones [Mon, 4 Sep 2017 14:21:54 +0000 (15:21 +0100)]
hw/arm/virt: allow pmu instantiation with userspace irqchip

Move the in-kernel-irqchip test to only guard the set-irq
stage, not the init stage of the PMU.  Also add the PMU to
the KVM device irq line synchronization to enable its use.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Christoffer Dall <cdall@linaro.org>
Message-id: 1500471597-2517-4-git-send-email-drjones@redhat.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agotarget/arm/kvm: pmu: split init and set-irq stages
Andrew Jones [Mon, 4 Sep 2017 14:21:54 +0000 (15:21 +0100)]
target/arm/kvm: pmu: split init and set-irq stages

When adding a PMU with a userspace irqchip we skip the set-irq
stage of device creation. Split the 'create' function into two
functions 'init' and 'set-irq' so they may be called separately.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Christoffer Dall <cdall@linaro.org>
Message-id: 1500471597-2517-3-git-send-email-drjones@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agohw/arm/virt: add pmu interrupt state
Andrew Jones [Mon, 4 Sep 2017 14:21:53 +0000 (15:21 +0100)]
hw/arm/virt: add pmu interrupt state

Mimicking gicv3-maintenance-interrupt, add the PMU's interrupt to
CPU state.

Signed-off-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1500471597-2517-2-git-send-email-drjones@redhat.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agohw/arm: use defined type name instead of hard-coded string
Philippe Mathieu-Daudé [Mon, 4 Sep 2017 14:21:53 +0000 (15:21 +0100)]
hw/arm: use defined type name instead of hard-coded string

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoloader: Ignore zero-sized ELF segments
Peter Maydell [Mon, 4 Sep 2017 14:21:53 +0000 (15:21 +0100)]
loader: Ignore zero-sized ELF segments

Some ELF files have program headers that specify segments that
are of zero size. Ignore them, rather than trying to create
zero-length ROM blobs for them, because the zero-length blob
can falsely trigger the overlapping-ROM-blobs check.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Hua Yanghao <huayanghao@gmail.com>
Message-id: 1502116754-18867-3-git-send-email-peter.maydell@linaro.org

6 years agoloader: Handle ELF files with overlapping zero-initialized data
Peter Maydell [Mon, 4 Sep 2017 14:21:53 +0000 (15:21 +0100)]
loader: Handle ELF files with overlapping zero-initialized data

For embedded systems, notably ARM, one common use of ELF
file segments is that the 'physical addresses' represent load addresses
and the 'virtual addresses' execution addresses, such that
the load addresses are packed into ROM or flash, and the
relocation and zero-initialization of data is done at runtime.
This means that the 'memsz' in the segment header represents
the runtime size of the segment, but the size that needs to
be loaded is only the 'filesz'. In particular, paddr+memsz
may overlap with the next segment to be loaded, as in this
example:

0x70000001 off    0x00007f68 vaddr 0x00008150 paddr 0x00008150 align 2**2
         filesz 0x00000008 memsz 0x00000008 flags r--
    LOAD off    0x000000f4 vaddr 0x00000000 paddr 0x00000000 align 2**2
         filesz 0x00000124 memsz 0x00000124 flags r--
    LOAD off    0x00000218 vaddr 0x00000400 paddr 0x00000400 align 2**3
         filesz 0x00007d58 memsz 0x00007d58 flags r-x
    LOAD off    0x00007f70 vaddr 0x20000140 paddr 0x00008158 align 2**3
         filesz 0x00000a80 memsz 0x000022f8 flags rw-
    LOAD off    0x000089f0 vaddr 0x20002438 paddr 0x00008bd8 align 2**0
         filesz 0x00000000 memsz 0x00004000 flags rw-
    LOAD off    0x000089f0 vaddr 0x20000000 paddr 0x20000000 align 2**0
         filesz 0x00000000 memsz 0x00000140 flags rw-

where the segment at paddr 0x8158 has a memsz of 0x2258 and
would overlap with the segment at paddr 0x8bd8 if QEMU's loader
tried to honour it. (At runtime the segments will not overlap
since their vaddrs are more widely spaced than their paddrs.)

Currently if you try to load an ELF file like this with QEMU then
it will fail with an error "rom: requested regions overlap",
because we create a ROM image for each segment using the memsz
as the size.

Support ELF files using this scheme, by truncating the
zero-initialized part of the segment if it would overlap another
segment. This will retain the existing loader behaviour for
all ELF files we currently accept, and also accept ELF files
which only need 'filesz' bytes to be loaded.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1502116754-18867-2-git-send-email-peter.maydell@linaro.org

6 years agonvic: Implement "user accesses BusFault" SCS region behaviour
Peter Maydell [Mon, 4 Sep 2017 14:21:53 +0000 (15:21 +0100)]
nvic: Implement "user accesses BusFault" SCS region behaviour

The ARMv7M architecture specifies that most of the addresses in the
PPB region (which includes the NVIC, systick and system registers)
are not accessible to unprivileged accesses, which should
BusFault with a few exceptions:
 * the STIR is configurably user-accessible
 * the ITM (which we don't implement at all) is always
   user-accessible

Implement this by switching the register access functions
to the _with_attrs scheme that lets us distinguish user
mode accesses.

This allows us to pull the handling of the CCR.USERSETMPEND
flag up to the level where we can make it generate a BusFault
as it should for non-permitted accesses.

Note that until the core ARM CPU code implements turning
MEMTX_ERROR into a BusFault the registers will continue to
act as RAZ/WI to user accesses.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-16-git-send-email-peter.maydell@linaro.org

6 years agoarmv7m_nvic.h: Move from include/hw/arm to include/hw/intc
Peter Maydell [Mon, 4 Sep 2017 14:21:53 +0000 (15:21 +0100)]
armv7m_nvic.h: Move from include/hw/arm to include/hw/intc

The armv7m_nvic.h header file was accidentally placed in
include/hw/arm; move it to include/hw/intc to match where
its corresponding .c file lives.

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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-15-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Create and use new function arm_v7m_is_handler_mode()
Peter Maydell [Mon, 4 Sep 2017 14:21:53 +0000 (15:21 +0100)]
target/arm: Create and use new function arm_v7m_is_handler_mode()

Add a utility function for testing whether the CPU is in Handler
mode; this is just a check whether v7m.exception is non-zero, but
we do it in several places and it makes the code a bit easier
to read to not have to mentally figure out what the test is testing.

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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-14-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Don't calculate lr in arm_v7m_cpu_do_interrupt() until needed
Peter Maydell [Mon, 4 Sep 2017 14:21:53 +0000 (15:21 +0100)]
target/arm: Don't calculate lr in arm_v7m_cpu_do_interrupt() until needed

Move the code in arm_v7m_cpu_do_interrupt() that calculates the
magic LR value down to when we're actually going to use it.
Having the calculation and use so far apart makes the code
a little harder to understand than it needs to be.

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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-13-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Make arm_cpu_dump_state() handle the M-profile XPSR
Peter Maydell [Mon, 4 Sep 2017 14:21:52 +0000 (15:21 +0100)]
target/arm: Make arm_cpu_dump_state() handle the M-profile XPSR

Make the arm_cpu_dump_state() debug logging handle the M-profile XPSR
rather than assuming it's an A-profile CPSR.  On M profile the PSR
line of a register dump will now look like this:

XPSR=41000000 -Z-- T priv-thread

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-12-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Don't use cpsr_write/cpsr_read to transfer M profile XPSR
Peter Maydell [Mon, 4 Sep 2017 14:21:52 +0000 (15:21 +0100)]
target/arm: Don't use cpsr_write/cpsr_read to transfer M profile XPSR

For M profile the XPSR is a similar but not identical format to the
A profile CPSR/SPSR. (For instance the Thumb bit is in a different
place.) For guest accesses we make the M profile code go through
xpsr_read() and xpsr_write() which handle the different layout.
However for migration we use cpsr_read() and cpsr_write() to
marshal state into and out of the migration data stream. This
is pretty confusing and works more by luck than anything else.
Make M profile migration use xpsr_read() and xpsr_write() instead.

The most complicated part of this is handling the possibility
that the migration source is an older QEMU which hands us a
CPSR format value; helpfully we can always tell the two apart.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-11-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Don't store M profile PRIMASK and FAULTMASK in daif
Peter Maydell [Mon, 4 Sep 2017 14:21:52 +0000 (15:21 +0100)]
target/arm: Don't store M profile PRIMASK and FAULTMASK in daif

We currently store the M profile CPU register state PRIMASK and
FAULTMASK in the daif field of the CPU state in its I and F
bits. This is a legacy from the original implementation, which
tried to share the cpu_exec_interrupt code between A profile
and M profile. We've since separated out the two cases because
they are significantly different, so now there is no common
code between M and A profile which looks at env->daif: all the
uses are either in A-only or M-only code paths. Sharing the state
fields now is just confusing, and will make things awkward
when we implement v8M, where the PRIMASK and FAULTMASK
registers are banked between security states.

Switch M profile over to using v7m.faultmask and v7m.primask
fields for these registers.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-10-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Define and use XPSR bit masks
Peter Maydell [Mon, 4 Sep 2017 14:21:52 +0000 (15:21 +0100)]
target/arm: Define and use XPSR bit masks

The M profile XPSR is almost the same format as the A profile CPSR,
but not quite. Define some XPSR_* macros and use them where we
definitely dealing with an XPSR rather than reusing the CPSR ones.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-9-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Fix outdated comment about exception exit
Peter Maydell [Mon, 4 Sep 2017 14:21:52 +0000 (15:21 +0100)]
target/arm: Fix outdated comment about exception exit

When we switched our handling of exception exit to detect
the magic addresses at translate time rather than via
a do_unassigned_access hook, we forgot to update a
comment; correct the omission.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-8-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Remove incorrect comment about MPU_CTRL
Peter Maydell [Mon, 4 Sep 2017 14:21:52 +0000 (15:21 +0100)]
target/arm: Remove incorrect comment about MPU_CTRL

Remove the comment that claims that some MPU_CTRL bits are stored
in sctlr_el[1]. This has never been true since MPU_CTRL was added
in commit 29c483a50607 -- the comment is a leftover from
Michael Davidsaver's original implementation, which I modified
not to use sctlr_el[1]; I forgot to delete the comment then.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-7-git-send-email-peter.maydell@linaro.org

6 years agohw/intc/armv7m_nvic.c: Remove out of date comment
Peter Maydell [Mon, 4 Sep 2017 14:21:52 +0000 (15:21 +0100)]
hw/intc/armv7m_nvic.c: Remove out of date comment

Remove an out of date comment which says there's only one
item in the NVIC container region -- we put systick into its
own device object a while back and so now there are two
things in the container.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-6-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Tighten up Thumb decode where new v8M insns will be
Peter Maydell [Mon, 4 Sep 2017 14:21:51 +0000 (15:21 +0100)]
target/arm: Tighten up Thumb decode where new v8M insns will be

Tighten up the T32 decoder in the places where new v8M instructions
will be:
 * TT/TTT/TTA/TTAT are in what was nominally LDREX/STREX r15, ...
   which is UNPREDICTABLE:
   make the UNPREDICTABLE behaviour be to UNDEF
 * BXNS/BLXNS are distinguished from BX/BLX via the low 3 bits,
   which in previous architectural versions are SBZ:
   enforce the SBZ via UNDEF rather than ignoring it, and move
   the "ARCH(5)" UNDEF case up so we don't leak a TCG temporary
 * SG is in the encoding which would be LDRD/STRD with rn = r15;
   this is UNPREDICTABLE and we currently UNDEF:
   move this check further up the code so that we don't leak
   TCG temporaries in the UNDEF case and have a better place
   to put the SG decode.

This means that if a v8M binary is accidentally run on v7M
or if a test case hits something that we haven't implemented
yet the behaviour will be obvious (UNDEF) rather than obscure
(plough on treating it as a different instruction).

In the process, add some comments about the instruction patterns
at these points in the decode. Our Thumb and ARM decoders are
very difficult to understand currently, but gradually adding
comments like this should help to clarify what exactly has
been decoded when.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-5-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Consolidate PMSA handling in get_phys_addr()
Peter Maydell [Mon, 4 Sep 2017 14:21:51 +0000 (15:21 +0100)]
target/arm: Consolidate PMSA handling in get_phys_addr()

Currently get_phys_addr() has PMSAv7 handling before the
"is translation disabled?" check, and then PMSAv5 after it.
Tidy this up by making the PMSAv5 code handle the "MPU disabled"
case itself, so that we have all the PMSA code in one place.
This will make adding the PMSAv8 code slightly cleaner, and
also means that pre-v7 PMSA cores benefit from the MPU lookup
logging that the PMSAv7 codepath had.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-4-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Don't trap WFI/WFE for M profile
Peter Maydell [Mon, 4 Sep 2017 14:21:51 +0000 (15:21 +0100)]
target/arm: Don't trap WFI/WFE for M profile

M profile cores can never trap on WFI or WFE instructions. Check for
M profile in check_wfx_trap() to ensure this.

The existing code will do the right thing for v7M cores because
the hcr_el2 and scr_el3 registers will be all-zeroes and so we
won't attempt to trap, but when we start setting ARM_FEATURE_V8
for v8M cores the v8A handling of SCTLR.nTWE and .nTWI will not
give the right results.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-3-git-send-email-peter.maydell@linaro.org

6 years agotarget/arm: Use MMUAccessType enum rather than int
Peter Maydell [Mon, 4 Sep 2017 14:21:51 +0000 (15:21 +0100)]
target/arm: Use MMUAccessType enum rather than int

In the ARM get_phys_addr() code, switch to using the MMUAccessType
enum and its MMU_* values rather than int and literal 0/1/2.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 1501692241-23310-2-git-send-email-peter.maydell@linaro.org

6 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-09-01-v3' into staging
Peter Maydell [Mon, 4 Sep 2017 12:28:09 +0000 (13:28 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-09-01-v3' into staging

QAPI patches for 2017-09-01

# gpg: Signature made Mon 04 Sep 2017 12:30:31 BST
# gpg:                using RSA key 0x3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2017-09-01-v3: (47 commits)
  qapi: drop the sentinel in enum array
  qapi: Change data type of the FOO_lookup generated for enum FOO
  qapi: Convert indirect uses of FOO_lookup[...] to qapi_enum_lookup()
  qapi: Mechanically convert FOO_lookup[...] to FOO_str(...)
  qapi: Generate FOO_str() macro for QAPI enum FOO
  qapi: Avoid unnecessary use of enum lookup table's sentinel
  qapi: Use qapi_enum_parse() in input_type_enum()
  crypto: Use qapi_enum_parse() in qcrypto_block_luks_name_lookup()
  quorum: Use qapi_enum_parse() in quorum_open()
  block: Use qemu_enum_parse() in blkdebug_debug_breakpoint()
  hmp: Use qapi_enum_parse() in hmp_migrate_set_parameter()
  hmp: Use qapi_enum_parse() in hmp_migrate_set_capability()
  tpm: Clean up model registration & lookup
  tpm: Clean up driver registration & lookup
  qapi: Drop superfluous qapi_enum_parse() parameter max
  qapi: Update qapi-code-gen.txt examples to match current code
  qapi-schema: Improve section headings
  qapi-schema: Move queries from common.json to qapi-schema.json
  qapi-schema: Make block-core.json self-contained
  qapi-schema: Fold event.json back into qapi-schema.json
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoqapi: drop the sentinel in enum array
Marc-André Lureau [Thu, 24 Aug 2017 08:46:11 +0000 (10:46 +0200)]
qapi: drop the sentinel in enum array

Now that all usages have been converted to user lookup helpers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-14-marcandre.lureau@redhat.com>
[Rebased, superfluous local variable dropped, missing
check-qom-proplist.c update added]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-17-git-send-email-armbru@redhat.com>

6 years agoqapi: Change data type of the FOO_lookup generated for enum FOO
Marc-André Lureau [Thu, 24 Aug 2017 08:46:10 +0000 (10:46 +0200)]
qapi: Change data type of the FOO_lookup generated for enum FOO

Currently, a FOO_lookup is an array of strings terminated by a NULL
sentinel.

A future patch will generate enums with "holes".  NULL-termination
will cease to work then.

To prepare for that, store the length in the FOO_lookup by wrapping it
in a struct and adding a member for the length.

The sentinel will be dropped next.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-13-marcandre.lureau@redhat.com>
[Basically redone]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-16-git-send-email-armbru@redhat.com>
[Rebased]

6 years agoqapi: Convert indirect uses of FOO_lookup[...] to qapi_enum_lookup()
Markus Armbruster [Thu, 24 Aug 2017 08:46:09 +0000 (10:46 +0200)]
qapi: Convert indirect uses of FOO_lookup[...] to qapi_enum_lookup()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-15-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi: Mechanically convert FOO_lookup[...] to FOO_str(...)
Markus Armbruster [Thu, 24 Aug 2017 08:46:08 +0000 (10:46 +0200)]
qapi: Mechanically convert FOO_lookup[...] to FOO_str(...)

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-14-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi: Generate FOO_str() macro for QAPI enum FOO
Markus Armbruster [Thu, 24 Aug 2017 08:46:07 +0000 (10:46 +0200)]
qapi: Generate FOO_str() macro for QAPI enum FOO

The next commit will put it to use.  May look pointless now, but we're
going to change the FOO_lookup's type, and then it'll help.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-13-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi: Avoid unnecessary use of enum lookup table's sentinel
Markus Armbruster [Thu, 24 Aug 2017 08:46:06 +0000 (10:46 +0200)]
qapi: Avoid unnecessary use of enum lookup table's sentinel

Currently, the FOO_lookup[] generated for QAPI enum types are
terminated by a NULL sentinel.

A future patch will generate enums with "holes".  NULL-termination
will cease to work then.

To prepare for that, replace "have we reached the sentinel?"
predicates by "have we reached the FOO__MAX value?" predicates.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-12-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi: Use qapi_enum_parse() in input_type_enum()
Markus Armbruster [Thu, 24 Aug 2017 08:46:05 +0000 (10:46 +0200)]
qapi: Use qapi_enum_parse() in input_type_enum()

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-11-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agocrypto: Use qapi_enum_parse() in qcrypto_block_luks_name_lookup()
Markus Armbruster [Thu, 24 Aug 2017 08:46:04 +0000 (10:46 +0200)]
crypto: Use qapi_enum_parse() in qcrypto_block_luks_name_lookup()

Cc: "Daniel P. Berrange" <berrange@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-10-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
6 years agoquorum: Use qapi_enum_parse() in quorum_open()
Marc-André Lureau [Thu, 24 Aug 2017 08:46:03 +0000 (10:46 +0200)]
quorum: Use qapi_enum_parse() in quorum_open()

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-12-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, qemu_opt_get() factored out, commit message tweaked]
Cc: Alberto Garcia <berto@igalia.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-9-git-send-email-armbru@redhat.com>

6 years agoblock: Use qemu_enum_parse() in blkdebug_debug_breakpoint()
Marc-André Lureau [Thu, 24 Aug 2017 08:46:02 +0000 (10:46 +0200)]
block: Use qemu_enum_parse() in blkdebug_debug_breakpoint()

The error message on invalid blkdebug events changes from

    qemu-system-x86_64: LOCATION: Invalid event name "VALUE"

to

    qemu-system-x86_64: LOCATION: invalid parameter value: VALUE

Slight degradation, but the message is sub-par even before the patch.
When complaining about a parameter value, both parameter name and
value should be mentioned, as the value may well not be unique.  Left
for another day.

Also left is the error message's unhelpful location: it points to the
config=FILENAME rather than into that file.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-11-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, commit message rewritten]
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Max Reitz <mreitz@redhat.com>
Cc: qemu-block@nongnu.org
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-8-git-send-email-armbru@redhat.com>

6 years agohmp: Use qapi_enum_parse() in hmp_migrate_set_parameter()
Marc-André Lureau [Thu, 24 Aug 2017 08:46:01 +0000 (10:46 +0200)]
hmp: Use qapi_enum_parse() in hmp_migrate_set_parameter()

The error message on invalid parameter name changes from

    Invalid parameter "NAME"

to

    invalid parameter value: NAME

Slight degratation, perhaps.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-10-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, assertion added, commit message rewritten]
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-7-git-send-email-armbru@redhat.com>

6 years agohmp: Use qapi_enum_parse() in hmp_migrate_set_capability()
Marc-André Lureau [Thu, 24 Aug 2017 08:46:00 +0000 (10:46 +0200)]
hmp: Use qapi_enum_parse() in hmp_migrate_set_capability()

The error message on invalid capability name changes from

    Invalid parameter "NAME"

to

    invalid parameter value: NAME

No worse than before.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-9-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, commit message rewritten]
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-6-git-send-email-armbru@redhat.com>

6 years agotpm: Clean up model registration & lookup
Markus Armbruster [Thu, 24 Aug 2017 08:45:59 +0000 (10:45 +0200)]
tpm: Clean up model registration & lookup

We have a strict separation between enum TpmModel and tpm_models[]:

* TpmModel may have any number of members.  It just happens to have one.

* tpm_register_model() uses the first empty slot in tpm_models[].

  If you register more than tpm_models[] has space,
  tpn_register_model() fails.  Its caller silently ignores the
  failure.

  Register the same TpmModel more than once has no effect other than
  wasting tpm_models[] slots: tpm_model_is_registered() is happy with
  the first one it finds.

Since we only ever register one model, and tpm_models[] has space for
just that one, this contraption even works.

Turn tpm_models[] into a straight map from enum TpmType to bool.  Much
simpler.

Cc: Stefan Berger <stefanb@us.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-5-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[Commit message typo fixed]

6 years agotpm: Clean up driver registration & lookup
Marc-André Lureau [Thu, 24 Aug 2017 08:45:58 +0000 (10:45 +0200)]
tpm: Clean up driver registration & lookup

We have a strict separation between enum TpmType and be_drivers[]:

* TpmType may have any number of members.  It just happens to have one.

* tpm_register_driver() uses the first empty slot in be_drivers[].

  If you register more than tpm_models[] has space,
  tpm_register_driver() fails.  Its caller silently ignores the
  failure.

  If you register more than one with a given TpmType,
  tpm_display_backend_drivers() will shows all of them, but
  tpm_driver_find_by_type() and tpm_get_backend_driver() will find
  only the one one that registered first.

Since we only ever register one driver, and be_drivers[] has space for
just that one, this contraption even works.

Turn be_drivers[] into a straight map from enum TpmType to driver.
Much simpler, and has a decent chance to actually work should we ever
acquire additional drivers.

While there, use qapi_enum_parse() in tpm_get_backend_driver().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170822132255.23945-8-marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Rebased, superfluous initializer dropped, commit message rewritten]
Cc: Stefan Berger <stefanb@us.ibm.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-4-git-send-email-armbru@redhat.com>

6 years agoqapi: Drop superfluous qapi_enum_parse() parameter max
Markus Armbruster [Thu, 24 Aug 2017 08:45:57 +0000 (10:45 +0200)]
qapi: Drop superfluous qapi_enum_parse() parameter max

The lookup tables have a sentinel, no need to make callers pass their
size.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-3-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Rebased, commit message corrected]

6 years agoqapi: Update qapi-code-gen.txt examples to match current code
Markus Armbruster [Thu, 24 Aug 2017 08:45:56 +0000 (10:45 +0200)]
qapi: Update qapi-code-gen.txt examples to match current code

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503564371-26090-2-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Improve section headings
Markus Armbruster [Thu, 24 Aug 2017 19:14:08 +0000 (21:14 +0200)]
qapi-schema: Improve section headings

The generated QEMU QMP reference is now structured as follows:

    1.1 Introduction
    1.2 Stability Considerations
    1.3 Common data types
    1.4 Socket data types
    1.5 VM run state
    1.6 Cryptography
    1.7 Block devices
    1.7.1 Block core (VM unrelated)
    1.7.2 QAPI block definitions (vm unrelated)
    1.8 Character devices
    1.9 Net devices
    1.10 Rocker switch device
    1.11 TPM (trusted platform module) devices
    1.12 Remote desktop
    1.12.1 Spice
    1.12.2 VNC
    1.13 Input
    1.14 Migration
    1.15 Transactions
    1.16 Tracing
    1.17 QMP introspection
    1.18 Miscellanea

Section "1.18 Miscellanea" is still too big: it documents 134 symbols.
Section "1.7.1 Block core (VM unrelated)" is also rather big: 128
symbols.  All the others are of reasonable size.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-17-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Move queries from common.json to qapi-schema.json
Markus Armbruster [Thu, 24 Aug 2017 19:14:07 +0000 (21:14 +0200)]
qapi-schema: Move queries from common.json to qapi-schema.json

query-version and query-commands are in common.json for no good
reason.  Several similar queries are in qapi-schema.json.  Move them
there.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-16-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Make block-core.json self-contained
Markus Armbruster [Thu, 24 Aug 2017 19:14:06 +0000 (21:14 +0200)]
qapi-schema: Make block-core.json self-contained

Except for block-core.json, the sub-schemas are self-contained: if
they use a symbol defined in another sub-schema, they include that
sub-schema.  To check, feed the sub-schema to qapi2texi (or any other
QAPI generator) along with the pragma from qapi-schema.json.

Fix up things to make block-core.json self-contained, too.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-15-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Fold event.json back into qapi-schema.json
Markus Armbruster [Thu, 24 Aug 2017 19:14:05 +0000 (21:14 +0200)]
qapi-schema: Fold event.json back into qapi-schema.json

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-14-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Move block events from event.json to block.json
Markus Armbruster [Thu, 24 Aug 2017 19:14:04 +0000 (21:14 +0200)]
qapi-schema: Move block events from event.json to block.json

Cc: Alberto Garcia <berto@igalia.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-13-git-send-email-armbru@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Collect TPM stuff in qapi/tpm.json
Markus Armbruster [Thu, 24 Aug 2017 19:14:03 +0000 (21:14 +0200)]
qapi-schema: Collect TPM stuff in qapi/tpm.json

Sadly, we don't have a TPM maintainer, not even a MAINTAINERS entry.
Create one, and mark it orphaned.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-12-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Collect transaction stuff in qapi/transaction.json
Markus Armbruster [Thu, 24 Aug 2017 19:14:02 +0000 (21:14 +0200)]
qapi-schema: Collect transaction stuff in qapi/transaction.json

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-11-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Collect migration stuff in qapi/migration.json
Markus Armbruster [Thu, 24 Aug 2017 19:14:01 +0000 (21:14 +0200)]
qapi-schema: Collect migration stuff in qapi/migration.json

Cc: Juan Quintela <quintela@redhat.com>
Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-10-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
6 years agoqapi-schema: Collect UI stuff in qapi/ui.json
Markus Armbruster [Thu, 24 Aug 2017 19:14:00 +0000 (21:14 +0200)]
qapi-schema: Collect UI stuff in qapi/ui.json

UI stuff is remote desktop stuff (Spice, VNC) and input stuff (mouse,
keyboard).

Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-9-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
6 years agoqapi-schema: Collect net device stuff in qapi/net.json
Markus Armbruster [Thu, 24 Aug 2017 19:13:59 +0000 (21:13 +0200)]
qapi-schema: Collect net device stuff in qapi/net.json

Cc: Jason Wang <jasowang@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-8-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Collect char device stuff in qapi/char.json
Markus Armbruster [Thu, 24 Aug 2017 19:13:58 +0000 (21:13 +0200)]
qapi-schema: Collect char device stuff in qapi/char.json

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-7-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Collect run state stuff in qapi/run-state.json
Markus Armbruster [Thu, 24 Aug 2017 19:13:57 +0000 (21:13 +0200)]
qapi-schema: Collect run state stuff in qapi/run-state.json

Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-6-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Collect sockets stuff in qapi/sockets.json
Markus Armbruster [Thu, 24 Aug 2017 19:13:56 +0000 (21:13 +0200)]
qapi-schema: Collect sockets stuff in qapi/sockets.json

Cc: "Daniel P. Berrange" <berrange@redhat.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503602048-12268-5-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
6 years agoqapi-schema: Rocker doc section contains unrelated stuff, fix
Markus Armbruster [Thu, 24 Aug 2017 19:13:55 +0000 (21:13 +0200)]
qapi-schema: Rocker doc section contains unrelated stuff, fix

Bug: section "Rocker switch device" starts with the rocker stuff, but
then has unrelated stuff, like ReplayMode, xen-load-devices-state, ...

Cause: rocker.json is included in the middle of section "QMP commands".

Fix: include it in a sane place, namely next to the other sub-schemas.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1503602048-12268-4-git-send-email-armbru@redhat.com>

6 years agoqapi-schema: Introspection doc is in the wrong section, fix
Markus Armbruster [Thu, 24 Aug 2017 19:13:54 +0000 (21:13 +0200)]
qapi-schema: Introspection doc is in the wrong section, fix

Bug: introspection documentation is in section "Tracing commands".

Cause: sub-schema qapi/introspect.json lacks a section header, and
therefore goes into whatever section precedes its include.

Fix: add a section header.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1503602048-12268-3-git-send-email-armbru@redhat.com>

6 years agoqapi-schema: Document how generated documentation is ordered
Markus Armbruster [Thu, 24 Aug 2017 19:13:53 +0000 (21:13 +0200)]
qapi-schema: Document how generated documentation is ordered

Documentation generated with qapi2texi.py is in source order, with
included sub-schemas inserted at the first include directive
(subsequent include directives have no effect).  To get a sane and
stable order, it's best to include each sub-schema just once, or
include it first in qapi-schema.json.  Document that.

While there, drop a few redundant comments.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1503602048-12268-2-git-send-email-armbru@redhat.com>

6 years agoqlit: Tighten QLit list vs QList comparison
Marc-André Lureau [Fri, 25 Aug 2017 10:59:11 +0000 (12:59 +0200)]
qlit: Tighten QLit list vs QList comparison

We check that all members of the QLit list are also in the QList.  We
neglect to check the other direction.  Fix that.

While there, use QLIST_FOREACH_ENTRY() to simplify the code and break
the loop on the first mismatch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170825105913.4060-13-marcandre.lureau@redhat.com>
[Commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqlit: Tighten QLit dict vs QDict comparison
Marc-André Lureau [Fri, 25 Aug 2017 10:59:10 +0000 (12:59 +0200)]
qlit: Tighten QLit dict vs QDict comparison

We check that all members of the QLit dictionary are also in the
QDict.  We neglect to check the other direction.

Comparing the number of members suffices, because QDict can't
contain duplicate members, and putting duplicates in a QLit is a
programming error.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170825105913.4060-12-marcandre.lureau@redhat.com>
[Commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agotests/check-qlit: New, covering qobject/qlit.c
Marc-André Lureau [Fri, 25 Aug 2017 10:59:09 +0000 (12:59 +0200)]
tests/check-qlit: New, covering qobject/qlit.c

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170825105913.4060-11-marcandre.lureau@redhat.com>
[Copyright notice correction squashed in, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqlit: Replace open-coded qnum_get_int() by call
Marc-André Lureau [Fri, 25 Aug 2017 10:59:08 +0000 (12:59 +0200)]
qlit: Replace open-coded qnum_get_int() by call

Bonus: rids us of a side effect in an assertion.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-10-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqlit: add QLIT_QNULL and QLIT_BOOL
Marc-André Lureau [Fri, 25 Aug 2017 10:59:07 +0000 (12:59 +0200)]
qlit: add QLIT_QNULL and QLIT_BOOL

As they are going to be used in the following patches.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-9-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqlit: make qlit_equal_qobject() take const arguments
Marc-André Lureau [Fri, 25 Aug 2017 10:59:06 +0000 (12:59 +0200)]
qlit: make qlit_equal_qobject() take const arguments

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-8-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqlit: make qlit_equal_qobject return a bool
Marc-André Lureau [Fri, 25 Aug 2017 10:59:05 +0000 (12:59 +0200)]
qlit: make qlit_equal_qobject return a bool

Make it more obvious about the expected return values.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-7-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqlit: rename compare_litqobj_to_qobj() to qlit_equal_qobject()
Marc-André Lureau [Fri, 25 Aug 2017 10:59:04 +0000 (12:59 +0200)]
qlit: rename compare_litqobj_to_qobj() to qlit_equal_qobject()

compare_litqobj_to_qobj() lacks a qlit_ prefix.  Moreover, "compare"
suggests -1, 0, +1 for less than, equal and greater than.  The
function actually returns non-zero for equal, zero for unequal.
Rename to qlit_equal_qobject().

Its return type will be cleaned up in the next patch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-6-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqlit: Change compound literals to initializers
Marc-André Lureau [Fri, 25 Aug 2017 10:59:03 +0000 (12:59 +0200)]
qlit: Change compound literals to initializers

The QLIT_QFOO() macros expand into compound literals.  Sadly, gcc
doesn't recognizes these as constant expressions (clang does), which
makes the macros useless for initializing objects with static storage
duration.

There is a gcc bug about it:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71713

Change the macros to expand into initializers.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20170825105913.4060-5-marcandre.lureau@redhat.com>
[Commit message improved]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqlit: use QLit prefix consistently
Marc-André Lureau [Fri, 25 Aug 2017 10:59:02 +0000 (12:59 +0200)]
qlit: use QLit prefix consistently

Rename from LiteralQ to QLit.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-4-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqlit: move qlit from check-qjson to qobject/
Marc-André Lureau [Fri, 25 Aug 2017 10:59:01 +0000 (12:59 +0200)]
qlit: move qlit from check-qjson to qobject/

Fix code style issues while at it, to please checkpatch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-3-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqdict: Add qdict_put_null() helper, and put it to use
Marc-André Lureau [Fri, 25 Aug 2017 10:59:00 +0000 (12:59 +0200)]
qdict: Add qdict_put_null() helper, and put it to use

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20170825105913.4060-2-marcandre.lureau@redhat.com>
[Update to qobject.cocci squashed in, commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
6 years agoqobject: Explain how QNum works, and why
Markus Armbruster [Tue, 22 Aug 2017 06:52:19 +0000 (08:52 +0200)]
qobject: Explain how QNum works, and why

Suggested-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1503384739-17207-1-git-send-email-armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
[Comment typos fixed]

6 years agotests/qmp-test: Add generic, basic test of query commands
Markus Armbruster [Fri, 11 Aug 2017 14:19:08 +0000 (16:19 +0200)]
tests/qmp-test: Add generic, basic test of query commands

A command is a query if it has no side effect and yields a result.
Such commands are typically named query-FOO, but there are exceptions.

The basic idea is to find candidates with query-qmp-schema, filter out
the ones that aren't queries with an explicit blacklist, and test the
remaining ones against a QEMU with no special arguments.

The current blacklist is just add-fd.

The test can't do queries with arguments, because it knows nothing
about the arguments.  No coverage for query-cpu-model-baseline,
query-cpu-model-comparison, query-cpu-model-expansion, query-rocker,
query-rocker-ports, query-rocker-of-dpa-flows, and
query-rocker-of-dpa-groups.

Most tested commands are expected to succeed.  The test does not check
the return value then.

query-balloon and query-vm-generation-id are expected to fail because
they need a virtio-balloon / vmgenid device to succeed, and this test
is too dumb to set one up.  Could be addressed later.

query-acpi-ospm-status and query-hotpluggable-cpus are expected to
fail because they require features provided only by special machine
types, and this test is too dumb to set that up.  Could also be
addressed later.

Several commands may either be functional or stubs that always fail,
depending on build configuration.  Ideally, the stubs shouldn't be in
query-qmp-schema, but that requires QAPI schema compile-time
configuration, which we don't have, yet.  Until we do, we need to
figure out whether a command is a stub.  When we have a suitable
CONFIG_FOO preprocessor symbol is available, use that.  Else,
simply blacklist the command for now.

We get basic test coverage for the following commands, except as
noted:

    qom-list-types
    query-acpi-ospm-status      (expected to fail)
    query-balloon               (expected to fail)
    query-block
    query-block-jobs
    query-blockstats
    query-chardev
    query-chardev-backends
    query-command-line-options
    query-commands
    query-cpu-definitions       (blacklisted for now)
    query-cpus
    query-dump
    query-dump-guest-memory-capability
    query-events
    query-fdsets
    query-gic-capabilities      (blacklisted for now)
    query-hotpluggable-cpus     (expected to fail)
    query-iothreads
    query-kvm
    query-machines
    query-memdev
    query-memory-devices
    query-mice
    query-migrate
    query-migrate-cache-size
    query-migrate-capabilities
    query-migrate-parameters
    query-name
    query-named-block-nodes
    query-pci                   (blacklisted for now)
    query-qmp-schema
    query-rx-filter
    query-spice
    query-status
    query-target
    query-tpm
    query-tpm-models
    query-tpm-types
    query-uuid
    query-version
    query-vm-generation-id      (expected to fail)
    query-vnc
    query-vnc-servers
    query-xen-replication-status

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1502461148-10154-1-git-send-email-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[Typos in code under #ifndef and in the commit message fixed]

6 years agoMerge remote-tracking branch 'remotes/ehabkost/tags/x86-and-machine-pull-request...
Peter Maydell [Fri, 1 Sep 2017 16:28:54 +0000 (17:28 +0100)]
Merge remote-tracking branch 'remotes/ehabkost/tags/x86-and-machine-pull-request' into staging

x86, cpu queue, 2017-09-01

CPU creation refactor plus x86 patches.

# gpg: Signature made Fri 01 Sep 2017 15:59:02 BST
# gpg:                using RSA key 0x2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF  D1AA 2807 936F 984D C5A6

* remotes/ehabkost/tags/x86-and-machine-pull-request: (29 commits)
  ppc: replace cpu_ppc_init() with cpu_generic_init()
  unicore32: replace uc32_cpu_init() with cpu_generic_init()
  openrisc: replace cpu_openrisc_init() with cpu_generic_init()
  moxie: replace cpu_moxie_init() with cpu_generic_init()
  lm32: replace cpu_lm32_init() with cpu_generic_init()
  x86: replace cpu_x86_init() with cpu_generic_init()
  cris: replace cpu_cris_init() with cpu_generic_init()
  arm: replace cpu_arm_init() with cpu_generic_init()
  sh4: replace cpu_sh4_init() with cpu_generic_init()
  tricore: replace cpu_tricore_init() with cpu_generic_init()
  xtensa: replace cpu_xtensa_init() with cpu_generic_init()
  tilegx: replace cpu_tilegx_init() with cpu_generic_init()
  nios2: replace cpu_nios2_init() with cpu_generic_init()
  microblaze: replace cpu_mb_init() with cpu_generic_init()
  m68k: replace cpu_m68k_init() with cpu_generic_init()
  hppa: replace cpu_hppa_init() with cpu_generic_init()
  alpha: replace cpu_alpha_init() with cpu_generic_init()
  s390x: replace cpu_s390x_init() with cpu_generic_init()
  sparc: replace cpu_sparc_init() with cpu_generic_init()
  sparc: make cpu feature parsing property based
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
6 years agoppc: replace cpu_ppc_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:48 +0000 (18:31 +0200)]
ppc: replace cpu_ppc_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Hervé Poussineau <hpoussin@reactos.org>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1503592308-93913-26-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agounicore32: replace uc32_cpu_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:47 +0000 (18:31 +0200)]
unicore32: replace uc32_cpu_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1503592308-93913-25-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agoopenrisc: replace cpu_openrisc_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:46 +0000 (18:31 +0200)]
openrisc: replace cpu_openrisc_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Stafford Horne <shorne@gmail.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1503592308-93913-24-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agomoxie: replace cpu_moxie_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:45 +0000 (18:31 +0200)]
moxie: replace cpu_moxie_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1503592308-93913-23-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agolm32: replace cpu_lm32_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:44 +0000 (18:31 +0200)]
lm32: replace cpu_lm32_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Michael Walle <michael@walle.cc>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1503592308-93913-22-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agox86: replace cpu_x86_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:43 +0000 (18:31 +0200)]
x86: replace cpu_x86_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1503592308-93913-21-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agocris: replace cpu_cris_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:42 +0000 (18:31 +0200)]
cris: replace cpu_cris_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1503592308-93913-20-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agoarm: replace cpu_arm_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:41 +0000 (18:31 +0200)]
arm: replace cpu_arm_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1503592308-93913-19-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agosh4: replace cpu_sh4_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:40 +0000 (18:31 +0200)]
sh4: replace cpu_sh4_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1503592308-93913-18-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agotricore: replace cpu_tricore_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:39 +0000 (18:31 +0200)]
tricore: replace cpu_tricore_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1503592308-93913-17-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agoxtensa: replace cpu_xtensa_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:38 +0000 (18:31 +0200)]
xtensa: replace cpu_xtensa_init() with cpu_generic_init()

call xtensa_irq_init() at realize time which makes
cpu_xtensa_init() like generic cpu creation function.
As result we can replace it with cpu_generic_init()
which does the same job, reducing code duplication a bit.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1503592308-93913-16-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agotilegx: replace cpu_tilegx_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:37 +0000 (18:31 +0200)]
tilegx: replace cpu_tilegx_init() with cpu_generic_init()

cpu_tilegx_init() always falls back to TYPE_TILEGX_CPU object
regardless of cpu_model. Put fallback logic into
tilegx_cpu_class_by_name() which would translate any cpu_model
into TYPE_TILEGX_CPU class and replace cpu_tilegx_init()
with cpu_generic_init().

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1503592308-93913-15-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agonios2: replace cpu_nios2_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:36 +0000 (18:31 +0200)]
nios2: replace cpu_nios2_init() with cpu_generic_init()

cpu_nios2_init() always falls back to TYPE_NIOS2_CPU object
regardless of cpu_model. Put fallback logic into
nios2_cpu_class_by_name() which would translate any cpu_model
into TYPE_NIOS2_CPU class and replace cpu_nios2_init()
with cpu_generic_init()

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1503592308-93913-14-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agomicroblaze: replace cpu_mb_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:35 +0000 (18:31 +0200)]
microblaze: replace cpu_mb_init() with cpu_generic_init()

cpu_mb_init() always falls back to TYPE_MICROBLAZE_CPU object
regardless of cpu_model. Put fallback logic into
mb_cpu_class_by_name() which would translate any cpu_model
into TYPE_MICROBLAZE_CPU class and replace cpu_mb_init()
with cpu_generic_init().

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1503592308-93913-13-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agom68k: replace cpu_m68k_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:34 +0000 (18:31 +0200)]
m68k: replace cpu_m68k_init() with cpu_generic_init()

call register_m68k_insns() at realize time which makes
cpu_m68k_init() typical object creation function.
As result we can replace it with cpu_generic_init()
which does the same job, reducing code duplication a bit.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Tested-by: Thomas Huth <huth@tuxfamily.org>
Acked-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <1503592308-93913-12-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agohppa: replace cpu_hppa_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:33 +0000 (18:31 +0200)]
hppa: replace cpu_hppa_init() with cpu_generic_init()

drop custom cpu_hppa_init() in favor of cpu_generic_init(),
to make cpu_generic_init() work all we need is to provide
cc->class_by_name callback that would resolve any cpu_model
to the sole TYPE_HPPA_CPU to match current behaviour.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Richard Henderson <rth@twiddle.net>
Message-Id: <1503592308-93913-11-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agoalpha: replace cpu_alpha_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:32 +0000 (18:31 +0200)]
alpha: replace cpu_alpha_init() with cpu_generic_init()

cpu_alpha_init() used to provide default fallback if invalid
(i.e. non existent) cpu_model were provided.

dp264 machine provides its own default so sole user of fallback
is [bsd|linux]-user targets which specifies 'any' cpu model that
fallbacks to "ev67" in cpu_alpha_init(). Push fallback handling
into alpha_cpu_class_by_name() and replace cpu_alpha_init() with
cpu_generic_init().

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Richard Henderson <rth@twiddle.net>
Message-Id: <1503592308-93913-10-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agos390x: replace cpu_s390x_init() with cpu_generic_init()
Igor Mammedov [Thu, 31 Aug 2017 13:19:38 +0000 (15:19 +0200)]
s390x: replace cpu_s390x_init() with cpu_generic_init()

cpu_s390x_init() is used only *-user targets indirectly
via cpu_init() macro and has a hack to assign ids to created
cpus (I'm not sure if 'id' really matters to *-user emulation).

So to on safe side, instead of having custom wrapper to do numbering
replace it with cpu_generic_init() and use S390CPUClass::next_cpu_id
which could serve the same purpose as static variable and move cpu->id
initialization to s390_cpu_initfn for CONFIG_USER_ONLY use-case.

PS:
ifdef is ugly but it allows us to hide s390x detail that isn't
set by *-user targets and reuse generic cpu creation utility
for btoh machine and user emulation.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Cornelia Huck <cohuck@redhat.com>
Message-Id: <1504185578-80843-1-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agosparc: replace cpu_sparc_init() with cpu_generic_init()
Igor Mammedov [Thu, 24 Aug 2017 16:31:30 +0000 (18:31 +0200)]
sparc: replace cpu_sparc_init() with cpu_generic_init()

it's just a wrapper, drop it and use cpu_generic_init() directly

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1503592308-93913-8-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agosparc: make cpu feature parsing property based
Igor Mammedov [Fri, 25 Aug 2017 14:47:40 +0000 (16:47 +0200)]
sparc: make cpu feature parsing property based

with features converted to properties we can use the same
approach as x86 for features parsing and drop legacy
approach that manipulated CPU instance directly.
New sparc_cpu_parse_features() will allow only +-feat
and explicitly disable feat=on|off syntax for now.

With that in place and sparc_cpu_parse_features() providing
generic CPUClass::parse_features callback, the cpu_sparc_init()
will do the same job as cpu_generic_init() so replace content
of cpu_sparc_init() with it.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1503672460-109436-1-git-send-email-imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agosparc: move adhoc CPUSPARCState initialization to realize time
Igor Mammedov [Thu, 24 Aug 2017 16:31:28 +0000 (18:31 +0200)]
sparc: move adhoc CPUSPARCState initialization to realize time

SPARCCPU::env was initialized from previously set properties
(with help of sparc_cpu_parse_features) in cpu_sparc_register().
However there is not reason to keep it there as this task is
typically done at realize time. So move post properties
initialization into sparc_cpu_realizefn, which brings
cpu_sparc_init() closer to cpu_generic_init().

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1503592308-93913-6-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agosparc: convert cpu features to qdev properties
Igor Mammedov [Thu, 24 Aug 2017 16:31:27 +0000 (18:31 +0200)]
sparc: convert cpu features to qdev properties

SPARC is the last target that uses legacy way of parsing
and initializing cpu features, drop legacy approach and
convert features to properties so that SPARC could as minimum
benefit from generic cpu_generic_init(), common with
x86 +-feat parser

PS:
the main purpose is to remove legacy way of cpu creation as
a blocker for unifying cpu creation code across targets.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1503592308-93913-5-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agosparc: embed sparc_def_t into CPUSPARCState
Igor Mammedov [Thu, 24 Aug 2017 16:31:26 +0000 (18:31 +0200)]
sparc: embed sparc_def_t into CPUSPARCState

Make CPUSPARCState::def embedded so it would be allocated as part
of cpu instance and we won't have to worry about cleaning def pointer
up mannualy on cpu destruction.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1503592308-93913-4-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
6 years agosparc: convert cpu models to SPARC cpu subclasses
Igor Mammedov [Thu, 24 Aug 2017 16:31:25 +0000 (18:31 +0200)]
sparc: convert cpu models to SPARC cpu subclasses

QOMfy cpu models handling introducing propper cpu types
for each cpu model.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <1503592308-93913-3-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>