]> Git Repo - qemu.git/log
qemu.git
3 years agotarget/ppc: code motion from translate_init.c.inc to gdbstub.c
Bruno Larsen (billionai) [Mon, 26 Apr 2021 18:47:06 +0000 (15:47 -0300)]
target/ppc: code motion from translate_init.c.inc to gdbstub.c

All the code related to gdb has been moved from translate_init.c.inc
file to the gdbstub.c file, where it makes more sense.

Version 4 fixes the omission of internal.h in gdbstub, mentioned in
<[email protected]>, and the extra blank line.

Signed-off-by: Bruno Larsen (billionai) <[email protected]>
Suggested-by: Fabiano Rosas <[email protected]>
Message-Id: <20210426184706[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agospapr_drc.c: handle hotunplug errors in drc_unisolate_logical()
Daniel Henrique Barboza [Tue, 20 Apr 2021 16:51:00 +0000 (13:51 -0300)]
spapr_drc.c: handle hotunplug errors in drc_unisolate_logical()

At this moment, PAPR does not provide a way to report errors during a
device removal operation. This led the pSeries machine to implement
extra mechanisms to try to fallback and recover from an error that might
have happened during the hotunplug in the guest side. This started to
change a bit with commit fe1831eff8a4 ("spapr_drc.c: use DRC
reconfiguration to cleanup DIMM unplug state"), where one way to
fallback from a memory removal error was introduced.

Around the same time, in [1], the idea of using RTAS set-indicator for
this role was first introduced. The RTAS set-indicator call, when
attempting to UNISOLATE a DRC that is already UNISOLATED or CONFIGURED,
returns RTAS_OK and does nothing else for both QEMU and phyp. This gives
us an opportunity to use this behavior to signal the hypervisor layer
when a device removal errir happens, allowing QEMU/phyp to do a proper
error handling. Using set-indicator to report HP errors isn't strange to
PAPR, as per R1-13.5.3.4-4. of table 13.7 of current PAPR [2]:

"For all DR options: If this is a DR operation that involves the user
insert- ing a DR entity, then if the firmware can determine that the
inserted entity would cause a system disturbance, then the set-indicator
RTAS call must not unisolate the entity and must return an error status
which is unique to the particular error."

A change was proposed to the pSeries Linux kernel to call set-indicator
to move a DRC to 'unisolate' in the case of a hotunplug error in the
guest side [3]. Setting a DRC that is already unisolated or configured to
'unisolate' is a no-op (returns RTAS_OK) for QEMU and also for phyp.
Being a benign change for hypervisors that doesn't care about handling
such errors, we expect the kernel to accept this change at some point.

This patch prepares the pSeries machine for this new kernel feature by
changing drc_unisolate_logical() to handle guest side hotunplug errors.
For CPUs it's a simple matter of setting drc->unplug_requested to 'false',
while for LMBs the process is similar to the rollback that is done in
rtas_ibm_configure_connector().

[1] https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg06395.html
[2] https://openpowerfoundation.org/wp-content/uploads/2020/07/LoPAR-20200611.pdf
[3] https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210416210216[email protected]/

Reviewed-by: David Gibson <[email protected]>
Signed-off-by: Daniel Henrique Barboza <[email protected]>
Message-Id: <20210420165100[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agospapr.h: increase FDT_MAX_SIZE
Daniel Henrique Barboza [Thu, 8 Apr 2021 20:40:49 +0000 (17:40 -0300)]
spapr.h: increase FDT_MAX_SIZE

Certain SMP topologies stress, e.g. 1 thread/core, 2048 cores and
1 socket, stress the current maximum size of the pSeries FDT:

Calling ibm,client-architecture-support...qemu-system-ppc64: error
creating device tree: (fdt_setprop(fdt, offset,
"ibm,processor-segment-sizes", segs, sizeof(segs))): FDT_ERR_NOSPACE

2048 is the default NR_CPUS value for the pSeries kernel. It's expected
that users will want QEMU to be able to handle this kind of
configuration.

Bumping FDT_MAX_SIZE to 2MB is enough for these setups to be created.

Signed-off-by: Daniel Henrique Barboza <[email protected]>
Message-Id: <20210408204049[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agospapr.c: do not use MachineClass::max_cpus to limit CPUs
Daniel Henrique Barboza [Thu, 8 Apr 2021 20:40:48 +0000 (17:40 -0300)]
spapr.c: do not use MachineClass::max_cpus to limit CPUs

Up to this patch, 'max_cpus' value is hardcoded to 1024 (commit
6244bb7e5811). In theory this patch would simply bump it to 2048, since
it's the default NR_CPUS kernel setting for ppc64 servers nowadays, but
the whole mechanic of MachineClass:max_cpus is flawed for the pSeries
machine. The two supported accelerators, KVM and TCG, can live without
it.

TCG guests don't have a theoretical limit. The user must be free to
emulate as many CPUs as the hardware is capable of. And even if there
were a limit, max_cpus is not the proper way to report it since it's a
common value checked by SMP code in machine_smp_parse() for KVM as well.

For KVM guests, the proper way to limit KVM CPUs is by host
configuration via NR_CPUS, not a QEMU hardcoded value. There is no
technical reason for a pSeries QEMU guest to forcefully stay below
NR_CPUS.

This hardcoded value also disregard hosts that might have a lower
NR_CPUS limit, say 512. In this case, machine.c:machine_smp_parse() will
allow a 1024 value to pass, but then kvm_init() will complain about it
because it will exceed NR_CPUS:

Number of SMP cpus requested (1024) exceeds the maximum cpus supported
by KVM (512)

A better 'max_cpus' value would consider host settings, but
MachineClass::max_cpus is defined well before machine_init() and
kvm_init(). We can't check for KVM limits because it's too soon, so we
end up making a guess.

This patch makes MachineClass:max_cpus settings innocuous by setting it
to INT32_MAX. machine.c:machine_smp_parse() will not fail the
verification based on max_cpus, letting kvm_init() do the checking with
actual host settings. And TCG guests get to do whatever the hardware is
capable of emulating.

Signed-off-by: Daniel Henrique Barboza <[email protected]>
Message-Id: <20210408204049[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agoppc: Rename current DAWR macros and variables
Ravi Bangoria [Mon, 12 Apr 2021 11:44:32 +0000 (17:14 +0530)]
ppc: Rename current DAWR macros and variables

Power10 is introducing second DAWR. Use real register names (with
suffix 0) from ISA for current macros and variables used by Qemu.

One exception to this is KVM_REG_PPC_DAWR[X]. This is from kernel
uapi header and thus not changed in kernel as well as Qemu.

Signed-off-by: Ravi Bangoria <[email protected]>
Reviewed-by: Greg Kurz <[email protected]>
Reviewed-by: David Gibson <[email protected]>
Message-Id: <20210412114433[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: POWER10 supports scv
Nicholas Piggin [Thu, 15 Apr 2021 05:42:25 +0000 (15:42 +1000)]
target/ppc: POWER10 supports scv

This must have slipped through the cracks between adding POWER10 support
and scv support.

Signed-off-by: Nicholas Piggin <[email protected]>
Message-Id: <20210415054227.1793812[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Fix POWER9 radix guest HV interrupt AIL behaviour
Nicholas Piggin [Thu, 15 Apr 2021 05:42:24 +0000 (15:42 +1000)]
target/ppc: Fix POWER9 radix guest HV interrupt AIL behaviour

ISA v3.0 radix guest execution has a quirk in AIL behaviour such that
the LPCR[AIL] value can apply to hypervisor interrupts.

This affects machines that emulate HV=1 mode (i.e., powernv9).

Signed-off-by: Nicholas Piggin <[email protected]>
Message-Id: <20210415054227.1793812[email protected]>
Reviewed-by: Fabiano Rosas <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agodocs/system: ppc: Add documentation for ppce500 machine
Bin Meng [Tue, 6 Apr 2021 07:38:16 +0000 (15:38 +0800)]
docs/system: ppc: Add documentation for ppce500 machine

This adds detailed documentation for PowerPC `ppce500` machine,
including the following information:

- Supported devices
- Hardware configuration information
- Boot options
- Running Linux kernel
- Running U-Boot

Signed-off-by: Bin Meng <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agoroms/u-boot: Bump ppce500 u-boot to v2021.04 to fix broken pci support
Bin Meng [Tue, 6 Apr 2021 04:40:16 +0000 (12:40 +0800)]
roms/u-boot: Bump ppce500 u-boot to v2021.04 to fix broken pci support

When QEMU originally supported the ppce500 machine back in Jan 2014,
it was created with a 1:1 mapping of PCI bus address. Things seemed
to change rapidly that in Nov 2014 with the following QEMU commits:

commit e6b4e5f4795b ("PPC: e500: Move CCSR and MMIO space to upper end of address space")

and

commit cb3778a0455a ("PPC: e500 pci host: Add support for ATMUs")

the PCI memory and IO physical address were moved to beyond 4 GiB,
but PCI bus address remained below 4 GiB, hence a non-identity
mapping was created. Unfortunately corresponding U-Boot updates
were missed along with the QEMU changes and the U-Boot QEMU ppce500
PCI support has been broken since then, until this issue was fixed
recently in U-Boot mainline v2021.04 release, specifically by the
following U-Boot series:

http://patchwork.ozlabs.org/project/uboot/list/?series=230985&state=*

The cross-compilation toolchain used to build the U-Boot image is:
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/x86_64/10.1.0/x86_64-gcc-10.1.0-nolibc-powerpc-linux.tar.xz

Signed-off-by: Bin Meng <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agoroms/Makefile: Update ppce500 u-boot build directory name
Bin Meng [Tue, 6 Apr 2021 05:09:44 +0000 (13:09 +0800)]
roms/Makefile: Update ppce500 u-boot build directory name

Currently building ppce500 u-boot image results in

  modified:   roms/u-boot (untracked content)

As roms/u-boot/.gitignore indicates, update the build directory
name to build-e500 to eliminate this message.

Signed-off-by: Bin Meng <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agoppc/spapr: Add support for implement support for H_SCM_HEALTH
Vaibhav Jain [Fri, 2 Apr 2021 10:21:28 +0000 (15:51 +0530)]
ppc/spapr: Add support for implement support for H_SCM_HEALTH

Add support for H_SCM_HEALTH hcall described at [1] for spapr
nvdimms. This enables guest to detect the 'unarmed' status of a
specific spapr nvdimm identified by its DRC and if its unarmed, mark
the region backed by the nvdimm as read-only.

The patch adds h_scm_health() to handle the H_SCM_HEALTH hcall which
returns two 64-bit bitmaps (health bitmap, health bitmap mask) derived
from 'struct nvdimm->unarmed' member.

Linux kernel side changes to enable handling of 'unarmed' nvdimms for
ppc64 are proposed at [2].

References:
[1] "Hypercall Op-codes (hcalls)"
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/powerpc/papr_hcalls.rst#n220
[2] "powerpc/papr_scm: Mark nvdimm as unarmed if needed during probe"
    https://lore.kernel.org/linux-nvdimm/20210329113103[email protected]/

Signed-off-by: Vaibhav Jain <[email protected]>
Message-Id: <20210402102128[email protected]>
Reviewed-by: Greg Kurz <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agospapr: Rename RTAS_MAX_ADDR to FDT_MAX_ADDR
Alexey Kardashevskiy [Wed, 31 Mar 2021 02:51:23 +0000 (13:51 +1100)]
spapr: Rename RTAS_MAX_ADDR to FDT_MAX_ADDR

SLOF instantiates RTAS since
744a928ccee9 ("spapr: Stop providing RTAS blob")
so the max address applies to the FDT only.

This renames the macro and fixes up the comment.

This should not cause any behavioral change.

Signed-off-by: Alexey Kardashevskiy <[email protected]>
Message-Id: <20210331025123[email protected]>
Reviewed-by: Greg Kurz <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agohw/ppc: Add emulation of Genesi/bPlan Pegasos II
BALATON Zoltan [Thu, 25 Mar 2021 13:50:39 +0000 (14:50 +0100)]
hw/ppc: Add emulation of Genesi/bPlan Pegasos II

Add new machine called pegasos2 emulating the Genesi/bPlan Pegasos II,
a PowerPC board based on the Marvell MV64361 system controller and the
VIA VT8231 integrated south bridge/superio chips. It can run Linux,
AmigaOS and a wide range of MorphOS versions. Currently a firmware ROM
image is needed to boot and only MorphOS has a video driver to produce
graphics output. Linux could work too but distros that supported this
machine don't include usual video drivers so those only run with
serial console for now.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <30cbfb9cbe6f46a1e15a69a75fac45ac39340122.1616680239[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agohw/pci-host: Add emulation of Marvell MV64361 PPC system controller
BALATON Zoltan [Thu, 25 Mar 2021 13:50:39 +0000 (14:50 +0100)]
hw/pci-host: Add emulation of Marvell MV64361 PPC system controller

The Marvell Discovery II aka. MV64361 is a PowerPC system controller
chip that is used on the pegasos2 PPC board. This adds emulation of it
that models the device enough to boot guests on this board. The
mv643xx.h header with register definitions is taken from Linux 4.15.10
only fixing white space errors, removing not needed parts and changing
formatting for QEMU coding style.

Signed-off-by: BALATON Zoltan <[email protected]>
Message-Id: <79545ebd03bfe0665b73d2d7cbc74fdf3d62629e.1616680239[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agovt82c686: Add emulation of VT8231 south bridge
BALATON Zoltan [Thu, 25 Mar 2021 13:50:39 +0000 (14:50 +0100)]
vt82c686: Add emulation of VT8231 south bridge

Add emulation of VT8231 south bridge ISA part based on the similar
VT82C686B but implemented in a separate subclass that holds the
differences while reusing parts that can be shared.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <10abc9f89854e7c980b9731c33d25a2e307e9c4f.1616680239[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agovt82c686: Introduce abstract TYPE_VIA_ISA and base vt82c686b_isa on it
BALATON Zoltan [Thu, 25 Mar 2021 13:50:39 +0000 (14:50 +0100)]
vt82c686: Introduce abstract TYPE_VIA_ISA and base vt82c686b_isa on it

To allow reusing ISA bridge emulation for vt8231_isa move the device
state of vt82c686b_isa emulation in an abstract via_isa class. This
change breaks migration back compatibility but this is not an issue
for Fuloong2E machine which is not versioned or migration supported.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <0cb8fc69c7aaa555589181931b881335fecd2ef3.1616680239[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agovt82c686: Add VT8231_SUPERIO based on VIA_SUPERIO
BALATON Zoltan [Thu, 25 Mar 2021 13:50:39 +0000 (14:50 +0100)]
vt82c686: Add VT8231_SUPERIO based on VIA_SUPERIO

The VT8231 south bridge is very similar to VT82C686B but there are
some differences in register addresses and functionality, e.g. the
VT8231 only has one serial port. This commit adds VT8231_SUPERIO
subclass based on the abstract VIA_SUPERIO class to emulate the
superio part of VT8231.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <8108809321f9ecf3fb1aea22ddaeccc7c3a57c8e.1616680239[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agovt82c686: QOM-ify superio related functionality
BALATON Zoltan [Thu, 25 Mar 2021 13:50:39 +0000 (14:50 +0100)]
vt82c686: QOM-ify superio related functionality

Collect superio functionality and its controlling config registers
handling in an abstract VIA_SUPERIO class that is a subclass of
ISA_SUPERIO and put vt82c686b specific parts in a subclass of this
abstract class.

Signed-off-by: BALATON Zoltan <[email protected]>
Reviewed-by: Mark Cave-Ayland <[email protected]>
Message-Id: <fbcc8cc8baf83f327612a1ef1c14bcbcdb0e7edb.1616680239[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Validate hflags with CONFIG_DEBUG_TCG
Richard Henderson [Tue, 23 Mar 2021 18:43:40 +0000 (12:43 -0600)]
target/ppc: Validate hflags with CONFIG_DEBUG_TCG

Verify that hflags was updated correctly whenever we change
cpu state that is used by hflags.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210323184340[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agolinux-user/ppc: Fix msr updates for signal handling
Richard Henderson [Tue, 23 Mar 2021 18:43:39 +0000 (12:43 -0600)]
linux-user/ppc: Fix msr updates for signal handling

In save_user_regs, there are two bugs where we OR in a bit number
instead of the bit, clobbering the low bits of MSR.  However:

The MSR_VR and MSR_SPE bits control the availability of the insns.
If the bits were not already set in MSR, then any attempt to access
those registers would result in SIGILL.

For linux-user, we always initialize MSR to the capabilities
of the cpu.  We *could* add checks vs MSR where we currently
check insn_flags and insn_flags2, but we know they match.

Also, there's a stray cut-and-paste comment in restore.

Then, do not force little-endian binaries into big-endian mode.

Finally, use ppc_store_msr for the update to affect hflags.
Which is the reason none of these bugs were previously noticed.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210323184340[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Remove env->immu_idx and env->dmmu_idx
Richard Henderson [Tue, 23 Mar 2021 18:43:38 +0000 (12:43 -0600)]
target/ppc: Remove env->immu_idx and env->dmmu_idx

We weren't recording MSR_GS in hflags, which means that BookE
memory accesses were essentially random vs Guest State.

Instead of adding this bit directly, record the completed mmu
indexes instead.  This makes it obvious that we are recording
exactly the information that we need.

This also means that we can stop directly recording MSR_IR.

Reviewed-by: David Gibson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210323184340[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Remove MSR_SA and MSR_AP from hflags
Richard Henderson [Tue, 23 Mar 2021 18:43:37 +0000 (12:43 -0600)]
target/ppc: Remove MSR_SA and MSR_AP from hflags

Nothing within the translator -- or anywhere else for that
matter -- checks MSR_SA or MSR_AP on the 602.  This may be
a mistake.  However, for the moment, we need not record these
bits in hflags.

This allows us to simplify HFLAGS_VSX computation by moving
it to overlap with MSR_VSX.

Reviewed-by: David Gibson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210323184340[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Put LPCR[GTSE] in hflags
Richard Henderson [Tue, 23 Mar 2021 18:43:36 +0000 (12:43 -0600)]
target/ppc: Put LPCR[GTSE] in hflags

Because this bit was not in hflags, the privilege check
for tlb instructions was essentially random.
Recompute hflags when storing to LPCR.

Reviewed-by: David Gibson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210323184340[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Create helper_scv
Richard Henderson [Tue, 23 Mar 2021 18:43:35 +0000 (12:43 -0600)]
target/ppc: Create helper_scv

Perform the test against FSCR_SCV at runtime, in the helper.

This means we can remove the incorrect set against SCV in
ppc_tr_init_disas_context and do not need to add an HFLAGS bit.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210323184340[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Put dbcr0 single-step bits into hflags
Richard Henderson [Tue, 23 Mar 2021 18:43:34 +0000 (12:43 -0600)]
target/ppc: Put dbcr0 single-step bits into hflags

Because these bits were not in hflags, the code generated
for single-stepping on BookE was essentially random.
Recompute hflags when storing to dbcr0.

Reviewed-by: David Gibson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210323184340[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Reduce env->hflags to uint32_t
Richard Henderson [Tue, 23 Mar 2021 18:43:33 +0000 (12:43 -0600)]
target/ppc: Reduce env->hflags to uint32_t

It will be stored in tb->flags, which is also uint32_t,
so let's use the correct size.

Reviewed-by: Cédric Le Goater <[email protected]>
Reviewed-by: David Gibson <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210323184340[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Disconnect hflags from MSR
Richard Henderson [Tue, 23 Mar 2021 18:43:32 +0000 (12:43 -0600)]
target/ppc: Disconnect hflags from MSR

Copying flags directly from msr has drawbacks: (1) msr bits
mean different things per cpu, (2) msr has 64 bits on 64 cpus
while tb->flags has only 32 bits.

Create a enum to define these bits.  Document the origin of each bit
and validate those bits that must match MSR.  This fixes the
truncation of env->hflags to tb->flags, because we no longer
have hflags bits set above bit 31.

Most of the code in ppc_tr_init_disas_context is moved over to
hreg_compute_hflags.  Some of it is simple extractions from msr,
some requires examining other cpu flags.  Anything that is moved
becomes a simple extract from hflags in ppc_tr_init_disas_context.

Several existing bugs are left in ppc_tr_init_disas_context, where
additional changes are required -- to be addressed in future patches.

Remove a broken #if 0 block.

Reported-by: Ivan Warren <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210323184340[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Extract post_load_update_msr
Richard Henderson [Tue, 23 Mar 2021 18:43:31 +0000 (12:43 -0600)]
target/ppc: Extract post_load_update_msr

Extract post_load_update_msr to share between cpu_load_old
and cpu_post_load in updating the msr.

Suggested-by: Cédric Le Goater <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210323184340[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agohw/ppc/spapr_rtas: Update hflags after setting msr
Richard Henderson [Mon, 15 Mar 2021 18:46:13 +0000 (12:46 -0600)]
hw/ppc/spapr_rtas: Update hflags after setting msr

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210315184615.1985590[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agohw/ppc/pnv_core: Update hflags after setting msr
Richard Henderson [Mon, 15 Mar 2021 18:46:12 +0000 (12:46 -0600)]
hw/ppc/pnv_core: Update hflags after setting msr

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210315184615.1985590[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Fix comment for MSR_FE{0,1}
Richard Henderson [Mon, 15 Mar 2021 18:46:04 +0000 (12:46 -0600)]
target/ppc: Fix comment for MSR_FE{0,1}

As per hreg_compute_hflags:

  We 'forget' FE0 & FE1: we'll never generate imprecise exceptions

remove the hflags marker from the respective comments.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210315184615.1985590[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Retain hflags_nmsr only for migration
Richard Henderson [Mon, 15 Mar 2021 18:46:03 +0000 (12:46 -0600)]
target/ppc: Retain hflags_nmsr only for migration

We have eliminated all normal uses of hflags_nmsr.  We need
not even compute it except when we want to migrate.  Rename
the field to emphasize this.

Remove the fixme comment for migrating access_type.  This value
is only ever used with the current executing instruction, and
is never live when the cpu is halted for migration.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210315184615.1985590[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Do not call hreg_compute_mem_idx after ppc_store_msr
Richard Henderson [Mon, 15 Mar 2021 18:46:02 +0000 (12:46 -0600)]
target/ppc: Do not call hreg_compute_mem_idx after ppc_store_msr

In ppc_store_msr we call hreg_compute_hflags, which itself
calls hreg_compute_mem_idx.  Rely on ppc_store_msr to update
everything required by the msr update.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210315184615.1985590[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Properly sync cpu state with new msr in cpu_load_old
Richard Henderson [Mon, 15 Mar 2021 18:46:01 +0000 (12:46 -0600)]
target/ppc: Properly sync cpu state with new msr in cpu_load_old

Match cpu_post_load in using ppc_store_msr to set all of
the cpu state implied by the value of msr.  Do not restore
hflags or hflags_nmsr, as we recompute them in ppc_store_msr.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210315184615.1985590[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Move 601 hflags adjustment to hreg_compute_hflags
Richard Henderson [Mon, 15 Mar 2021 18:46:00 +0000 (12:46 -0600)]
target/ppc: Move 601 hflags adjustment to hreg_compute_hflags

Keep all hflags computation in one place, as this will be
especially important later.

Introduce a new POWERPC_FLAG_HID0_LE bit to indicate when
LE should be taken from HID0.  This appears to be set if
and only if POWERPC_FLAG_RTC_CLK is set, but we're not
short of bits and having both names will avoid confusion.

Note that this was the only user of hflags_nmsr, so we can
perform a straight assignment rather than mask and set.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210315184615.1985590[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agotarget/ppc: Move helper_regs.h functions out-of-line
Richard Henderson [Mon, 15 Mar 2021 18:45:59 +0000 (12:45 -0600)]
target/ppc: Move helper_regs.h functions out-of-line

Move the functions to a new file, helper_regs.c.

Note int_helper.c was relying on helper_regs.h to
indirectly include qemu/log.h.

Signed-off-by: Richard Henderson <[email protected]>
Message-Id: <20210315184615.1985590[email protected]>
Reviewed-by: Cédric Le Goater <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agohw/ppc/mac_newworld: Restrict RAM to 2 GiB
Philippe Mathieu-Daudé [Tue, 6 Apr 2021 08:48:42 +0000 (10:48 +0200)]
hw/ppc/mac_newworld: Restrict RAM to 2 GiB

On Mac99 and newer machines, the Uninorth PCI host bridge maps
the PCI hole region at 2GiB, so the RAM area beside 2GiB is not
accessible by the CPU. Restrict the memory to 2GiB to avoid
problems such the one reported in the buglink.

Buglink: https://bugs.launchpad.net/qemu/+bug/1922391
Reported-by: Håvard Eidnes <[email protected]>
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Message-Id: <20210406084842.2859664[email protected]>
Reviewed-by: BALATON Zoltan <[email protected]>
Signed-off-by: David Gibson <[email protected]>
3 years agoMerge remote-tracking branch 'remotes/rth-gitlab/tags/pull-hex-20210502' into staging
Peter Maydell [Sun, 2 May 2021 15:23:05 +0000 (16:23 +0100)]
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-hex-20210502' into staging

Minor cleanups.
Finish the rest of the hexagon integer instructions.

# gpg: Signature made Sun 02 May 2021 15:38:17 BST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Richard Henderson <[email protected]>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth-gitlab/tags/pull-hex-20210502: (31 commits)
  Hexagon (target/hexagon) CABAC decode bin
  Hexagon (target/hexagon) load into shifted register instructions
  Hexagon (target/hexagon) load and unpack bytes instructions
  Hexagon (target/hexagon) bit reverse (brev) addressing
  Hexagon (target/hexagon) circular addressing
  Hexagon (target/hexagon) add A4_addp_c/A4_subp_c
  Hexagon (target/hexagon) add A6_vminub_RdP
  Hexagon (target/hexagon) add A5_ACS (vacsh)
  Hexagon (target/hexagon) add F2_sfinvsqrta
  Hexagon (target/hexagon) add F2_sfrecipa instruction
  Hexagon (target/hexagon) compile all debug code
  Hexagon (target/hexagon) move QEMU_GENERATE to only be on during macros.h
  Hexagon (target/hexagon) cleanup reg_field_info definition
  Hexagon (target/hexagon) cleanup ternary operators in semantics
  Hexagon (target/hexagon) use softfloat for float-to-int conversions
  Hexagon (target/hexagon) replace float32_mul_pow2 with float32_scalbn
  Hexagon (target/hexagon) use softfloat default NaN and tininess
  Hexagon (target/hexagon) change type of softfloat_roundingmodes
  Hexagon (target/hexagon) remove unused carry_from_add64 function
  Hexagon (target/hexagon) change variables from int to bool when appropriate
  ...

Signed-off-by: Peter Maydell <[email protected]>
3 years agoMerge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210501' into staging
Peter Maydell [Sun, 2 May 2021 11:02:46 +0000 (12:02 +0100)]
Merge remote-tracking branch 'remotes/rth-gitlab/tags/pull-tcg-20210501' into staging

Include cleanups.
Decodetree enhancements for power10.

# gpg: Signature made Sat 01 May 2021 19:50:22 BST
# gpg:                using RSA key 7A481E78868B4DB6A85A05C064DF38E8AF7E215F
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Richard Henderson <[email protected]>" [full]
# Primary key fingerprint: 7A48 1E78 868B 4DB6 A85A  05C0 64DF 38E8 AF7E 215F

* remotes/rth-gitlab/tags/pull-tcg-20210501:
  decodetree: Extend argument set syntax to allow types
  decodetree: Add support for 64-bit instructions
  decodetree: More use of f-strings
  decodetree: Introduce whex and whexC helpers
  exec: Remove accel/tcg/ from include paths

Signed-off-by: Peter Maydell <[email protected]>
3 years agoHexagon (target/hexagon) CABAC decode bin
Taylor Simpson [Fri, 9 Apr 2021 01:07:54 +0000 (20:07 -0500)]
Hexagon (target/hexagon) CABAC decode bin

The following instruction is added
    S2_cabacdecbin            Rdd32=decbin(Rss32,Rtt32)

Test cases added to tests/tcg/hexagon/misc.c

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) load into shifted register instructions
Taylor Simpson [Fri, 9 Apr 2021 01:07:53 +0000 (20:07 -0500)]
Hexagon (target/hexagon) load into shifted register instructions

The following instructions are added
    L2_loadalignb_io          Ryy32 = memb_fifo(Rs32+#s11:1)
    L2_loadalignh_io          Ryy32 = memh_fifo(Rs32+#s11:1)
    L4_loadalignb_ur          Ryy32 = memb_fifo(Rt32<<#u2+#U6)
    L4_loadalignh_ur          Ryy32 = memh_fifo(Rt32<<#u2+#U6)
    L4_loadalignb_ap          Ryy32 = memb_fifo(Re32=#U6)
    L4_loadalignh_ap          Ryy32 = memh_fifo(Re32=#U6)
    L2_loadalignb_pr          Ryy32 = memb_fifo(Rx32++Mu2)
    L2_loadalignh_pr          Ryy32 = memh_fifo(Rx32++Mu2)
    L2_loadalignb_pbr         Ryy32 = memb_fifo(Rx32++Mu2:brev)
    L2_loadalignh_pbr         Ryy32 = memh_fifo(Rx32++Mu2:brev)
    L2_loadalignb_pi          Ryy32 = memb_fifo(Rx32++#s4:1)
    L2_loadalignh_pi          Ryy32 = memh_fifo(Rx32++#s4:1)
    L2_loadalignb_pci         Ryy32 = memb_fifo(Rx32++#s4:1:circ(Mu2))
    L2_loadalignh_pci         Ryy32 = memh_fifo(Rx32++#s4:1:circ(Mu2))
    L2_loadalignb_pcr         Ryy32 = memb_fifo(Rx32++I:circ(Mu2))
    L2_loadalignh_pcr         Ryy32 = memh_fifo(Rx32++I:circ(Mu2))

Test cases in tests/tcg/hexagon/load_align.c

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) load and unpack bytes instructions
Taylor Simpson [Fri, 9 Apr 2021 01:07:52 +0000 (20:07 -0500)]
Hexagon (target/hexagon) load and unpack bytes instructions

The following instructions are added
    L2_loadbzw2_io          Rd32 = memubh(Rs32+#s11:1)
    L2_loadbzw4_io          Rdd32 = memubh(Rs32+#s11:1)
    L2_loadbsw2_io          Rd32 = membh(Rs32+#s11:1)
    L2_loadbsw4_io          Rdd32 = membh(Rs32+#s11:1)

    L4_loadbzw2_ur          Rd32 = memubh(Rt32<<#u2+#U6)
    L4_loadbzw4_ur          Rdd32 = memubh(Rt32<<#u2+#U6)
    L4_loadbsw2_ur          Rd32 = membh(Rt32<<#u2+#U6)
    L4_loadbsw4_ur          Rdd32 = membh(Rt32<<#u2+#U6)

    L4_loadbzw2_ap          Rd32 = memubh(Re32=#U6)
    L4_loadbzw4_ap          Rdd32 = memubh(Re32=#U6)
    L4_loadbsw2_ap          Rd32 = membh(Re32=#U6)
    L4_loadbsw4_ap          Rdd32 = membh(Re32=#U6)

    L2_loadbzw2_pr          Rd32 = memubh(Rx32++Mu2)
    L2_loadbzw4_pr          Rdd32 = memubh(Rx32++Mu2)
    L2_loadbsw2_pr          Rd32 = membh(Rx32++Mu2)
    L2_loadbsw4_pr          Rdd32 = membh(Rx32++Mu2)

    L2_loadbzw2_pbr         Rd32 = memubh(Rx32++Mu2:brev)
    L2_loadbzw4_pbr         Rdd32 = memubh(Rx32++Mu2:brev)
    L2_loadbsw2_pbr         Rd32 = membh(Rx32++Mu2:brev)
    L2_loadbsw4_pbr         Rdd32 = membh(Rx32++Mu2:brev)

    L2_loadbzw2_pi          Rd32 = memubh(Rx32++#s4:1)
    L2_loadbzw4_pi          Rdd32 = memubh(Rx32++#s4:1)
    L2_loadbsw2_pi          Rd32 = membh(Rx32++#s4:1)
    L2_loadbsw4_pi          Rdd32 = membh(Rx32++#s4:1)

    L2_loadbzw2_pci         Rd32 = memubh(Rx32++#s4:1:circ(Mu2))
    L2_loadbzw4_pci         Rdd32 = memubh(Rx32++#s4:1:circ(Mu2))
    L2_loadbsw2_pci         Rd32 = membh(Rx32++#s4:1:circ(Mu2))
    L2_loadbsw4_pci         Rdd32 = membh(Rx32++#s4:1:circ(Mu2))

    L2_loadbzw2_pcr         Rd32 = memubh(Rx32++I:circ(Mu2))
    L2_loadbzw4_pcr         Rdd32 = memubh(Rx32++I:circ(Mu2))
    L2_loadbsw2_pcr         Rd32 = membh(Rx32++I:circ(Mu2))
    L2_loadbsw4_pcr         Rdd32 = membh(Rx32++I:circ(Mu2))

Test cases in tests/tcg/hexagon/load_unpack.c

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) bit reverse (brev) addressing
Taylor Simpson [Fri, 9 Apr 2021 01:07:51 +0000 (20:07 -0500)]
Hexagon (target/hexagon) bit reverse (brev) addressing

The following instructions are added
    L2_loadrub_pbr          Rd32 = memub(Rx32++Mu2:brev)
    L2_loadrb_pbr           Rd32 = memb(Rx32++Mu2:brev)
    L2_loadruh_pbr          Rd32 = memuh(Rx32++Mu2:brev)
    L2_loadrh_pbr           Rd32 = memh(Rx32++Mu2:brev)
    L2_loadri_pbr           Rd32 = memw(Rx32++Mu2:brev)
    L2_loadrd_pbr           Rdd32 = memd(Rx32++Mu2:brev)
    S2_storerb_pbr          memb(Rx32++Mu2:brev).=.Rt32
    S2_storerh_pbr          memh(Rx32++Mu2:brev).=.Rt32
    S2_storerf_pbr          memh(Rx32++Mu2:brev).=.Rt.H32
    S2_storeri_pbr          memw(Rx32++Mu2:brev).=.Rt32
    S2_storerd_pbr          memd(Rx32++Mu2:brev).=.Rt32
    S2_storerinew_pbr       memw(Rx32++Mu2:brev).=.Nt8.new
    S2_storerbnew_pbr       memw(Rx32++Mu2:brev).=.Nt8.new
    S2_storerhnew_pbr       memw(Rx32++Mu2:brev).=.Nt8.new

Test cases in tests/tcg/hexagon/brev.c

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) circular addressing
Taylor Simpson [Fri, 9 Apr 2021 01:07:50 +0000 (20:07 -0500)]
Hexagon (target/hexagon) circular addressing

The following instructions are added
    L2_loadrub_pci          Rd32 = memub(Rx32++#s4:0:circ(Mu2))
    L2_loadrb_pci           Rd32 = memb(Rx32++#s4:0:circ(Mu2))
    L2_loadruh_pci          Rd32 = memuh(Rx32++#s4:1:circ(Mu2))
    L2_loadrh_pci           Rd32 = memh(Rx32++#s4:1:circ(Mu2))
    L2_loadri_pci           Rd32 = memw(Rx32++#s4:2:circ(Mu2))
    L2_loadrd_pci           Rdd32 = memd(Rx32++#s4:3:circ(Mu2))
    S2_storerb_pci          memb(Rx32++#s4:0:circ(Mu2)) = Rt32
    S2_storerh_pci          memh(Rx32++#s4:1:circ(Mu2)) = Rt32
    S2_storerf_pci          memh(Rx32++#s4:1:circ(Mu2)) = Rt.H32
    S2_storeri_pci          memw(Rx32++#s4:2:circ(Mu2)) = Rt32
    S2_storerd_pci          memd(Rx32++#s4:3:circ(Mu2)) = Rtt32
    S2_storerbnew_pci       memb(Rx32++#s4:0:circ(Mu2)) = Nt8.new
    S2_storerhnew_pci       memw(Rx32++#s4:1:circ(Mu2)) = Nt8.new
    S2_storerinew_pci       memw(Rx32++#s4:2:circ(Mu2)) = Nt8.new
    L2_loadrub_pcr          Rd32 = memub(Rx32++I:circ(Mu2))
    L2_loadrb_pcr           Rd32 = memb(Rx32++I:circ(Mu2))
    L2_loadruh_pcr          Rd32 = memuh(Rx32++I:circ(Mu2))
    L2_loadrh_pcr           Rd32 = memh(Rx32++I:circ(Mu2))
    L2_loadri_pcr           Rd32 = memw(Rx32++I:circ(Mu2))
    L2_loadrd_pcr           Rdd32 = memd(Rx32++I:circ(Mu2))
    S2_storerb_pcr          memb(Rx32++I:circ(Mu2)) = Rt32
    S2_storerh_pcr          memh(Rx32++I:circ(Mu2)) = Rt32
    S2_storerf_pcr          memh(Rx32++I:circ(Mu2)) = Rt32.H32
    S2_storeri_pcr          memw(Rx32++I:circ(Mu2)) = Rt32
    S2_storerd_pcr          memd(Rx32++I:circ(Mu2)) = Rtt32
    S2_storerbnew_pcr       memb(Rx32++I:circ(Mu2)) = Nt8.new
    S2_storerhnew_pcr       memh(Rx32++I:circ(Mu2)) = Nt8.new
    S2_storerinew_pcr       memw(Rx32++I:circ(Mu2)) = Nt8.new

Test cases in tests/tcg/hexagon/circ.c

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
[rth: Squash <1619667142[email protected]>
removing gen_read_reg and gen_set_byte to avoid clang Werror.]
Signed-off-by: Richard Henderson <[email protected]>
3 years agodecodetree: Extend argument set syntax to allow types
Richard Henderson [Thu, 29 Apr 2021 17:03:59 +0000 (10:03 -0700)]
decodetree: Extend argument set syntax to allow types

Rather than force all structure members to be 'int',
allow the type of the member to be specified.

Reviewed-by: Luis Pires <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agodecodetree: Add support for 64-bit instructions
Luis Fernando Fujita Pires [Wed, 7 Apr 2021 22:18:49 +0000 (22:18 +0000)]
decodetree: Add support for 64-bit instructions

Allow '64' to be specified for the instruction width command line params
and use the appropriate extract and deposit functions in that case.

This will be used to implement the new 64-bit Power ISA 3.1 instructions.

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Luis Pires <[email protected]>
Message-Id: <CP2PR80MB3668E123E2EFDB0ACD3A46F1DA759@CP2PR80MB3668.lamprd80.prod.outlook.com>
[rth: Drop the change to the field type; use bitop_width instead of separate
variables for extract/deposit; use "ull" for 64-bit constants.]
Reviewed-by: Luis Pires <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agodecodetree: More use of f-strings
Richard Henderson [Wed, 28 Apr 2021 23:37:02 +0000 (16:37 -0700)]
decodetree: More use of f-strings

Reviewed-by: Luis Pires <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agodecodetree: Introduce whex and whexC helpers
Richard Henderson [Wed, 28 Apr 2021 23:27:56 +0000 (16:27 -0700)]
decodetree: Introduce whex and whexC helpers

Form a hex constant of the appropriate insnwidth.
Begin using f-strings on changed lines.

Reviewed-by: Luis Pires <[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoexec: Remove accel/tcg/ from include paths
Philippe Mathieu-Daudé [Tue, 13 Apr 2021 08:10:08 +0000 (10:10 +0200)]
exec: Remove accel/tcg/ from include paths

When TCG is enabled, the accel/tcg/ include path is added to the
project global include search list. This accel/tcg/ directory
contains a header named "internal.h" which, while intented to
be internal to accel/tcg/, is accessible by all files compiled
when TCG is enabled. This might lead to problem with other
directories using the same "internal.h" header name:

  $ git ls-files | fgrep /internal.h
  accel/tcg/internal.h
  include/hw/ide/internal.h
  target/hexagon/internal.h
  target/mips/internal.h
  target/ppc/internal.h
  target/s390x/internal.h

As we don't need to expose accel/tcg/ internals to the rest of
the code base, simplify by removing it from the include search
list, and include the accel/tcg/ public headers relative to the
project root search path (which is already in the generic include
search path).

Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Claudio Fontana <[email protected]>
Message-Id: <20210413081008.3409459[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) add A4_addp_c/A4_subp_c
Taylor Simpson [Fri, 9 Apr 2021 01:07:49 +0000 (20:07 -0500)]
Hexagon (target/hexagon) add A4_addp_c/A4_subp_c

Rdd32 = add(Rss32, Rtt32, Px4):carry
    Add with carry
Rdd32 = sub(Rss32, Rtt32, Px4):carry
    Sub with carry

Test cases in tests/tcg/hexagon/multi_result.c

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) add A6_vminub_RdP
Taylor Simpson [Fri, 9 Apr 2021 01:07:48 +0000 (20:07 -0500)]
Hexagon (target/hexagon) add A6_vminub_RdP

Rdd32,Pe4 = vminub(Rtt32, Rss32)
    Vector min of bytes

Test cases in tests/tcg/hexagon/multi_result.c

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) add A5_ACS (vacsh)
Taylor Simpson [Fri, 9 Apr 2021 01:07:47 +0000 (20:07 -0500)]
Hexagon (target/hexagon) add A5_ACS (vacsh)

Rxx32,Pe4 = vacsh(Rss32, Rtt32)
    Add compare and select elements of two vectors

Test cases in tests/tcg/hexagon/multi_result.c

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) add F2_sfinvsqrta
Taylor Simpson [Fri, 9 Apr 2021 01:07:46 +0000 (20:07 -0500)]
Hexagon (target/hexagon) add F2_sfinvsqrta

Rd32,Pe4 = sfinvsqrta(Rs32)
    Square root approx

The helper packs the 2 32-bit results into a 64-bit value,
and the fGEN_TCG override unpacks them into the proper results.

Test cases in tests/tcg/hexagon/multi_result.c
FP exception tests added to tests/tcg/hexagon/fpstuff.c

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) add F2_sfrecipa instruction
Taylor Simpson [Fri, 9 Apr 2021 01:07:45 +0000 (20:07 -0500)]
Hexagon (target/hexagon) add F2_sfrecipa instruction

Rd32,Pe4 = sfrecipa(Rs32, Rt32)
    Recripocal approx

Test cases in tests/tcg/hexagon/multi_result.c
FP exception tests added to tests/tcg/hexagon/fpstuff.c

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) compile all debug code
Taylor Simpson [Fri, 9 Apr 2021 01:07:44 +0000 (20:07 -0500)]
Hexagon (target/hexagon) compile all debug code

Change #if HEX_DEBUG to if (HEX_DEBUG) so the debug code doesn't bit rot

Suggested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) move QEMU_GENERATE to only be on during macros.h
Taylor Simpson [Fri, 9 Apr 2021 01:07:43 +0000 (20:07 -0500)]
Hexagon (target/hexagon) move QEMU_GENERATE to only be on during macros.h

Suggested-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) cleanup reg_field_info definition
Taylor Simpson [Fri, 9 Apr 2021 01:07:42 +0000 (20:07 -0500)]
Hexagon (target/hexagon) cleanup reg_field_info definition

Include size in declaration
Remove {0, 0} entry

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) cleanup ternary operators in semantics
Taylor Simpson [Fri, 9 Apr 2021 01:07:41 +0000 (20:07 -0500)]
Hexagon (target/hexagon) cleanup ternary operators in semantics

Change  (cond ? (res = x) : (res = y)) to res = (cond ? x : y)

This makes the semnatics easier to for idef-parser to deal with

The following instructions are impacted
    C2_any8
    C2_all8
    C2_mux
    C2_muxii
    C2_muxir
    C2_muxri

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) use softfloat for float-to-int conversions
Taylor Simpson [Fri, 9 Apr 2021 01:07:40 +0000 (20:07 -0500)]
Hexagon (target/hexagon) use softfloat for float-to-int conversions

Use the proper return for helpers that convert to unsigned
Remove target/hexagon/conv_emu.[ch]

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) replace float32_mul_pow2 with float32_scalbn
Taylor Simpson [Fri, 9 Apr 2021 01:07:39 +0000 (20:07 -0500)]
Hexagon (target/hexagon) replace float32_mul_pow2 with float32_scalbn

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) use softfloat default NaN and tininess
Taylor Simpson [Fri, 9 Apr 2021 01:07:38 +0000 (20:07 -0500)]
Hexagon (target/hexagon) use softfloat default NaN and tininess

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) change type of softfloat_roundingmodes
Taylor Simpson [Fri, 9 Apr 2021 01:07:37 +0000 (20:07 -0500)]
Hexagon (target/hexagon) change type of softfloat_roundingmodes

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) remove unused carry_from_add64 function
Taylor Simpson [Fri, 9 Apr 2021 01:07:36 +0000 (20:07 -0500)]
Hexagon (target/hexagon) remove unused carry_from_add64 function

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) change variables from int to bool when appropriate
Taylor Simpson [Fri, 9 Apr 2021 01:07:35 +0000 (20:07 -0500)]
Hexagon (target/hexagon) change variables from int to bool when appropriate

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) decide if pred has been written at TCG gen time
Taylor Simpson [Fri, 9 Apr 2021 01:07:34 +0000 (20:07 -0500)]
Hexagon (target/hexagon) decide if pred has been written at TCG gen time

Multiple writes to the same preg are and'ed together.  Rather than
generating a runtime check, we can determine at TCG generation time
if the predicate has previously been written in the packet.

Test added to tests/tcg/hexagon/misc.c

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) properly generate TB end for DISAS_NORETURN
Taylor Simpson [Fri, 9 Apr 2021 01:07:33 +0000 (20:07 -0500)]
Hexagon (target/hexagon) properly generate TB end for DISAS_NORETURN

When exiting a TB, generate all the code before returning from
hexagon_tr_translate_packet so that nothing needs to be done in
hexagon_tr_tb_stop.

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) use env_archcpu and env_cpu
Taylor Simpson [Fri, 9 Apr 2021 01:07:32 +0000 (20:07 -0500)]
Hexagon (target/hexagon) use env_archcpu and env_cpu

Remove hexagon_env_get_cpu and replace with env_archcpu
Replace CPU(hexagon_env_get_cpu(env)) with env_cpu(env)

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) remove unnecessary inline directives
Taylor Simpson [Fri, 9 Apr 2021 01:07:31 +0000 (20:07 -0500)]
Hexagon (target/hexagon) remove unnecessary inline directives

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) cleanup gen_log_predicated_reg_write_pair
Taylor Simpson [Fri, 9 Apr 2021 01:07:30 +0000 (20:07 -0500)]
Hexagon (target/hexagon) cleanup gen_log_predicated_reg_write_pair

Similar to previous cleanup of gen_log_predicated_reg_write

Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoHexagon (target/hexagon) TCG generation cleanup
Taylor Simpson [Fri, 9 Apr 2021 01:07:29 +0000 (20:07 -0500)]
Hexagon (target/hexagon) TCG generation cleanup

Simplify TCG generation of hex_reg_written

Suggested-by: Richard Henderson <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Reviewed-by: Richard Henderson <[email protected]>
Message-Id: <1617930474[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agotarget/hexagon: remove unnecessary semicolons
Taylor Simpson [Mon, 15 Mar 2021 04:55:00 +0000 (23:55 -0500)]
target/hexagon: remove unnecessary semicolons

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Reported-by: Richard Henderson <<[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Message-Id: <1615784100[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agotarget/hexagon: fix typo in comment
Taylor Simpson [Mon, 15 Mar 2021 04:55:15 +0000 (23:55 -0500)]
target/hexagon: fix typo in comment

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Message-Id: <1615784115[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agotarget/hexagon: Change DECODE_MAPPED_REG operand name to OPNUM
Taylor Simpson [Mon, 15 Mar 2021 04:54:09 +0000 (23:54 -0500)]
target/hexagon: Change DECODE_MAPPED_REG operand name to OPNUM

Reported-by: Richard Henderson <<[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Message-Id: <1615784049[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agotarget/hexagon: remove unnecessary checks in find_iclass_slots
Taylor Simpson [Mon, 15 Mar 2021 04:53:57 +0000 (23:53 -0500)]
target/hexagon: remove unnecessary checks in find_iclass_slots

Reported-by: Richard Henderson <<[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Message-Id: <1615784037[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agotarget/hexagon: translation changes
Taylor Simpson [Mon, 15 Mar 2021 04:53:04 +0000 (23:53 -0500)]
target/hexagon: translation changes

Change cpu_ldl_code to translator_ldl.
Don't end the TB after every packet when HEX_DEBUG is on.
Make gen_check_store_width a simple call.

Reported-by: Richard Henderson <<[email protected]>
Signed-off-by: Taylor Simpson <[email protected]>
Message-Id: <1615783984[email protected]>
Signed-off-by: Richard Henderson <[email protected]>
3 years agoMerge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-04-30' into staging
Peter Maydell [Fri, 30 Apr 2021 15:02:00 +0000 (16:02 +0100)]
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-04-30' into staging

QAPI patches patches for 2021-04-30

# gpg: Signature made Fri 30 Apr 2021 12:42:32 BST
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Markus Armbruster <[email protected]>" [full]
# gpg:                 aka "Markus Armbruster <[email protected]>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2021-04-30: (25 commits)
  qapi/error.py: enable mypy checks
  qapi/error: Add type hints
  qapi/error.py: enable pylint checks
  qapi/error.py: move QAPIParseError to parser.py
  qapi/error: assert QAPISourceInfo is not None
  qapi/error: Make QAPISourceError 'col' parameter optional
  qapi/error: Use Python3-style super()
  qapi/error: Repurpose QAPIError as an abstract base exception class
  qapi/expr: Update authorship and copyright information
  qapi/expr.py: Use tuples instead of lists for static data
  qapi/expr.py: Add docstrings
  qapi/expr: Only explicitly prohibit 'Kind' nor 'List' for type names
  qapi/expr.py: enable pylint checks
  qapi/expr.py: Remove single-letter variable
  qapi/expr.py: Consolidate check_if_str calls in check_if
  qapi/expr.py: add type hint annotations
  qapi/expr.py: Modify check_keys to accept any Collection
  qapi/expr.py: Add casts in a few select cases
  qapi/expr.py: Check type of union and alternate 'data' member
  qapi/expr.py: move string check upwards in check_type
  ...

Signed-off-by: Peter Maydell <[email protected]>
3 years agoMerge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Peter Maydell [Fri, 30 Apr 2021 12:46:42 +0000 (13:46 +0100)]
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging

Block layer patches

- Fix permission update order problems with block graph changes
- qemu-img convert: Unshare write permission for source
- vhost-user-blk: Fail gracefully on too large queue size

# gpg: Signature made Fri 30 Apr 2021 11:27:51 BST
# gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
# gpg:                issuer "[email protected]"
# gpg: Good signature from "Kevin Wolf <[email protected]>" [full]
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74  56FE 7F09 B272 C88F 2FD6

* remotes/kevin/tags/for-upstream: (39 commits)
  vhost-user-blk: Fail gracefully on too large queue size
  qemu-img convert: Unshare write permission for source
  block: Add BDRV_O_NO_SHARE for blk_new_open()
  block: refactor bdrv_node_check_perm()
  block: rename bdrv_replace_child_safe() to bdrv_replace_child()
  block: refactor bdrv_child_set_perm_safe() transaction action
  block: inline bdrv_replace_child()
  block: inline bdrv_check_perm_common()
  block: drop unused permission update functions
  block: bdrv_reopen_multiple: refresh permissions on updated graph
  block: bdrv_reopen_multiple(): move bdrv_flush to separate pre-prepare
  block: add bdrv_set_backing_noperm() transaction action
  block: make bdrv_refresh_limits() to be a transaction action
  block: make bdrv_unset_inherits_from to be a transaction action
  block: drop ignore_children for permission update functions
  block/backup-top: drop .active
  block: introduce bdrv_drop_filter()
  block: add bdrv_remove_filter_or_cow transaction action
  block: adapt bdrv_append() for inserting filters
  block: split out bdrv_replace_node_noperm()
  ...

Signed-off-by: Peter Maydell <[email protected]>
3 years agoqapi/error.py: enable mypy checks
John Snow [Wed, 21 Apr 2021 19:22:33 +0000 (15:22 -0400)]
qapi/error.py: enable mypy checks

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421192233.3542904[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/error: Add type hints
John Snow [Wed, 21 Apr 2021 19:22:32 +0000 (15:22 -0400)]
qapi/error: Add type hints

No functional change.

Note: QAPISourceError's info parameter is Optional[] because schema.py
treats the info property of its various classes as Optional to
accommodate built-in types, which have no source. See prior commit
'qapi/error: assert QAPISourceInfo is not None'.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421192233.3542904[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/error.py: enable pylint checks
John Snow [Wed, 21 Apr 2021 19:22:31 +0000 (15:22 -0400)]
qapi/error.py: enable pylint checks

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421192233.3542904[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/error.py: move QAPIParseError to parser.py
John Snow [Wed, 21 Apr 2021 19:22:30 +0000 (15:22 -0400)]
qapi/error.py: move QAPIParseError to parser.py

Keeping it in error.py will create some cyclic import problems when we
add types to the QAPISchemaParser. Callers don't need to know the
details of QAPIParseError unless they are parsing or dealing directly
with the parser, so this won't create any harsh new requirements for
callers in the general case.

Update error.py with a little docstring that gives a nod to where the
error may now be found.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421192233.3542904[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/error: assert QAPISourceInfo is not None
John Snow [Wed, 21 Apr 2021 19:22:29 +0000 (15:22 -0400)]
qapi/error: assert QAPISourceInfo is not None

Built-in stuff is not parsed from a source file, and therefore have no
QAPISourceInfo. If such None info was used for reporting an error,
built-in stuff would be broken. Programming error. Instead of reporting
a confusing error with bogus source location then, we better crash.

We currently crash only if self.col was set. Assert that self.info is
not None in order to crash reliably.

We can not yet change the type of the initializer to prove this cannot
happen at static analysis time before the remainder of the code is fully
typed.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421192233.3542904[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/error: Make QAPISourceError 'col' parameter optional
John Snow [Wed, 21 Apr 2021 19:22:28 +0000 (15:22 -0400)]
qapi/error: Make QAPISourceError 'col' parameter optional

It's already treated as optional, with one direct caller and some
subclass callers passing 'None'. Make it officially optional, which
requires moving the position of the argument to come after all required
parameters.

QAPISemError becomes functionally identical to QAPISourceError. Keep the
name to preserve its semantic meaning and avoid code churn, but remove
the now-useless __init__ wrapper.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421192233.3542904[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/error: Use Python3-style super()
John Snow [Wed, 21 Apr 2021 19:22:27 +0000 (15:22 -0400)]
qapi/error: Use Python3-style super()

Missed in commit 2cae67bcb5 "qapi: Use super() now we have Python 3".

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Message-Id: <20210421192233.3542904[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/error: Repurpose QAPIError as an abstract base exception class
John Snow [Wed, 21 Apr 2021 19:22:26 +0000 (15:22 -0400)]
qapi/error: Repurpose QAPIError as an abstract base exception class

Rename QAPIError to QAPISourceError, and then create a new QAPIError
class that serves as the basis for all of our other custom exceptions,
without specifying any class properties.

This leaves QAPIError as a package-wide error class that's suitable for
any current or future errors.

(Right now, we don't have any errors that DON'T also want to specify a
Source location, but this MAY change. In these cases, a common abstract
ancestor would be desired.)

Add docstrings to explain the intended function of each error class.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421192233.3542904[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr: Update authorship and copyright information
John Snow [Wed, 21 Apr 2021 18:20:32 +0000 (14:20 -0400)]
qapi/expr: Update authorship and copyright information

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: Use tuples instead of lists for static data
John Snow [Wed, 21 Apr 2021 18:20:31 +0000 (14:20 -0400)]
qapi/expr.py: Use tuples instead of lists for static data

It is -- maybe -- possibly -- three nanoseconds faster.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: Add docstrings
John Snow [Wed, 21 Apr 2021 18:20:30 +0000 (14:20 -0400)]
qapi/expr.py: Add docstrings

Now with more :words:!

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr: Only explicitly prohibit 'Kind' nor 'List' for type names
John Snow [Wed, 21 Apr 2021 18:20:29 +0000 (14:20 -0400)]
qapi/expr: Only explicitly prohibit 'Kind' nor 'List' for type names

Per list review: qapi-code-gen.txt reserves suffixes Kind and
List only for type names, but the code rejects them for events and
commands, too.

It turns out we reject them earlier anyway: In check_name_upper() for
event names, and in check_name_lower() for command names.

Still, adjust the code for clarity over what precisely we are guarding
against.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: enable pylint checks
John Snow [Wed, 21 Apr 2021 18:20:28 +0000 (14:20 -0400)]
qapi/expr.py: enable pylint checks

Signed-off-by: John Snow <[email protected]>
Tested-by: Eduardo Habkost <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Tested-by: Cleber Rosa <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: Remove single-letter variable
John Snow [Wed, 21 Apr 2021 18:20:27 +0000 (14:20 -0400)]
qapi/expr.py: Remove single-letter variable

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: Consolidate check_if_str calls in check_if
John Snow [Wed, 21 Apr 2021 18:20:26 +0000 (14:20 -0400)]
qapi/expr.py: Consolidate check_if_str calls in check_if

This is a small rewrite to address some minor style nits.

Don't compare against the empty list to check for the empty condition, and
move the normalization forward to unify the check on the now-normalized
structure.

With the check unified, the local nested function isn't needed anymore
and can be brought down into the normal flow of the function. With the
nesting level changed, shuffle the error strings around a bit to get
them to fit in 79 columns.

Note: although ifcond is typed as Sequence[str] elsewhere, we *know* that
the parser will produce real, bona-fide lists. It's okay to check
isinstance(ifcond, list) here.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: add type hint annotations
John Snow [Wed, 21 Apr 2021 18:20:25 +0000 (14:20 -0400)]
qapi/expr.py: add type hint annotations

Annotations do not change runtime behavior.
This commit *only* adds annotations.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: Modify check_keys to accept any Collection
John Snow [Wed, 21 Apr 2021 18:20:24 +0000 (14:20 -0400)]
qapi/expr.py: Modify check_keys to accept any Collection

This is a minor adjustment that lets parameters @required and
@optional take tuple arguments, in particular ().  Later patches will
make use of that.

(Iterable would also have worked, but Iterable also includes things like
generator expressions which are consumed upon iteration, which would
require a rewrite to make sure that each input was only traversed
once. Collection implies the "can re-iterate" property.)

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: Add casts in a few select cases
John Snow [Wed, 21 Apr 2021 18:20:23 +0000 (14:20 -0400)]
qapi/expr.py: Add casts in a few select cases

Casts are instructions to the type checker only, they aren't "safe" and
should probably be avoided in general. In this case, when we perform
type checking on a nested structure, the type of each field does not
"stick".

(See PEP 647 for an example of "type narrowing" that does "stick".
 It is available in Python 3.10, so we can't use it yet.)

We don't need to assert that something is a str if we've already checked
or asserted that it is -- use a cast instead for these cases.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: Check type of union and alternate 'data' member
John Snow [Wed, 21 Apr 2021 18:20:22 +0000 (14:20 -0400)]
qapi/expr.py: Check type of union and alternate 'data' member

Prior to this commit, specifying a non-object value here causes the QAPI
parser to crash in expr.py with a stack trace with (likely) an
AttributeError when we attempt to call that value's items() method.

This member needs to be an object (Dict), and not anything else. Add a
check for this with a nicer error message, and formalize that check with
new test cases that exercise that error.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: move string check upwards in check_type
John Snow [Wed, 21 Apr 2021 18:20:21 +0000 (14:20 -0400)]
qapi/expr.py: move string check upwards in check_type

For readability purposes only, shimmy the early return upwards to the
top of the function, so cases proceed in order from least to most
complex.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: Add assertion for union type 'check_dict'
John Snow [Wed, 21 Apr 2021 18:20:20 +0000 (14:20 -0400)]
qapi/expr.py: Add assertion for union type 'check_dict'

mypy isn't fond of allowing you to check for bool membership in a
collection of str elements. Guard this lookup for precisely when we were
given a name.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: constrain incoming expression types
John Snow [Wed, 21 Apr 2021 18:20:19 +0000 (14:20 -0400)]
qapi/expr.py: constrain incoming expression types

mypy does not know the types of values stored in Dicts that masquerade
as objects. Help the type checker out by constraining the type.

Signed-off-by: John Snow <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
3 years agoqapi/expr.py: Check for dict instead of OrderedDict
John Snow [Wed, 21 Apr 2021 18:20:18 +0000 (14:20 -0400)]
qapi/expr.py: Check for dict instead of OrderedDict

OrderedDict is a subtype of dict, so we can check for a more general
form. These functions do not themselves depend on it being any
particular type.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Eduardo Habkost <[email protected]>
Reviewed-by: Cleber Rosa <[email protected]>
Message-Id: <20210421182032.3521476[email protected]>
Reviewed-by: Markus Armbruster <[email protected]>
Signed-off-by: Markus Armbruster <[email protected]>
This page took 0.095964 seconds and 4 git commands to generate.