Strict disable implicit fallthrough
Subsystems (7)
cover Strict disable implicit fallthrough
Hello,
This RFC is inspired by the kernel's move to -Wimplicit-fallthrough=3 back in 2019.[0]
We take one step (or two) further by increasing it to 5 which rejects fall through comments and requires an attribute statement.
[0]:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a035d552a93b
The line differences are not many, but they spread all over different subsystems, architectures and devices. An attempt has been made to split them in cohesive patches to aid post-RFC review. Part of the RFC is to determine whether these patch divisions needs improvement.
Main questions this RFC poses
=============================
- Is this change desirable and net-positive.
- Should the fallthrough; pseudo-keyword be defined like in the Linux kernel, or use glib's G_GNUC_FALLTHROUGH, or keep the already existing QEMU_FALLTHROUGH macro.
- Should fallthrough comments be removed if they do not include extra information.
Some external resources
=======================
See the RFC discussion in the kernel:
The fallthrough; pseudo-keyword in the kernel source code:
https://elixir.bootlin.com/linux/latest/C/ident/fallthrough
In summary, I quote the doc comment and definition:
/*
* Add the pseudo keyword 'fallthrough' so case statement blocks
* must end with any of these keywords:
* break;
* fallthrough;
* continue;
* goto <label>;
* return [expression];
*
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
*/
#if __has_attribute(__fallthrough__)
# define fallthrough __attribute__((__fallthrough__))
#else
# define fallthrough do {} while (0) /* fallthrough */
#endif
Background - Motivation
=======================
The C switch statement allows you to conditionally goto different labels depending on a value. A break; statement conveniently goto's the end of the switch. If a "case" does not end in a break, we say that the control flow falls through the next case label, if any, implicitly. This can lead to bugs and QEMU uses the GCC warning -Wimplicit-fallthrough to prevent this.
Currently, QEMU is built with -Wimplicit-fallthrough=2. This makes GCC's static analyzer check for a case-insensitive matches of the .*falls?[ \t-]*thr(ough|u).* regular expression. This means the following list of comments taken from QEMU all disable the implicit fallthrough warning:
- /* FALLTHRU */
- /* fall through */
- /* Fall through. */
- /* Fall through... */
- /* fall through if hEventTimeout is signaled */
- /* FALL THROUGH */
To keep a constistent code style, this commit adds a macro fallthrough that looks like a C keyword but expands to an attribute statement in supported compilers (GCC at the moment).
Note: there was already such a macro, QEMU_FALLTHROUGH, and it was used only around 7 times in the code base. The first commit replaces it.
Emmanouil Pitsidianakis (78):
include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough
block: add fallthrough pseudo-keyword
fpu/softfloat: add fallthrough pseudo-keyword qapi/opts-visitor: add fallthrough pseudo-keyword qobject/json: add fallthrough pseudo-keyword
tcg: add fallthrough pseudo-keyword hw/virtio/virtio-balloon.c: add fallthrough pseudo-keyword hw/block: add fallthrough pseudo-keyword hw/acpi/aml-build.c: add fallthrough pseudo-keyword hw/ide/atapi.c: add fallthrough pseudo-keyword hw/timer: add fallthrough pseudo-keyword
hw/usb: add fallthrough pseudo-keyword
hw/adc: add fallthrough pseudo-keyword util/error-report.c: add fallthrough pseudo-keyword accel/tcg: add fallthrough pseudo-keyword
audio: add fallthrough pseudo-keyword
ui/sdl2.c: add fallthrough pseudo-keyword ui/win32-kbd-hook.c: add fallthrough pseudo-keyword target/hppa: add fallthrough pseudo-keyword target/mips: add fallthrough pseudo-keyword target/sparc: add fallthrough pseudo-keyword target/ppc: add fallthrough pseudo-keyword
target/arm: add fallthrough pseudo-keyword target/alpha: add fallthrough pseudo-keyword target/i386: add fallthrough pseudo-keyword target/s390x: add fallthrough pseudo-keyword target/riscv: add fallthrough pseudo-keyword target/avr: add fallthrough pseudo-keyword
target/cris: add fallthrough pseudo-keyword target/nios2: add fallthrough pseudo-keyword target/xtensa: add fallthrough pseudo-keyword target/m68k: add fallthrough pseudo-keyword
target/rx: add fallthrough pseudo-keyword target/tricore: add fallthrough pseudo-keyword target/sh4: add fallthrough pseudo-keyword target/openrisc: add fallthrough pseudo-keyword target/hexagon: add fallthrough pseudo-keyword system/rtc.c: add fallthrough pseudo-keyword
hw/scsi: add fallthrough pseudo-keyword
hw/sd/sdhci.c: add fallthrough pseudo-keyword
linux-user: add fallthrough pseudo-keyword
hw/i386: add fallthrough pseudo-keyword
hw/misc: add fallthrough pseudo-keyword hw/m68k/mcf_intc.c: add fallthrough pseudo-keyword hw/dma: add fallthrough pseudo-keyword
disas: add fallthrough pseudo-keyword contrib/rdmacm-mux: add fallthrough pseudo-keyword contrib/vhost-user-scsi: add fallthrough pseudo-keyword hw/arm: add fallthrough pseudo-keyword
hw/audio: add fallthrough pseudo-keyword
chardev: add fallthrough pseudo-keyword
hw/char: add fallthrough pseudo-keyword
nbd: add fallthrough pseudo-keyword
hw/core: add fallthrough pseudo-keyword
hw/display: add fallthrough pseudo-keyword
hw/input: add fallthrough pseudo-keyword
hw/net: add fallthrough pseudo-keyword
hw/ppc: add fallthrough pseudo-keyword
hw/intc: add fallthrough pseudo-keyword
qga: add fallthrough pseudo-keyword
semihosting: add fallthrough pseudo-keyword
hw/gpio: add fallthrough pseudo-keyword
hw/ipmi: add fallthrough pseudo-keyword
hw/mips: add fallthrough pseudo-keyword
hw/nvme: add fallthrough pseudo-keyword hw/nvram/eeprom_at24c.c: add fallthrough pseudo-keyword hw/pci-host/pnv_phb3.c: add fallthrough pseudo-keyword hw/pci: add fallthrough pseudo-keyword hw/rdma/rdma_backend.c: add fallthrough pseudo-keyword hw/rtc: add fallthrough pseudo-keyword
hw/s390x: add fallthrough pseudo-keyword
hw/ssi: add fallthrough pseudo-keyword hw/watchdog/wdt_diag288.c: add fallthrough pseudo-keyword hw/cxl/cxl-device-utils.c: add fallthrough pseudo-keyword
migration: add fallthrough pseudo-keyword
qemu-img.c: add fallthrough pseudo-keyword tests/unit/test-char.c: add fallthrough pseudo-keyword meson.build: increase -Wimplicit-fallthrough to 5
accel/tcg/cputlb.c | 4 +- accel/tcg/ldst_atomicity.c.inc | 2 +- accel/tcg/plugin-gen.c | 2 +- audio/audio.c | 16 ++-- audio/jackaudio.c | 4 +- audio/pwaudio.c | 12 +-- block/block-copy.c | 1 + block/file-posix.c | 1 + block/io.c | 1 + block/iscsi.c | 1 + block/qcow2-cluster.c | 5 +- block/vhdx.c | 17 +++- chardev/char-socket.c | 2 +- contrib/rdmacm-mux/main.c | 10 +-- contrib/vhost-user-scsi/vhost-user-scsi.c | 3 +- disas/hppa.c | 4 +- disas/m68k.c | 2 +- disas/sh4.c | 6 +- disas/sparc.c | 2 +- docs/devel/style.rst | 23 +++++ fpu/softfloat-parts.c.inc | 8 +- fpu/softfloat.c | 7 +- hw/acpi/aml-build.c | 6 +- hw/adc/aspeed_adc.c | 12 +-- hw/adc/zynq-xadc.c | 2 +- hw/arm/omap1.c | 8 +- hw/arm/pxa2xx.c | 6 +- hw/arm/smmuv3.c | 2 +- hw/arm/stellaris.c | 1 + hw/audio/asc.c | 2 +- hw/audio/cs4231a.c | 2 +- hw/audio/gusemu_hal.c | 2 +- hw/block/dataplane/xen-block.c | 4 +- hw/block/m25p80.c | 2 +- hw/block/onenand.c | 2 +- hw/block/pflash_cfi01.c | 1 + hw/block/pflash_cfi02.c | 6 +- hw/char/nrf51_uart.c | 4 +- hw/core/loader.c | 2 +- hw/cxl/cxl-device-utils.c | 4 +- hw/display/cg3.c | 2 +- hw/display/cirrus_vga.c | 2 +- hw/display/tcx.c | 4 +- hw/dma/omap_dma.c | 32 +++---- hw/dma/pxa2xx_dma.c | 4 +- hw/dma/sparc32_dma.c | 2 +- hw/gpio/omap_gpio.c | 2 +- hw/i2c/bitbang_i2c.c | 2 +- hw/i386/intel_iommu.c | 4 +- hw/i386/kvm/xen_evtchn.c | 2 +- hw/i386/x86.c | 2 +- hw/ide/atapi.c | 1 + hw/input/hid.c | 3 +- hw/input/tsc2005.c | 4 +- hw/input/tsc210x.c | 2 +- hw/intc/apic.c | 2 +- hw/intc/arm_gicv3_kvm.c | 16 ++-- hw/intc/armv7m_nvic.c | 12 +-- hw/intc/xilinx_intc.c | 2 +- hw/ipmi/ipmi_bmc_extern.c | 2 +- hw/ipmi/smbus_ipmi.c | 4 +- hw/m68k/mcf_intc.c | 2 +- hw/mips/boston.c | 12 +-- hw/misc/a9scu.c | 2 + hw/misc/aspeed_scu.c | 2 +- hw/misc/bcm2835_property.c | 12 +-- hw/misc/mos6522.c | 4 +- hw/net/cadence_gem.c | 4 +- hw/net/can/can_sja1000.c | 4 +- hw/net/igb_core.c | 2 +- hw/net/igbvf.c | 2 +- hw/net/imx_fec.c | 2 +- hw/net/net_rx_pkt.c | 2 +- hw/net/pcnet.c | 2 +- hw/net/rtl8139.c | 6 +- hw/net/xilinx_ethlite.c | 2 +- hw/nvme/ctrl.c | 24 +++--- hw/nvme/dif.c | 4 +- hw/nvram/eeprom_at24c.c | 2 +- hw/pci-host/pnv_phb3.c | 2 +- hw/pci/pcie_aer.c | 3 +- hw/pci/pcie_doe.c | 2 +- hw/ppc/pnv_bmc.c | 2 +- hw/ppc/spapr_events.c | 1 + hw/rdma/rdma_backend.c | 2 +- hw/rtc/aspeed_rtc.c | 4 +- hw/rtc/mc146818rtc.c | 4 +- hw/s390x/ipl.c | 1 + hw/s390x/s390-pci-inst.c | 4 +- hw/s390x/sclp.c | 4 +- hw/scsi/esp.c | 2 +- hw/scsi/megasas.c | 2 +- hw/scsi/scsi-bus.c | 4 +- hw/scsi/scsi-disk.c | 2 +- hw/sd/sdhci.c | 8 +- hw/ssi/npcm7xx_fiu.c | 14 +-- hw/ssi/omap_spi.c | 48 +++++------ hw/timer/a9gtimer.c | 8 +- hw/timer/aspeed_timer.c | 1 + hw/timer/pxa2xx_timer.c | 94 ++++++++++----------- hw/timer/renesas_tmr.c | 2 +- hw/timer/sh_timer.c | 8 +- hw/usb/dev-mtp.c | 2 +- hw/usb/dev-wacom.c | 2 +- hw/usb/hcd-ehci.c | 4 +- hw/usb/hcd-xhci.c | 4 +- hw/usb/redirect.c | 4 +- hw/usb/tusb6010.c | 2 +- hw/virtio/virtio-balloon.c | 1 + hw/watchdog/wdt_diag288.c | 2 +- include/qemu/compiler.h | 30 +++++-- include/qemu/osdep.h | 4 +- linux-user/mips/cpu_loop.c | 8 +- linux-user/mmap.c | 2 +- linux-user/syscall.c | 2 +- meson.build | 2 +- migration/migration.c | 2 +- nbd/client.c | 4 +- nbd/common.c | 2 +- qapi/opts-visitor.c | 1 + qapi/string-input-visitor.c | 4 +- qemu-img.c | 2 +- qemu-nbd.c | 4 +- qga/main.c | 2 +- qga/vss-win32/requester.cpp | 1 + qobject/json-lexer.c | 4 +- qobject/json-parser.c | 5 +- semihosting/arm-compat-semi.c | 2 +- system/rtc.c | 2 +- target/alpha/helper.c | 6 +- target/alpha/translate.c | 4 +- target/arm/helper.c | 34 ++++---- target/arm/ptw.c | 10 +-- target/arm/tcg/psci.c | 2 +- target/arm/tcg/translate-a64.c | 76 ++++++++--------- target/arm/tcg/translate-m-nocp.c | 2 +- target/arm/tcg/translate-vfp.c | 2 +- target/arm/tcg/translate.c | 8 +- target/avr/translate.c | 4 +- target/cris/translate.c | 4 +- target/hexagon/idef-parser/parser-helpers.c | 5 +- target/hppa/translate.c | 10 +-- target/i386/cpu.c | 2 +- target/i386/hvf/x86_decode.c | 1 + target/i386/kvm/kvm.c | 4 +- target/i386/tcg/decode-new.c.inc | 6 +- target/i386/tcg/emit.c.inc | 2 +- target/i386/tcg/translate.c | 11 +-- target/loongarch/cpu.c | 4 +- target/loongarch/translate.c | 2 +- target/m68k/op_helper.c | 3 +- target/m68k/translate.c | 10 +-- target/mips/sysemu/physaddr.c | 2 +- target/mips/tcg/micromips_translate.c.inc | 4 +- target/mips/tcg/mips16e_translate.c.inc | 30 +++---- target/mips/tcg/mxu_translate.c | 8 +- target/mips/tcg/nanomips_translate.c.inc | 4 +- target/mips/tcg/op_helper.c | 2 +- target/mips/tcg/translate.c | 79 ++++++++--------- target/nios2/helper.c | 6 +- target/nios2/translate.c | 2 +- target/openrisc/mmu.c | 2 +- target/openrisc/translate.c | 2 +- target/ppc/cpu_init.c | 8 +- target/ppc/excp_helper.c | 6 +- target/ppc/mmu-radix64.c | 6 +- target/ppc/mmu_common.c | 12 +-- target/ppc/translate.c | 6 +- target/riscv/insn_trans/trans_rvi.c.inc | 2 +- target/riscv/insn_trans/trans_rvzce.c.inc | 22 ++--- target/riscv/translate.c | 4 +- target/rx/translate.c | 2 +- target/s390x/cpu.c | 4 +- target/s390x/kvm/kvm.c | 2 +- target/s390x/mmu_helper.c | 6 +- target/s390x/tcg/translate.c | 18 ++-- target/s390x/tcg/translate_vx.c.inc | 2 +- target/sh4/helper.c | 2 +- target/sparc/ldst_helper.c | 4 +- target/sparc/mmu_helper.c | 6 +- target/sparc/translate.c | 3 +- target/sparc/win_helper.c | 1 + target/tricore/translate.c | 4 +- target/xtensa/op_helper.c | 8 +- target/xtensa/translate.c | 2 +- tcg/aarch64/tcg-target.c.inc | 15 +++- tcg/arm/tcg-target.c.inc | 5 +- tcg/i386/tcg-target.c.inc | 20 +++-- tcg/loongarch64/tcg-target.c.inc | 4 +- tcg/mips/tcg-target.c.inc | 8 +- tcg/optimize.c | 8 +- tcg/ppc/tcg-target.c.inc | 19 +++-- tcg/riscv/tcg-target.c.inc | 5 +- tcg/s390x/tcg-target.c.inc | 8 +- tcg/tcg-op-gvec.c | 24 +++--- tcg/tcg-op-ldst.c | 2 +- tcg/tcg.c | 24 +++--- tcg/tci.c | 2 +- tcg/tci/tcg-target.c.inc | 2 +- tests/unit/test-char.c | 2 +- ui/sdl2.c | 2 +- ui/win32-kbd-hook.c | 7 -- util/error-report.c | 2 +- 203 files changed, 747 insertions(+), 618 deletions(-)
base-commit: cea3ea670fe265421131aad90c36fbb87bc4d206
Signature · 1 line
2.39.2
RFC PATCH 1/78 include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough
--- audio/pwaudio.c | 8 ++++---- hw/arm/smmuv3.c | 2 +- include/qemu/compiler.h | 30 +++++++++++++++++++++++------- include/qemu/osdep.h | 4 ++-- target/loongarch/cpu.c | 4 ++-- target/loongarch/translate.c | 2 +- tcg/optimize.c | 8 ++++---- 7 files changed, 37 insertions(+), 21 deletions(-)
audio/pwaudio.c +4 -4
@@ -1,29 +1,29 @@/* * QEMU PipeWire audio driver * * Copyright (c) 2023 Red Hat Inc. * * Author: Dorinda Bassey <[email protected]> * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include <spa/param/audio/format-utils.h> +#include <spa/utils/ringbuffer.h> +#include <spa/utils/result.h> +#include <spa/param/props.h> #include "qemu/osdep.h" #include "qemu/module.h" #include "audio.h" #include <errno.h> #include "qemu/error-report.h" #include "qapi/error.h" -#include <spa/param/audio/format-utils.h> -#include <spa/utils/ringbuffer.h> -#include <spa/utils/result.h> -#include <spa/param/props.h> #include <pipewire/pipewire.h> #include "trace.h" #define AUDIO_CAP "pipewire"#define RINGBUFFER_SIZE (1u << 22)#define RINGBUFFER_MASK (RINGBUFFER_SIZE - 1)#include "audio_int.h"
hw/arm/smmuv3.c +1 -1
@@ -1166,210 +1166,210 @@ smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data)static int smmuv3_cmdq_consume (SMMUv3State *s) {SMMUState *bs =ARM_SMMU (s);SMMUCmdError cmd_error =SMMU_CERROR_NONE ;SMMUQueue *q = &s->cmdq;SMMUCommandType type =0 ;if (!smmuv3_cmdq_enabled (s)) {return 0 ; }/* * some commands depend on register values, typically CR0. In case those * register values change while handling the command, spec says it * is UNPREDICTABLE whether the command is interpreted under the new * or old value. */ while (!smmuv3_q_empty (q)) {uint32_t pending = s->gerror ^ s->gerrorn;Cmd cmd;trace_smmuv3_cmdq_consume (Q_PROD (q),Q_CONS (q),Q_PROD_WRAP (q),Q_CONS_WRAP (q));if (FIELD_EX32 (pending,GERROR ,CMDQ_ERR )) {break ; }if (queue_read (q, &cmd) !=MEMTX_OK ) { cmd_error =SMMU_CERROR_ABT ;break ; } type =CMD_TYPE (&cmd);trace_smmuv3_cmdq_opcode (smmu_cmd_string (type));qemu_mutex_lock (&s->mutex);switch (type) {case SMMU_CMD_SYNC :if (CMD_SYNC_CS (&cmd) &CMD_SYNC_SIG_IRQ ) {smmuv3_trigger_irq (s,SMMU_IRQ_CMD_SYNC ,0 ); }break ;case SMMU_CMD_PREFETCH_CONFIG :case SMMU_CMD_PREFETCH_ADDR :break ;case SMMU_CMD_CFGI_STE : {uint32_t sid =CMD_SID (&cmd);IOMMUMemoryRegion *mr =smmu_iommu_mr (bs, sid);SMMUDevice *sdev;if (CMD_SSEC (&cmd)) { cmd_error =SMMU_CERROR_ILL ;break ; }if (!mr) {break ; }trace_smmuv3_cmdq_cfgi_ste (sid); sdev =container_of (mr, SMMUDevice, iommu);smmuv3_flush_config (sdev);break ; }case SMMU_CMD_CFGI_STE_RANGE :/* same as SMMU_CMD_CFGI_ALL */ {uint32_t sid =CMD_SID (&cmd), mask;uint8_t range =CMD_STE_RANGE (&cmd);SMMUSIDRange sid_range;if (CMD_SSEC (&cmd)) { cmd_error =SMMU_CERROR_ILL ;break ; } mask = (1ULL << (range +1 )) -1 ; sid_range.start = sid & ~mask; sid_range.end = sid_range.start + mask;trace_smmuv3_cmdq_cfgi_ste_range (sid_range.start, sid_range.end);g_hash_table_foreach_remove (bs->configs, smmuv3_invalidate_ste, &sid_range);break ; }case SMMU_CMD_CFGI_CD :case SMMU_CMD_CFGI_CD_ALL : {uint32_t sid =CMD_SID (&cmd);IOMMUMemoryRegion *mr =smmu_iommu_mr (bs, sid);SMMUDevice *sdev;if (CMD_SSEC (&cmd)) { cmd_error =SMMU_CERROR_ILL ;break ; }if (!mr) {break ; }trace_smmuv3_cmdq_cfgi_cd (sid); sdev =container_of (mr, SMMUDevice, iommu);smmuv3_flush_config (sdev);break ; }case SMMU_CMD_TLBI_NH_ASID : {uint16_t asid =CMD_ASID (&cmd);if (!STAGE1_SUPPORTED (s)) { cmd_error =SMMU_CERROR_ILL ;break ; }trace_smmuv3_cmdq_tlbi_nh_asid (asid);smmu_inv_notifiers_all (&s->smmu_state);smmu_iotlb_inv_asid (bs, asid);break ; }case SMMU_CMD_TLBI_NH_ALL :if (!STAGE1_SUPPORTED (s)) { cmd_error =SMMU_CERROR_ILL ;break ; } -QEMU_FALLTHROUGH ; + fallthrough;case SMMU_CMD_TLBI_NSNH_ALL :trace_smmuv3_cmdq_tlbi_nh ();smmu_inv_notifiers_all (&s->smmu_state);smmu_iotlb_inv_all (bs);break ;case SMMU_CMD_TLBI_NH_VAA :case SMMU_CMD_TLBI_NH_VA :if (!STAGE1_SUPPORTED (s)) { cmd_error =SMMU_CERROR_ILL ;break ; }smmuv3_range_inval (bs, &cmd);break ;case SMMU_CMD_TLBI_S12_VMALL : {uint16_t vmid =CMD_VMID (&cmd);if (!STAGE2_SUPPORTED (s)) { cmd_error =SMMU_CERROR_ILL ;break ; }trace_smmuv3_cmdq_tlbi_s12_vmid (vmid);smmu_inv_notifiers_all (&s->smmu_state);smmu_iotlb_inv_vmid (bs, vmid);break ; }case SMMU_CMD_TLBI_S2_IPA :if (!STAGE2_SUPPORTED (s)) { cmd_error =SMMU_CERROR_ILL ;break ; }/* * As currently only either s1 or s2 are supported * we can reuse same function for s2. */ smmuv3_range_inval (bs, &cmd);break ;case SMMU_CMD_TLBI_EL3_ALL :case SMMU_CMD_TLBI_EL3_VA :case SMMU_CMD_TLBI_EL2_ALL :case SMMU_CMD_TLBI_EL2_ASID :case SMMU_CMD_TLBI_EL2_VA :case SMMU_CMD_TLBI_EL2_VAA :case SMMU_CMD_ATC_INV :case SMMU_CMD_PRI_RESP :case SMMU_CMD_RESUME :case SMMU_CMD_STALL_TERM :trace_smmuv3_unhandled_cmd (type);break ;default : cmd_error =SMMU_CERROR_ILL ;break ; }qemu_mutex_unlock (&s->mutex);if (cmd_error) {if (cmd_error ==SMMU_CERROR_ILL ) {qemu_log_mask (LOG_GUEST_ERROR ,"Illegal command type: %d\n" ,CMD_TYPE (&cmd)); }break ; }/* * We only increment the cons index after the completion of * the command. We do that because the SYNC returns immediately * and does not check the completion of previous commands */ queue_cons_incr (q); }if (cmd_error) {trace_smmuv3_cmdq_consume_error (smmu_cmd_string (type), cmd_error);smmu_write_cmdq_err (s, cmd_error);smmuv3_trigger_irq (s,SMMU_IRQ_GERROR ,R_GERROR_CMDQ_ERR_MASK ); }trace_smmuv3_cmdq_consume_out (Q_PROD (q),Q_CONS (q),Q_PROD_WRAP (q),Q_CONS_WRAP (q));return 0 ; }
include/qemu/compiler.h +23 -7
@@ -1,215 +1,231 @@/* compiler.h: macros to abstract away compiler specifics * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ #ifndef COMPILER_H #define COMPILER_H #define HOST_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)/* HOST_LONG_BITS is the size of a native pointer in bits. */ #define HOST_LONG_BITS (__SIZEOF_POINTER__ * 8)#if defined __clang_analyzer__ || defined __COVERITY__#define QEMU_STATIC_ANALYSIS 1#endif #ifdef __cplusplus#define QEMU_EXTERN_C extern "C"#else #define QEMU_EXTERN_C extern#endif #if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))# define QEMU_PACKED __attribute__((gcc_struct, packed))#else # define QEMU_PACKED __attribute__((packed))#endif #define QEMU_ALIGNED (X ) __attribute__((aligned(X)))#ifndef glue#define xglue (x, y) x ## y#define glue (x, y) xglue(x, y)#define stringify (s) tostring(s)#define tostring (s) #s#endif /* Expands into an identifier stemN, where N is another number each time */ #define MAKE_IDENTFIER (stem) glue(stem, __COUNTER__)#ifndef likely#define likely (x) __builtin_expect(!!(x), 1)#define unlikely (x) __builtin_expect(!!(x), 0)#endif #ifndef container_of#define container_of (ptr, type, member) ({ \ const typeof(((type *) 0)->member) *__mptr = (ptr); \ (type *) ((char *) __mptr - offsetof(type, member));})#endif #define sizeof_field (type, field) sizeof(((type *)0)->field)/* * Calculate the number of bytes up to and including the given 'field' of * 'container'. */ #define endof (container, field) \ (offsetof(container, field) + sizeof_field(container, field))/* Convert from a base type to a parent type, with compile time checking. */ #define DO_UPCAST (type, field, dev) ( __extension__ ( { \ char __attribute__((unused)) offset_must_be_zero[ \ -offsetof(type, field)]; \ container_of(dev, type, field);}))#define typeof_field (type, field) typeof(((type *)0)->field)#define type_check (t1,t2) ((t1*)0 - (t2*)0)#define QEMU_BUILD_BUG_ON_STRUCT (x) \ struct { \ int:(x) ? -1 : 1; \ }#define QEMU_BUILD_BUG_MSG (x, msg) _Static_assert(!(x), msg)#define QEMU_BUILD_BUG_ON (x) QEMU_BUILD_BUG_MSG(x, "not expecting: " #x)#define QEMU_BUILD_BUG_ON_ZERO (x) (sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)) - \ sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)))#if !defined(__clang__) && defined(_WIN32)/* * Map __printf__ to __gnu_printf__ because we want standard format strings even * when MinGW or GLib include files use __printf__. */ # define __printf__ __gnu_printf__#endif #ifndef __has_warning#define __has_warning (x) 0/* compatibility with non-clang compilers */ #endif #ifndef __has_feature#define __has_feature (x) 0/* compatibility with non-clang compilers */ #endif #ifndef __has_builtin#define __has_builtin (x) 0/* compatibility with non-clang compilers */ #endif #if __has_builtin (__builtin_assume_aligned) || !defined(__clang__)#define HAS_ASSUME_ALIGNED #endif #ifndef __has_attribute#define __has_attribute (x) 0/* compatibility with older GCC */ #endif #if defined(__SANITIZE_ADDRESS__) ||__has_feature (address_sanitizer)# define QEMU_SANITIZE_ADDRESS 1#endif #if defined(__SANITIZE_THREAD__) ||__has_feature (thread_sanitizer)# define QEMU_SANITIZE_THREAD 1#endif /* * GCC doesn't provide __has_attribute() until GCC 5, but we know all the GCC * versions we support have the "flatten" attribute. Clang may not have the * "flatten" attribute but always has __has_attribute() to check for it. */ #if __has_attribute (flatten) || !defined(__clang__)# define QEMU_FLATTEN __attribute__((flatten))#else # define QEMU_FLATTEN #endif /* * If __attribute__((error)) is present, use it to produce an error at * compile time. Otherwise, one must wait for the linker to diagnose * the missing symbol. */ #if __has_attribute (error)# define QEMU_ERROR (X ) __attribute__((error(X)))#else # define QEMU_ERROR (X )#endif /* * The nonstring variable attribute specifies that an object or member * declaration with type array of char or pointer to char is intended * to store character arrays that do not necessarily contain a terminating * NUL character. This is useful in detecting uses of such arrays or pointers * with functions that expect NUL-terminated strings, and to avoid warnings * when such an array or pointer is used as an argument to a bounded string * manipulation function such as strncpy. */ #if __has_attribute (nonstring)# define QEMU_NONSTRING __attribute__((nonstring))#else # define QEMU_NONSTRING #endif /* * Forced inlining may be desired to encourage constant propagation * of function parameters. However, it can also make debugging harder, * so disable it for a non-optimizing build. */ #if defined(__OPTIMIZE__)#define QEMU_ALWAYS_INLINE __attribute__((always_inline))#else #define QEMU_ALWAYS_INLINE #endif -/** -* In most cases, normal "fallthrough" comments are good enough for -* switch-case statements, but sometimes the compiler has problems -* with those. In that case you can use QEMU_FALLTHROUGH instead. +/* +* Add the pseudo keyword 'fallthrough' so case statement blocks +* must end with any of these keywords: +* break; +* fallthrough; +* continue; +* goto <label>; +* return [expression]; +* +* gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes */ -#if __has_attribute (fallthrough) -# define QEMU_FALLTHROUGH __attribute__((fallthrough)) + +/* +* glib_macros.h contains its own definition of fallthrough, so if we define +* the pseudokeyword here it will expand when the glib header checks for the +* attribute. glib headers must be #included after this header. +*/ +#ifdef fallthrough +#undef fallthrough +#endif + +#if __has_attribute (__fallthrough__) +# define fallthrough __attribute__((__fallthrough__))#else -# define QEMU_FALLTHROUGH do {} while (0)/* fallthrough */ +# define fallthrough do {} while (0)/* fallthrough */ #endif #ifdef CONFIG_CFI /* * If CFI is enabled, use an attribute to disable cfi-icall on the following * function */ #define QEMU_DISABLE_CFI __attribute__((no_sanitize("cfi-icall")))#else /* If CFI is not enabled, use an empty define to not change the behavior */ #define QEMU_DISABLE_CFI #endif /* * Apple clang version 14 has a bug in its __builtin_subcll(); define * BUILTIN_SUBCLL_BROKEN for the offending versions so we can avoid it. * When a version of Apple clang which has this bug fixed is released * we can add an upper bound to this check. * See https://gitlab.com/qemu-project/qemu/-/issues/1631 * and https://gitlab.com/qemu-project/qemu/-/issues/1659 for details. * The bug never made it into any upstream LLVM releases, only Apple ones. */ #if defined(__apple_build_version__) && __clang_major__ >=14 #define BUILTIN_SUBCLL_BROKEN #endif #if __has_attribute (annotate)#define QEMU_ANNOTATE (x) __attribute__((annotate(x)))#else #define QEMU_ANNOTATE (x)#endif #if __has_attribute (used)# define QEMU_USED __attribute__((used))#else # define QEMU_USED #endif #endif /* COMPILER_H */
include/qemu/osdep.h +2 -2
@@ -1,171 +1,171 @@/* * OS includes and handling of OS dependencies * * This header exists to pull in some common system headers that * most code in QEMU will want, and to fix up some possible issues with * it (missing defines, Windows weirdness, and so on). * * To avoid getting into possible circular include dependencies, this * file should not include any other QEMU headers, with the exceptions * of config-host.h, config-target.h, qemu/compiler.h, * sysemu/os-posix.h, sysemu/os-win32.h, glib-compat.h and * qemu/typedefs.h, all of which are doing a similar job to this file * and are under similar constraints. * * This header also contains prototypes for functions defined in * os-*.c and util/oslib-*.c; those would probably be better split * out into separate header files. * * In an ideal world this header would contain only: * (1) things which everybody needs * (2) things without which code would work on most platforms but * fail to compile or misbehave on a minority of host OSes * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ #ifndef QEMU_OSDEP_H #define QEMU_OSDEP_H #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ && defined __linux__# define _FORTIFY_SOURCE 2#endif #include "config-host.h" #ifdef NEED_CPU_H #include CONFIG_TARGET #else #include "exec/poison.h" #endif /* * HOST_WORDS_BIGENDIAN was replaced with HOST_BIG_ENDIAN. Prevent it from * creeping back in. */ #pragma GCC poison HOST_WORDS_BIGENDIAN/* * TARGET_WORDS_BIGENDIAN was replaced with TARGET_BIG_ENDIAN. Prevent it from * creeping back in. */ #pragma GCC poison TARGET_WORDS_BIGENDIAN -#include "qemu/compiler.h" -/* Older versions of C++ don't get definitions of various macros from * stdlib.h unless we define these macros before first inclusion of * that system header. */ #ifndef __STDC_CONSTANT_MACROS#define __STDC_CONSTANT_MACROS#endif #ifndef __STDC_LIMIT_MACROS#define __STDC_LIMIT_MACROS#endif #ifndef __STDC_FORMAT_MACROS#define __STDC_FORMAT_MACROS#endif /* The following block of code temporarily renames the daemon() function so the * compiler does not see the warning associated with it in stdlib.h on OSX */ #ifdef __APPLE__#define daemon qemu_fake_daemon_function#include <stdlib.h> #undef daemon QEMU_EXTERN_C int daemon(int, int);#endif #ifdef _WIN32/* as defined in sdkddkver.h */ #ifndef _WIN32_WINNT#define _WIN32_WINNT 0x0602/* Windows 8 API (should be >= the one from glib) */ #endif /* reduces the number of implicitly included headers */ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #endif /* enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) */ #ifdef __MINGW32__#define __USE_MINGW_ANSI_STDIO 1#endif /* * We need the FreeBSD "legacy" definitions. Rust needs the FreeBSD 11 system * calls since it doesn't use libc at all, so we have to emulate that despite * FreeBSD 11 being EOL'd. */ #ifdef __FreeBSD__#define _WANT_FREEBSD11_STAT#define _WANT_FREEBSD11_STATFS#define _WANT_FREEBSD11_DIRENT#define _WANT_KERNEL_ERRNO#define _WANT_SEMUN#endif #include <stdarg.h> #include <stddef.h> #include <stdbool.h> #include <stdint.h> #include <sys/types.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <inttypes.h> #include <limits.h> /* Put unistd.h before time.h as that triggers localtime_r/gmtime_r * function availability on recentish Mingw-w64 platforms. */ #include <unistd.h> #include <time.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> #include <getopt.h> #include <sys/stat.h> #include <sys/time.h> #include <assert.h> /* setjmp must be declared before sysemu/os-win32.h * because it is redefined there. */ #include <setjmp.h> #include <signal.h> #ifdef CONFIG_IOVEC #include <sys/uio.h> #endif #if defined(__linux__) && defined(__sparc__)/* The SPARC definition of QEMU_VMALLOC_ALIGN needs SHMLBA */ #include <sys/shm.h> #endif #ifndef _WIN32#include <sys/wait.h> #else #define WIFEXITED (x) 1#define WEXITSTATUS (x) (x)#endif #ifdef __APPLE__#include <AvailabilityMacros.h> #endif /* * This is somewhat like a system header; it must be outside any extern "C" * block because it includes system headers itself, including glib.h, * which will not compile if inside an extern "C" block. */ #include "glib-compat.h" +#include "qemu/compiler.h" +#ifdef _WIN32#include "sysemu/os-win32.h" #endif #ifdef CONFIG_POSIX #include "sysemu/os-posix.h" #endif #ifdef __cplusplus
target/loongarch/cpu.c +2 -2
@@ -142,145 +142,145 @@ static inline bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env)static void loongarch_cpu_do_interrupt (CPUState *cs) {LoongArchCPU *cpu =LOONGARCH_CPU (cs);CPULoongArchState *env = &cpu->env;bool update_badinstr =1 ;int cause =-1 ;const char *name;bool tlbfill =FIELD_EX64 (env->CSR_TLBRERA,CSR_TLBRERA ,ISTLBR );uint32_t vec_size =FIELD_EX64 (env->CSR_ECFG,CSR_ECFG ,VS );if (cs->exception_index !=EXCCODE_INT ) {if (cs->exception_index <0 || cs->exception_index >=ARRAY_SIZE (excp_names)) { name ="unknown" ; }else { name = excp_names[cs->exception_index]; }qemu_log_mask (CPU_LOG_INT ,"%s enter: pc " TARGET_FMT_lx" ERA " TARGET_FMT_lx" TLBRERA " TARGET_FMT_lx" %s exception\n" , __func__, env->pc, env->CSR_ERA, env->CSR_TLBRERA, name); }switch (cs->exception_index) {case EXCCODE_DBP : env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,DCL ,1 ); env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,ECODE ,0xC ); goto set_DERA; set_DERA: env->CSR_DERA = env->pc; env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,DST ,1 );set_pc (env, env->CSR_EENTRY +0x480 );break ;case EXCCODE_INT :if (FIELD_EX64 (env->CSR_DBG,CSR_DBG ,DST )) { env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,DEI ,1 ); goto set_DERA; } -QEMU_FALLTHROUGH ; + fallthrough;case EXCCODE_PIF :case EXCCODE_ADEF : cause = cs->exception_index; update_badinstr =0 ;break ;case EXCCODE_SYS :case EXCCODE_BRK :case EXCCODE_INE :case EXCCODE_IPE :case EXCCODE_FPD :case EXCCODE_FPE :case EXCCODE_SXD :case EXCCODE_ASXD : env->CSR_BADV = env->pc; -QEMU_FALLTHROUGH ; + fallthrough;case EXCCODE_BCE :case EXCCODE_ADEM :case EXCCODE_PIL :case EXCCODE_PIS :case EXCCODE_PME :case EXCCODE_PNR :case EXCCODE_PNX :case EXCCODE_PPI : cause = cs->exception_index;break ;default :qemu_log ("Error: exception(%d) has not been supported\n" , cs->exception_index);abort (); }if (update_badinstr) { env->CSR_BADI =cpu_ldl_code (env, env->pc); }/* Save PLV and IE */ if (tlbfill) { env->CSR_TLBRPRMD =FIELD_DP64 (env->CSR_TLBRPRMD,CSR_TLBRPRMD ,PPLV ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,PLV )); env->CSR_TLBRPRMD =FIELD_DP64 (env->CSR_TLBRPRMD,CSR_TLBRPRMD ,PIE ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,IE ));/* set the DA mode */ env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,DA ,1 ); env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,PG ,0 ); env->CSR_TLBRERA =FIELD_DP64 (env->CSR_TLBRERA,CSR_TLBRERA ,PC , (env->pc >>2 )); }else { env->CSR_ESTAT =FIELD_DP64 (env->CSR_ESTAT,CSR_ESTAT ,ECODE ,EXCODE_MCODE (cause)); env->CSR_ESTAT =FIELD_DP64 (env->CSR_ESTAT,CSR_ESTAT ,ESUBCODE ,EXCODE_SUBCODE (cause)); env->CSR_PRMD =FIELD_DP64 (env->CSR_PRMD,CSR_PRMD ,PPLV ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,PLV )); env->CSR_PRMD =FIELD_DP64 (env->CSR_PRMD,CSR_PRMD ,PIE ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,IE )); env->CSR_ERA = env->pc; } env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,PLV ,0 ); env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,IE ,0 );if (vec_size) { vec_size = (1 << vec_size) *4 ; }if (cs->exception_index ==EXCCODE_INT ) {/* Interrupt */ uint32_t vector =0 ;uint32_t pending =FIELD_EX64 (env->CSR_ESTAT,CSR_ESTAT ,IS ); pending &=FIELD_EX64 (env->CSR_ECFG,CSR_ECFG ,LIE );/* Find the highest-priority interrupt. */ vector =31 -clz32 (pending);set_pc (env, env->CSR_EENTRY + \ (EXCCODE_EXTERNAL_INT + vector) * vec_size);qemu_log_mask (CPU_LOG_INT ,"%s: PC " TARGET_FMT_lx" ERA " TARGET_FMT_lx" cause %d\n" " A " TARGET_FMT_lx" D " TARGET_FMT_lx" vector = %d ExC " TARGET_FMT_lx"ExS" TARGET_FMT_lx"\n" , __func__, env->pc, env->CSR_ERA, cause, env->CSR_BADV, env->CSR_DERA, vector, env->CSR_ECFG, env->CSR_ESTAT); }else {if (tlbfill) {set_pc (env, env->CSR_TLBRENTRY); }else {set_pc (env, env->CSR_EENTRY +EXCODE_MCODE (cause) * vec_size); }qemu_log_mask (CPU_LOG_INT ,"%s: PC " TARGET_FMT_lx" ERA " TARGET_FMT_lx" cause %d%s\n, ESTAT " TARGET_FMT_lx" EXCFG " TARGET_FMT_lx" BADVA " TARGET_FMT_lx"BADI " TARGET_FMT_lx" SYS_NUM " TARGET_FMT_lu" cpu %d asid " TARGET_FMT_lx"\n" , __func__, env->pc, tlbfill ? env->CSR_TLBRERA : env->CSR_ERA, cause, tlbfill ?"(refill)" :"" , env->CSR_ESTAT, env->CSR_ECFG, tlbfill ? env->CSR_TLBRBADV : env->CSR_BADV, env->CSR_BADI, env->gpr[11 ], cs->cpu_index, env->CSR_ASID); } cs->exception_index =-1 ; }
target/loongarch/translate.c +1 -1
@@ -304,24 +304,24 @@ static void loongarch_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)static void loongarch_tr_tb_stop (DisasContextBase *dcbase,CPUState *cs) {DisasContext *ctx =container_of (dcbase, DisasContext, base);switch (ctx->base.is_jmp) {case DISAS_STOP :tcg_gen_movi_tl (cpu_pc, ctx->base.pc_next);tcg_gen_lookup_and_goto_ptr ();break ;case DISAS_TOO_MANY :gen_goto_tb (ctx,0 , ctx->base.pc_next);break ;case DISAS_NORETURN :break ;case DISAS_EXIT_UPDATE :tcg_gen_movi_tl (cpu_pc, ctx->base.pc_next); -QEMU_FALLTHROUGH ; + fallthrough;case DISAS_EXIT :tcg_gen_exit_tb (NULL ,0 );break ;default :g_assert_not_reached (); } }
tcg/optimize.c +4 -4
@@ -1062,81 +1062,81 @@ static bool fold_brcond(OptContext *ctx, TCGOp *op)static bool fold_brcond2 (OptContext *ctx,TCGOp *op) {TCGCond cond = op->args[4 ];TCGArg label = op->args[5 ];int i, inv =0 ;if (swap_commutative2 (&op->args[0 ], &op->args[2 ])) { op->args[4 ] = cond =tcg_swap_cond (cond); } i =do_constant_folding_cond2 (&op->args[0 ], &op->args[2 ], cond);if (i >=0 ) { goto do_brcond_const; }switch (cond) {case TCG_COND_LT :case TCG_COND_GE :/* * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ if (arg_is_const (op->args[2 ]) &&arg_info (op->args[2 ])->val ==0 &&arg_is_const (op->args[3 ]) &&arg_info (op->args[3 ])->val ==0 ) { goto do_brcond_high; }break ;case TCG_COND_NE : inv =1 ; -QEMU_FALLTHROUGH ; + fallthrough;case TCG_COND_EQ :/* * Simplify EQ/NE comparisons where one of the pairs * can be simplified. */ i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[0 ], op->args[2 ], cond);switch (i ^ inv) {case 0 : goto do_brcond_const;case 1 : goto do_brcond_high; } i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[1 ], op->args[3 ], cond);switch (i ^ inv) {case 0 : goto do_brcond_const;case 1 : op->opc = INDEX_op_brcond_i32; op->args[1 ] = op->args[2 ]; op->args[2 ] = cond; op->args[3 ] = label;break ; }break ;default :break ; do_brcond_high: op->opc = INDEX_op_brcond_i32; op->args[0 ] = op->args[1 ]; op->args[1 ] = op->args[3 ]; op->args[2 ] = cond; op->args[3 ] = label;break ; do_brcond_const:if (i ==0 ) {tcg_op_remove (ctx->tcg, op);return true; } op->opc = INDEX_op_br; op->args[0 ] = label;break ; }return false; }
@@ -1424,46 +1424,46 @@ static bool fold_extract2(OptContext *ctx, TCGOp *op)static bool fold_exts (OptContext *ctx,TCGOp *op) {uint64_t s_mask_old, s_mask, z_mask, sign;bool type_change = false;if (fold_const1 (ctx, op)) {return true; } z_mask =arg_info (op->args[1 ])->z_mask; s_mask =arg_info (op->args[1 ])->s_mask; s_mask_old = s_mask;switch (op->opc) { CASE_OP_32_64(ext8s): sign =INT8_MIN ; z_mask = (uint8_t )z_mask;break ; CASE_OP_32_64(ext16s): sign =INT16_MIN ; z_mask = (uint16_t )z_mask;break ;case INDEX_op_ext_i32_i64: type_change = true; -QEMU_FALLTHROUGH ; + fallthrough;case INDEX_op_ext32s_i64: sign =INT32_MIN ; z_mask = (uint32_t )z_mask;break ;default :g_assert_not_reached (); }if (z_mask & sign) { z_mask |= sign; } s_mask |= sign <<1 ; ctx->z_mask = z_mask; ctx->s_mask = s_mask;if (!type_change) { ctx->a_mask = s_mask & ~s_mask_old; }return fold_masks (ctx, op); }
@@ -1471,40 +1471,40 @@ static bool fold_exts(OptContext *ctx, TCGOp *op)static bool fold_extu (OptContext *ctx,TCGOp *op) {uint64_t z_mask_old, z_mask;bool type_change = false;if (fold_const1 (ctx, op)) {return true; } z_mask_old = z_mask =arg_info (op->args[1 ])->z_mask;switch (op->opc) { CASE_OP_32_64(ext8u): z_mask = (uint8_t )z_mask;break ; CASE_OP_32_64(ext16u): z_mask = (uint16_t )z_mask;break ;case INDEX_op_extrl_i64_i32:case INDEX_op_extu_i32_i64: type_change = true; -QEMU_FALLTHROUGH ; + fallthrough;case INDEX_op_ext32u_i64: z_mask = (uint32_t )z_mask;break ;case INDEX_op_extrh_i64_i32: type_change = true; z_mask >>=32 ;break ;default :g_assert_not_reached (); } ctx->z_mask = z_mask; ctx->s_mask =smask_from_zmask (z_mask);if (!type_change) { ctx->a_mask = z_mask_old ^ z_mask; }return fold_masks (ctx, op); }
@@ -1835,75 +1835,75 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op)static bool fold_setcond2 (OptContext *ctx,TCGOp *op) {TCGCond cond = op->args[5 ];int i, inv =0 ;if (swap_commutative2 (&op->args[1 ], &op->args[3 ])) { op->args[5 ] = cond =tcg_swap_cond (cond); } i =do_constant_folding_cond2 (&op->args[1 ], &op->args[3 ], cond);if (i >=0 ) { goto do_setcond_const; }switch (cond) {case TCG_COND_LT :case TCG_COND_GE :/* * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ if (arg_is_const (op->args[3 ]) &&arg_info (op->args[3 ])->val ==0 &&arg_is_const (op->args[4 ]) &&arg_info (op->args[4 ])->val ==0 ) { goto do_setcond_high; }break ;case TCG_COND_NE : inv =1 ; -QEMU_FALLTHROUGH ; + fallthrough;case TCG_COND_EQ :/* * Simplify EQ/NE comparisons where one of the pairs * can be simplified. */ i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[1 ], op->args[3 ], cond);switch (i ^ inv) {case 0 : goto do_setcond_const;case 1 : goto do_setcond_high; } i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[2 ], op->args[4 ], cond);switch (i ^ inv) {case 0 : goto do_setcond_const;case 1 : op->args[2 ] = op->args[3 ]; op->args[3 ] = cond; op->opc = INDEX_op_setcond_i32;break ; }break ;default :break ; do_setcond_high: op->args[1 ] = op->args[2 ]; op->args[2 ] = op->args[4 ]; op->args[3 ] = cond; op->opc = INDEX_op_setcond_i32;break ; } ctx->z_mask =1 ; ctx->s_mask =smask_from_zmask (1 );return false; do_setcond_const:return tcg_opt_gen_movi (ctx, op, op->args[0 ], i); }
Signature · 1 line
2.39.2
Re: [RFC PATCH 01/78] include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough
Quoted 10 lines · Emmanouil Pitsidianakis
Signed-off-by Emmanouil Pitsidianakis <[email protected]>--- audio/pwaudio.c | 8 ++++---- hw/arm/smmuv3.c | 2 +- include/qemu/compiler.h | 30 +++++++++++++++++++++++------- include/qemu/osdep.h | 4 ++-- target/loongarch/cpu.c | 4 ++-- target/loongarch/translate.c | 2 +- tcg/optimize.c | 8 ++++---- 7 files changed, 37 insertions(+), 21 deletions(-)
This patch (and all the others in the series) have a ridiculously large context either side of the change. It makes this horrible to review as it requires wading through pages of pre-existing code trying to spot the change.
Please send patches with the default git context lines setting.
Quoted 1,116 lines
audio/pwaudio.c +4
-4@@ -1,29 +1,29 @@/* * QEMU PipeWire audio driver * * Copyright (c) 2023 Red Hat Inc. * * Author: Dorinda Bassey <[email protected]> * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include <spa/param/audio/format-utils.h> +#include <spa/utils/ringbuffer.h> +#include <spa/utils/result.h> +#include <spa/param/props.h> #include "qemu/osdep.h" #include "qemu/module.h" #include "audio.h" #include <errno.h> #include "qemu/error-report.h" #include "qapi/error.h" -#include <spa/param/audio/format-utils.h> -#include <spa/utils/ringbuffer.h> -#include <spa/utils/result.h> -#include <spa/param/props.h> #include <pipewire/pipewire.h> #include "trace.h" #define AUDIO_CAP "pipewire"#define RINGBUFFER_SIZE (1u << 22)#define RINGBUFFER_MASK (RINGBUFFER_SIZE - 1)#include "audio_int.h" hw/arm/smmuv3.c +1
-1@@ -1166,210 +1166,210 @@ smmuv3_invalidate_ste(gpointer key, gpointer value, gpointer user_data)static int smmuv3_cmdq_consume (SMMUv3State *s) {SMMUState *bs =ARM_SMMU (s);SMMUCmdError cmd_error =SMMU_CERROR_NONE ;SMMUQueue *q = &s->cmdq;SMMUCommandType type =0 ;if (!smmuv3_cmdq_enabled (s)) {return 0 ; }/* * some commands depend on register values, typically CR0. In case those * register values change while handling the command, spec says it * is UNPREDICTABLE whether the command is interpreted under the new * or old value. */ while (!smmuv3_q_empty (q)) {uint32_t pending = s->gerror ^ s->gerrorn;Cmd cmd;trace_smmuv3_cmdq_consume (Q_PROD (q),Q_CONS (q),Q_PROD_WRAP (q),Q_CONS_WRAP (q));if (FIELD_EX32 (pending,GERROR ,CMDQ_ERR )) {break ; }if (queue_read (q, &cmd) !=MEMTX_OK ) { cmd_error =SMMU_CERROR_ABT ;break ; } type =CMD_TYPE (&cmd);trace_smmuv3_cmdq_opcode (smmu_cmd_string (type));qemu_mutex_lock (&s->mutex);switch (type) {case SMMU_CMD_SYNC :if (CMD_SYNC_CS (&cmd) &CMD_SYNC_SIG_IRQ ) {smmuv3_trigger_irq (s,SMMU_IRQ_CMD_SYNC ,0 ); }break ;case SMMU_CMD_PREFETCH_CONFIG :case SMMU_CMD_PREFETCH_ADDR :break ;case SMMU_CMD_CFGI_STE : {uint32_t sid =CMD_SID (&cmd);IOMMUMemoryRegion *mr =smmu_iommu_mr (bs, sid);SMMUDevice *sdev;if (CMD_SSEC (&cmd)) { cmd_error =SMMU_CERROR_ILL ;break ; }if (!mr) {break ; }trace_smmuv3_cmdq_cfgi_ste (sid); sdev =container_of (mr, SMMUDevice, iommu);smmuv3_flush_config (sdev);break ; }case SMMU_CMD_CFGI_STE_RANGE :/* same as SMMU_CMD_CFGI_ALL */ {uint32_t sid =CMD_SID (&cmd), mask;uint8_t range =CMD_STE_RANGE (&cmd);SMMUSIDRange sid_range;if (CMD_SSEC (&cmd)) { cmd_error =SMMU_CERROR_ILL ;break ; } mask = (1ULL << (range +1 )) -1 ; sid_range.start = sid & ~mask; sid_range.end = sid_range.start + mask;trace_smmuv3_cmdq_cfgi_ste_range (sid_range.start, sid_range.end);g_hash_table_foreach_remove (bs->configs, smmuv3_invalidate_ste, &sid_range);break ; }case SMMU_CMD_CFGI_CD :case SMMU_CMD_CFGI_CD_ALL : {uint32_t sid =CMD_SID (&cmd);IOMMUMemoryRegion *mr =smmu_iommu_mr (bs, sid);SMMUDevice *sdev;if (CMD_SSEC (&cmd)) { cmd_error =SMMU_CERROR_ILL ;break ; }if (!mr) {break ; }trace_smmuv3_cmdq_cfgi_cd (sid); sdev =container_of (mr, SMMUDevice, iommu);smmuv3_flush_config (sdev);break ; }case SMMU_CMD_TLBI_NH_ASID : {uint16_t asid =CMD_ASID (&cmd);if (!STAGE1_SUPPORTED (s)) { cmd_error =SMMU_CERROR_ILL ;break ; }trace_smmuv3_cmdq_tlbi_nh_asid (asid);smmu_inv_notifiers_all (&s->smmu_state);smmu_iotlb_inv_asid (bs, asid);break ; }case SMMU_CMD_TLBI_NH_ALL :if (!STAGE1_SUPPORTED (s)) { cmd_error =SMMU_CERROR_ILL ;break ; } -QEMU_FALLTHROUGH ; + fallthrough;case SMMU_CMD_TLBI_NSNH_ALL :trace_smmuv3_cmdq_tlbi_nh ();smmu_inv_notifiers_all (&s->smmu_state);smmu_iotlb_inv_all (bs);break ;case SMMU_CMD_TLBI_NH_VAA :case SMMU_CMD_TLBI_NH_VA :if (!STAGE1_SUPPORTED (s)) { cmd_error =SMMU_CERROR_ILL ;break ; }smmuv3_range_inval (bs, &cmd);break ;case SMMU_CMD_TLBI_S12_VMALL : {uint16_t vmid =CMD_VMID (&cmd);if (!STAGE2_SUPPORTED (s)) { cmd_error =SMMU_CERROR_ILL ;break ; }trace_smmuv3_cmdq_tlbi_s12_vmid (vmid);smmu_inv_notifiers_all (&s->smmu_state);smmu_iotlb_inv_vmid (bs, vmid);break ; }case SMMU_CMD_TLBI_S2_IPA :if (!STAGE2_SUPPORTED (s)) { cmd_error =SMMU_CERROR_ILL ;break ; }/* * As currently only either s1 or s2 are supported * we can reuse same function for s2. */ smmuv3_range_inval (bs, &cmd);break ;case SMMU_CMD_TLBI_EL3_ALL :case SMMU_CMD_TLBI_EL3_VA :case SMMU_CMD_TLBI_EL2_ALL :case SMMU_CMD_TLBI_EL2_ASID :case SMMU_CMD_TLBI_EL2_VA :case SMMU_CMD_TLBI_EL2_VAA :case SMMU_CMD_ATC_INV :case SMMU_CMD_PRI_RESP :case SMMU_CMD_RESUME :case SMMU_CMD_STALL_TERM :trace_smmuv3_unhandled_cmd (type);break ;default : cmd_error =SMMU_CERROR_ILL ;break ; }qemu_mutex_unlock (&s->mutex);if (cmd_error) {if (cmd_error ==SMMU_CERROR_ILL ) {qemu_log_mask (LOG_GUEST_ERROR ,"Illegal command type: %d\n" ,CMD_TYPE (&cmd)); }break ; }/* * We only increment the cons index after the completion of * the command. We do that because the SYNC returns immediately * and does not check the completion of previous commands */ queue_cons_incr (q); }if (cmd_error) {trace_smmuv3_cmdq_consume_error (smmu_cmd_string (type), cmd_error);smmu_write_cmdq_err (s, cmd_error);smmuv3_trigger_irq (s,SMMU_IRQ_GERROR ,R_GERROR_CMDQ_ERR_MASK ); }trace_smmuv3_cmdq_consume_out (Q_PROD (q),Q_CONS (q),Q_PROD_WRAP (q),Q_CONS_WRAP (q));return 0 ; }include/qemu/compiler.h +23
-7@@ -1,215 +1,231 @@/* compiler.h: macros to abstract away compiler specifics * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ #ifndef COMPILER_H #define COMPILER_H #define HOST_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)/* HOST_LONG_BITS is the size of a native pointer in bits. */ #define HOST_LONG_BITS (__SIZEOF_POINTER__ * 8)#if defined __clang_analyzer__ || defined __COVERITY__#define QEMU_STATIC_ANALYSIS 1#endif #ifdef __cplusplus#define QEMU_EXTERN_C extern "C"#else #define QEMU_EXTERN_C extern#endif #if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))# define QEMU_PACKED __attribute__((gcc_struct, packed))#else # define QEMU_PACKED __attribute__((packed))#endif #define QEMU_ALIGNED (X ) __attribute__((aligned(X)))#ifndef glue#define xglue (x, y) x ## y#define glue (x, y) xglue(x, y)#define stringify (s) tostring(s)#define tostring (s) #s#endif /* Expands into an identifier stemN, where N is another number each time */ #define MAKE_IDENTFIER (stem) glue(stem, __COUNTER__)#ifndef likely#define likely (x) __builtin_expect(!!(x), 1)#define unlikely (x) __builtin_expect(!!(x), 0)#endif #ifndef container_of#define container_of (ptr, type, member) ({ \ const typeof(((type *) 0)->member) *__mptr = (ptr); \ (type *) ((char *) __mptr - offsetof(type, member));})#endif #define sizeof_field (type, field) sizeof(((type *)0)->field)/* * Calculate the number of bytes up to and including the given 'field' of * 'container'. */ #define endof (container, field) \ (offsetof(container, field) + sizeof_field(container, field))/* Convert from a base type to a parent type, with compile time checking. */ #define DO_UPCAST (type, field, dev) ( __extension__ ( { \ char __attribute__((unused)) offset_must_be_zero[ \ -offsetof(type, field)]; \ container_of(dev, type, field);}))#define typeof_field (type, field) typeof(((type *)0)->field)#define type_check (t1,t2) ((t1*)0 - (t2*)0)#define QEMU_BUILD_BUG_ON_STRUCT (x) \ struct { \ int:(x) ? -1 : 1; \ }#define QEMU_BUILD_BUG_MSG (x, msg) _Static_assert(!(x), msg)#define QEMU_BUILD_BUG_ON (x) QEMU_BUILD_BUG_MSG(x, "not expecting: " #x)#define QEMU_BUILD_BUG_ON_ZERO (x) (sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)) - \ sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)))#if !defined(__clang__) && defined(_WIN32)/* * Map __printf__ to __gnu_printf__ because we want standard format strings even * when MinGW or GLib include files use __printf__. */ # define __printf__ __gnu_printf__#endif #ifndef __has_warning#define __has_warning (x) 0/* compatibility with non-clang compilers */ #endif #ifndef __has_feature#define __has_feature (x) 0/* compatibility with non-clang compilers */ #endif #ifndef __has_builtin#define __has_builtin (x) 0/* compatibility with non-clang compilers */ #endif #if __has_builtin (__builtin_assume_aligned) || !defined(__clang__)#define HAS_ASSUME_ALIGNED #endif #ifndef __has_attribute#define __has_attribute (x) 0/* compatibility with older GCC */ #endif #if defined(__SANITIZE_ADDRESS__) ||__has_feature (address_sanitizer)# define QEMU_SANITIZE_ADDRESS 1#endif #if defined(__SANITIZE_THREAD__) ||__has_feature (thread_sanitizer)# define QEMU_SANITIZE_THREAD 1#endif /* * GCC doesn't provide __has_attribute() until GCC 5, but we know all the GCC * versions we support have the "flatten" attribute. Clang may not have the * "flatten" attribute but always has __has_attribute() to check for it. */ #if __has_attribute (flatten) || !defined(__clang__)# define QEMU_FLATTEN __attribute__((flatten))#else # define QEMU_FLATTEN #endif /* * If __attribute__((error)) is present, use it to produce an error at * compile time. Otherwise, one must wait for the linker to diagnose * the missing symbol. */ #if __has_attribute (error)# define QEMU_ERROR (X ) __attribute__((error(X)))#else # define QEMU_ERROR (X )#endif /* * The nonstring variable attribute specifies that an object or member * declaration with type array of char or pointer to char is intended * to store character arrays that do not necessarily contain a terminating * NUL character. This is useful in detecting uses of such arrays or pointers * with functions that expect NUL-terminated strings, and to avoid warnings * when such an array or pointer is used as an argument to a bounded string * manipulation function such as strncpy. */ #if __has_attribute (nonstring)# define QEMU_NONSTRING __attribute__((nonstring))#else # define QEMU_NONSTRING #endif /* * Forced inlining may be desired to encourage constant propagation * of function parameters. However, it can also make debugging harder, * so disable it for a non-optimizing build. */ #if defined(__OPTIMIZE__)#define QEMU_ALWAYS_INLINE __attribute__((always_inline))#else #define QEMU_ALWAYS_INLINE #endif -/** -* In most cases, normal "fallthrough" comments are good enough for -* switch-case statements, but sometimes the compiler has problems -* with those. In that case you can use QEMU_FALLTHROUGH instead. +/* +* Add the pseudo keyword 'fallthrough' so case statement blocks +* must end with any of these keywords: +* break; +* fallthrough; +* continue; +* goto <label>; +* return [expression]; +* +* gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes */ -#if __has_attribute (fallthrough) -# define QEMU_FALLTHROUGH __attribute__((fallthrough)) + +/* +* glib_macros.h contains its own definition of fallthrough, so if we define +* the pseudokeyword here it will expand when the glib header checks for the +* attribute. glib headers must be #included after this header. +*/ +#ifdef fallthrough +#undef fallthrough +#endif + +#if __has_attribute (__fallthrough__) +# define fallthrough __attribute__((__fallthrough__))#else -# define QEMU_FALLTHROUGH do {} while (0)/* fallthrough */ +# define fallthrough do {} while (0)/* fallthrough */ #endif #ifdef CONFIG_CFI /* * If CFI is enabled, use an attribute to disable cfi-icall on the following * function */ #define QEMU_DISABLE_CFI __attribute__((no_sanitize("cfi-icall")))#else /* If CFI is not enabled, use an empty define to not change the behavior */ #define QEMU_DISABLE_CFI #endif /* * Apple clang version 14 has a bug in its __builtin_subcll(); define * BUILTIN_SUBCLL_BROKEN for the offending versions so we can avoid it. * When a version of Apple clang which has this bug fixed is released * we can add an upper bound to this check. * See https://gitlab.com/qemu-project/qemu/-/issues/1631 * and https://gitlab.com/qemu-project/qemu/-/issues/1659 for details. * The bug never made it into any upstream LLVM releases, only Apple ones. */ #if defined(__apple_build_version__) && __clang_major__ >=14 #define BUILTIN_SUBCLL_BROKEN #endif #if __has_attribute (annotate)#define QEMU_ANNOTATE (x) __attribute__((annotate(x)))#else #define QEMU_ANNOTATE (x)#endif #if __has_attribute (used)# define QEMU_USED __attribute__((used))#else # define QEMU_USED #endif #endif /* COMPILER_H */ include/qemu/osdep.h +2
-2@@ -1,171 +1,171 @@/* * OS includes and handling of OS dependencies * * This header exists to pull in some common system headers that * most code in QEMU will want, and to fix up some possible issues with * it (missing defines, Windows weirdness, and so on). * * To avoid getting into possible circular include dependencies, this * file should not include any other QEMU headers, with the exceptions * of config-host.h, config-target.h, qemu/compiler.h, * sysemu/os-posix.h, sysemu/os-win32.h, glib-compat.h and * qemu/typedefs.h, all of which are doing a similar job to this file * and are under similar constraints. * * This header also contains prototypes for functions defined in * os-*.c and util/oslib-*.c; those would probably be better split * out into separate header files. * * In an ideal world this header would contain only: * (1) things which everybody needs * (2) things without which code would work on most platforms but * fail to compile or misbehave on a minority of host OSes * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ #ifndef QEMU_OSDEP_H #define QEMU_OSDEP_H #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ && defined __linux__# define _FORTIFY_SOURCE 2#endif #include "config-host.h" #ifdef NEED_CPU_H #include CONFIG_TARGET #else #include "exec/poison.h" #endif /* * HOST_WORDS_BIGENDIAN was replaced with HOST_BIG_ENDIAN. Prevent it from * creeping back in. */ #pragma GCC poison HOST_WORDS_BIGENDIAN/* * TARGET_WORDS_BIGENDIAN was replaced with TARGET_BIG_ENDIAN. Prevent it from * creeping back in. */ #pragma GCC poison TARGET_WORDS_BIGENDIAN -#include "qemu/compiler.h" -/* Older versions of C++ don't get definitions of various macros from * stdlib.h unless we define these macros before first inclusion of * that system header. */ #ifndef __STDC_CONSTANT_MACROS#define __STDC_CONSTANT_MACROS#endif #ifndef __STDC_LIMIT_MACROS#define __STDC_LIMIT_MACROS#endif #ifndef __STDC_FORMAT_MACROS#define __STDC_FORMAT_MACROS#endif /* The following block of code temporarily renames the daemon() function so the * compiler does not see the warning associated with it in stdlib.h on OSX */ #ifdef __APPLE__#define daemon qemu_fake_daemon_function#include <stdlib.h> #undef daemon QEMU_EXTERN_C int daemon(int, int);#endif #ifdef _WIN32/* as defined in sdkddkver.h */ #ifndef _WIN32_WINNT#define _WIN32_WINNT 0x0602/* Windows 8 API (should be >= the one from glib) */ #endif /* reduces the number of implicitly included headers */ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #endif /* enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) */ #ifdef __MINGW32__#define __USE_MINGW_ANSI_STDIO 1#endif /* * We need the FreeBSD "legacy" definitions. Rust needs the FreeBSD 11 system * calls since it doesn't use libc at all, so we have to emulate that despite * FreeBSD 11 being EOL'd. */ #ifdef __FreeBSD__#define _WANT_FREEBSD11_STAT#define _WANT_FREEBSD11_STATFS#define _WANT_FREEBSD11_DIRENT#define _WANT_KERNEL_ERRNO#define _WANT_SEMUN#endif #include <stdarg.h> #include <stddef.h> #include <stdbool.h> #include <stdint.h> #include <sys/types.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <inttypes.h> #include <limits.h> /* Put unistd.h before time.h as that triggers localtime_r/gmtime_r * function availability on recentish Mingw-w64 platforms. */ #include <unistd.h> #include <time.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> #include <getopt.h> #include <sys/stat.h> #include <sys/time.h> #include <assert.h> /* setjmp must be declared before sysemu/os-win32.h * because it is redefined there. */ #include <setjmp.h> #include <signal.h> #ifdef CONFIG_IOVEC #include <sys/uio.h> #endif #if defined(__linux__) && defined(__sparc__)/* The SPARC definition of QEMU_VMALLOC_ALIGN needs SHMLBA */ #include <sys/shm.h> #endif #ifndef _WIN32#include <sys/wait.h> #else #define WIFEXITED (x) 1#define WEXITSTATUS (x) (x)#endif #ifdef __APPLE__#include <AvailabilityMacros.h> #endif /* * This is somewhat like a system header; it must be outside any extern "C" * block because it includes system headers itself, including glib.h, * which will not compile if inside an extern "C" block. */ #include "glib-compat.h" +#include "qemu/compiler.h" +#ifdef _WIN32#include "sysemu/os-win32.h" #endif #ifdef CONFIG_POSIX #include "sysemu/os-posix.h" #endif #ifdef __cplusplustarget/loongarch/cpu.c +2
-2@@ -142,145 +142,145 @@ static inline bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env)static void loongarch_cpu_do_interrupt (CPUState *cs) {LoongArchCPU *cpu =LOONGARCH_CPU (cs);CPULoongArchState *env = &cpu->env;bool update_badinstr =1 ;int cause =-1 ;const char *name;bool tlbfill =FIELD_EX64 (env->CSR_TLBRERA,CSR_TLBRERA ,ISTLBR );uint32_t vec_size =FIELD_EX64 (env->CSR_ECFG,CSR_ECFG ,VS );if (cs->exception_index !=EXCCODE_INT ) {if (cs->exception_index <0 || cs->exception_index >=ARRAY_SIZE (excp_names)) { name ="unknown" ; }else { name = excp_names[cs->exception_index]; }qemu_log_mask (CPU_LOG_INT ,"%s enter: pc " TARGET_FMT_lx" ERA " TARGET_FMT_lx" TLBRERA " TARGET_FMT_lx" %s exception\n" , __func__, env->pc, env->CSR_ERA, env->CSR_TLBRERA, name); }switch (cs->exception_index) {case EXCCODE_DBP : env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,DCL ,1 ); env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,ECODE ,0xC ); goto set_DERA; set_DERA: env->CSR_DERA = env->pc; env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,DST ,1 );set_pc (env, env->CSR_EENTRY +0x480 );break ;case EXCCODE_INT :if (FIELD_EX64 (env->CSR_DBG,CSR_DBG ,DST )) { env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,DEI ,1 ); goto set_DERA; } -QEMU_FALLTHROUGH ; + fallthrough;case EXCCODE_PIF :case EXCCODE_ADEF : cause = cs->exception_index; update_badinstr =0 ;break ;case EXCCODE_SYS :case EXCCODE_BRK :case EXCCODE_INE :case EXCCODE_IPE :case EXCCODE_FPD :case EXCCODE_FPE :case EXCCODE_SXD :case EXCCODE_ASXD : env->CSR_BADV = env->pc; -QEMU_FALLTHROUGH ; + fallthrough;case EXCCODE_BCE :case EXCCODE_ADEM :case EXCCODE_PIL :case EXCCODE_PIS :case EXCCODE_PME :case EXCCODE_PNR :case EXCCODE_PNX :case EXCCODE_PPI : cause = cs->exception_index;break ;default :qemu_log ("Error: exception(%d) has not been supported\n" , cs->exception_index);abort (); }if (update_badinstr) { env->CSR_BADI =cpu_ldl_code (env, env->pc); }/* Save PLV and IE */ if (tlbfill) { env->CSR_TLBRPRMD =FIELD_DP64 (env->CSR_TLBRPRMD,CSR_TLBRPRMD ,PPLV ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,PLV )); env->CSR_TLBRPRMD =FIELD_DP64 (env->CSR_TLBRPRMD,CSR_TLBRPRMD ,PIE ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,IE ));/* set the DA mode */ env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,DA ,1 ); env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,PG ,0 ); env->CSR_TLBRERA =FIELD_DP64 (env->CSR_TLBRERA,CSR_TLBRERA ,PC , (env->pc >>2 )); }else { env->CSR_ESTAT =FIELD_DP64 (env->CSR_ESTAT,CSR_ESTAT ,ECODE ,EXCODE_MCODE (cause)); env->CSR_ESTAT =FIELD_DP64 (env->CSR_ESTAT,CSR_ESTAT ,ESUBCODE ,EXCODE_SUBCODE (cause)); env->CSR_PRMD =FIELD_DP64 (env->CSR_PRMD,CSR_PRMD ,PPLV ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,PLV )); env->CSR_PRMD =FIELD_DP64 (env->CSR_PRMD,CSR_PRMD ,PIE ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,IE )); env->CSR_ERA = env->pc; } env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,PLV ,0 ); env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,IE ,0 );if (vec_size) { vec_size = (1 << vec_size) *4 ; }if (cs->exception_index ==EXCCODE_INT ) {/* Interrupt */ uint32_t vector =0 ;uint32_t pending =FIELD_EX64 (env->CSR_ESTAT,CSR_ESTAT ,IS ); pending &=FIELD_EX64 (env->CSR_ECFG,CSR_ECFG ,LIE );/* Find the highest-priority interrupt. */ vector =31 -clz32 (pending);set_pc (env, env->CSR_EENTRY + \ (EXCCODE_EXTERNAL_INT + vector) * vec_size);qemu_log_mask (CPU_LOG_INT ,"%s: PC " TARGET_FMT_lx" ERA " TARGET_FMT_lx" cause %d\n" " A " TARGET_FMT_lx" D " TARGET_FMT_lx" vector = %d ExC " TARGET_FMT_lx"ExS" TARGET_FMT_lx"\n" , __func__, env->pc, env->CSR_ERA, cause, env->CSR_BADV, env->CSR_DERA, vector, env->CSR_ECFG, env->CSR_ESTAT); }else {if (tlbfill) {set_pc (env, env->CSR_TLBRENTRY); }else {set_pc (env, env->CSR_EENTRY +EXCODE_MCODE (cause) * vec_size); }qemu_log_mask (CPU_LOG_INT ,"%s: PC " TARGET_FMT_lx" ERA " TARGET_FMT_lx" cause %d%s\n, ESTAT " TARGET_FMT_lx" EXCFG " TARGET_FMT_lx" BADVA " TARGET_FMT_lx"BADI " TARGET_FMT_lx" SYS_NUM " TARGET_FMT_lu" cpu %d asid " TARGET_FMT_lx"\n" , __func__, env->pc, tlbfill ? env->CSR_TLBRERA : env->CSR_ERA, cause, tlbfill ?"(refill)" :"" , env->CSR_ESTAT, env->CSR_ECFG, tlbfill ? env->CSR_TLBRBADV : env->CSR_BADV, env->CSR_BADI, env->gpr[11 ], cs->cpu_index, env->CSR_ASID); } cs->exception_index =-1 ; }target/loongarch/translate.c +1
-1@@ -304,24 +304,24 @@ static void loongarch_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)static void loongarch_tr_tb_stop (DisasContextBase *dcbase,CPUState *cs) {DisasContext *ctx =container_of (dcbase, DisasContext, base);switch (ctx->base.is_jmp) {case DISAS_STOP :tcg_gen_movi_tl (cpu_pc, ctx->base.pc_next);tcg_gen_lookup_and_goto_ptr ();break ;case DISAS_TOO_MANY :gen_goto_tb (ctx,0 , ctx->base.pc_next);break ;case DISAS_NORETURN :break ;case DISAS_EXIT_UPDATE :tcg_gen_movi_tl (cpu_pc, ctx->base.pc_next); -QEMU_FALLTHROUGH ; + fallthrough;case DISAS_EXIT :tcg_gen_exit_tb (NULL ,0 );break ;default :g_assert_not_reached (); } }tcg/optimize.c +4
-4@@ -1062,81 +1062,81 @@ static bool fold_brcond(OptContext *ctx, TCGOp *op)static bool fold_brcond2 (OptContext *ctx,TCGOp *op) {TCGCond cond = op->args[4 ];TCGArg label = op->args[5 ];int i, inv =0 ;if (swap_commutative2 (&op->args[0 ], &op->args[2 ])) { op->args[4 ] = cond =tcg_swap_cond (cond); } i =do_constant_folding_cond2 (&op->args[0 ], &op->args[2 ], cond);if (i >=0 ) { goto do_brcond_const; }switch (cond) {case TCG_COND_LT :case TCG_COND_GE :/* * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ if (arg_is_const (op->args[2 ]) &&arg_info (op->args[2 ])->val ==0 &&arg_is_const (op->args[3 ]) &&arg_info (op->args[3 ])->val ==0 ) { goto do_brcond_high; }break ;case TCG_COND_NE : inv =1 ; -QEMU_FALLTHROUGH ; + fallthrough;case TCG_COND_EQ :/* * Simplify EQ/NE comparisons where one of the pairs * can be simplified. */ i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[0 ], op->args[2 ], cond);switch (i ^ inv) {case 0 : goto do_brcond_const;case 1 : goto do_brcond_high; } i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[1 ], op->args[3 ], cond);switch (i ^ inv) {case 0 : goto do_brcond_const;case 1 : op->opc = INDEX_op_brcond_i32; op->args[1 ] = op->args[2 ]; op->args[2 ] = cond; op->args[3 ] = label;break ; }break ;default :break ; do_brcond_high: op->opc = INDEX_op_brcond_i32; op->args[0 ] = op->args[1 ]; op->args[1 ] = op->args[3 ]; op->args[2 ] = cond; op->args[3 ] = label;break ; do_brcond_const:if (i ==0 ) {tcg_op_remove (ctx->tcg, op);return true; } op->opc = INDEX_op_br; op->args[0 ] = label;break ; }return false; }@@ -1424,46 +1424,46 @@ static bool fold_extract2(OptContext *ctx, TCGOp *op)static bool fold_exts (OptContext *ctx,TCGOp *op) {uint64_t s_mask_old, s_mask, z_mask, sign;bool type_change = false;if (fold_const1 (ctx, op)) {return true; } z_mask =arg_info (op->args[1 ])->z_mask; s_mask =arg_info (op->args[1 ])->s_mask; s_mask_old = s_mask;switch (op->opc) { CASE_OP_32_64(ext8s): sign =INT8_MIN ; z_mask = (uint8_t )z_mask;break ; CASE_OP_32_64(ext16s): sign =INT16_MIN ; z_mask = (uint16_t )z_mask;break ;case INDEX_op_ext_i32_i64: type_change = true; -QEMU_FALLTHROUGH ; + fallthrough;case INDEX_op_ext32s_i64: sign =INT32_MIN ; z_mask = (uint32_t )z_mask;break ;default :g_assert_not_reached (); }if (z_mask & sign) { z_mask |= sign; } s_mask |= sign <<1 ; ctx->z_mask = z_mask; ctx->s_mask = s_mask;if (!type_change) { ctx->a_mask = s_mask & ~s_mask_old; }return fold_masks (ctx, op); }@@ -1471,40 +1471,40 @@ static bool fold_exts(OptContext *ctx, TCGOp *op)static bool fold_extu (OptContext *ctx,TCGOp *op) {uint64_t z_mask_old, z_mask;bool type_change = false;if (fold_const1 (ctx, op)) {return true; } z_mask_old = z_mask =arg_info (op->args[1 ])->z_mask;switch (op->opc) { CASE_OP_32_64(ext8u): z_mask = (uint8_t )z_mask;break ; CASE_OP_32_64(ext16u): z_mask = (uint16_t )z_mask;break ;case INDEX_op_extrl_i64_i32:case INDEX_op_extu_i32_i64: type_change = true; -QEMU_FALLTHROUGH ; + fallthrough;case INDEX_op_ext32u_i64: z_mask = (uint32_t )z_mask;break ;case INDEX_op_extrh_i64_i32: type_change = true; z_mask >>=32 ;break ;default :g_assert_not_reached (); } ctx->z_mask = z_mask; ctx->s_mask =smask_from_zmask (z_mask);if (!type_change) { ctx->a_mask = z_mask_old ^ z_mask; }return fold_masks (ctx, op); }@@ -1835,75 +1835,75 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op)static bool fold_setcond2 (OptContext *ctx,TCGOp *op) {TCGCond cond = op->args[5 ];int i, inv =0 ;if (swap_commutative2 (&op->args[1 ], &op->args[3 ])) { op->args[5 ] = cond =tcg_swap_cond (cond); } i =do_constant_folding_cond2 (&op->args[1 ], &op->args[3 ], cond);if (i >=0 ) { goto do_setcond_const; }switch (cond) {case TCG_COND_LT :case TCG_COND_GE :/* * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ if (arg_is_const (op->args[3 ]) &&arg_info (op->args[3 ])->val ==0 &&arg_is_const (op->args[4 ]) &&arg_info (op->args[4 ])->val ==0 ) { goto do_setcond_high; }break ;case TCG_COND_NE : inv =1 ; -QEMU_FALLTHROUGH ; + fallthrough;case TCG_COND_EQ :/* * Simplify EQ/NE comparisons where one of the pairs * can be simplified. */ i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[1 ], op->args[3 ], cond);switch (i ^ inv) {case 0 : goto do_setcond_const;case 1 : goto do_setcond_high; } i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[2 ], op->args[4 ], cond);switch (i ^ inv) {case 0 : goto do_setcond_const;case 1 : op->args[2 ] = op->args[3 ]; op->args[3 ] = cond; op->opc = INDEX_op_setcond_i32;break ; }break ;default :break ; do_setcond_high: op->args[1 ] = op->args[2 ]; op->args[2 ] = op->args[4 ]; op->args[3 ] = cond; op->opc = INDEX_op_setcond_i32;break ; } ctx->z_mask =1 ; ctx->s_mask =smask_from_zmask (1 );return false; do_setcond_const:return tcg_opt_gen_movi (ctx, op, op->args[0 ], i); }Signature · 1 line
2.39.2
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [RFC PATCH 01/78] include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough
Quoted 6 lines · Daniel P. Berrangé
This patch (and all the others in the series) have a ridiculously large context either side of the change. It makes this horrible to review as it requires wading through pages of pre-existing code trying to spot the change.
Please send patches with the default git context lines setting.
Many thanks Daniel, I had not noticed at all. Somehow that option slipped through...
Will reroll the patch series.
Re: [RFC PATCH 01/78] include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough
In reply to Emmanouil PitsidianakisThe commit message needs to explain why.
Quoted 39 lines · Emmanouil Pitsidianakis
Signed-off-by Emmanouil Pitsidianakis <[email protected]>--- audio/pwaudio.c | 8 ++++---- hw/arm/smmuv3.c | 2 +- include/qemu/compiler.h | 30 +++++++++++++++++++++++------- include/qemu/osdep.h | 4 ++-- target/loongarch/cpu.c | 4 ++-- target/loongarch/translate.c | 2 +- tcg/optimize.c | 8 ++++---- 7 files changed, 37 insertions(+), 21 deletions(-)audio/pwaudio.c +4
-3@@ -1,29 +1,29 @@/* * QEMU PipeWire audio driver * * Copyright (c) 2023 Red Hat Inc. * * Author: Dorinda Bassey <[email protected]> * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include <spa/param/audio/format-utils.h> +#include <spa/utils/ringbuffer.h> +#include <spa/utils/result.h> +#include <spa/param/props.h> #include "qemu/osdep.h" #include "qemu/module.h" #include "audio.h" #include <errno.h> #include "qemu/error-report.h" #include "qapi/error.h" -#include <spa/param/audio/format-utils.h> -#include <spa/utils/ringbuffer.h> -#include <spa/utils/result.h>
audio/pwaudio.c line 29
Quoted 10 lines
audio/pwaudio.c +0
-1-#include <spa/param/props.h> #include <pipewire/pipewire.h> #include "trace.h" #define AUDIO_CAP "pipewire"#define RINGBUFFER_SIZE (1u << 22)#define RINGBUFFER_MASK (RINGBUFFER_SIZE - 1)#include "audio_int.h"
This is wrong. docs/devel/style.rst:
Include directives
------------------
Order include directives as follows:
.. code-block:: c
#include "qemu/osdep.h" /* Always first... */
#include <...> /* then system headers... */
#include "..." /* and finally QEMU headers. */Separate patch, please.
[...]
Quoted 5 lines
include/qemu/compiler.h +0
-0@@ -1,215 +1,231 @@
[...]
include/qemu/compiler.h line 169
Quoted 9 lines
#define
QEMU_ALWAYS_INLINE
#endifinclude/qemu/compiler.h +2
-4-/** -* In most cases, normal "fallthrough" comments are good enough for -* switch-case statements, but sometimes the compiler has problems -* with those. In that case you can use QEMU_FALLTHROUGH instead. +/* +* Add the pseudo keyword 'fallthrough' so case statement blocks
Pseudo-keyword? It's a macro.
Quoted 6 lines
+ * must end with any of these keywords:
+ * break; + * fallthrough; + * continue; + * goto <label>; + * return [expression];
These are statements, not keywords.
Quoted 2 lines
+ *
+ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
Not sure we need to point to the docs here. We have hundreds of __attribute__ uses in the tree.
include/qemu/compiler.h line 187
Quoted 12 lines
*/
include/qemu/compiler.h +9
-2-#if __has_attribute (fallthrough) -# define QEMU_FALLTHROUGH __attribute__((fallthrough)) + +/* +* glib_macros.h contains its own definition of fallthrough, so if we define +* the pseudokeyword here it will expand when the glib header checks for the +* attribute. glib headers must be #included after this header. +*/ +#ifdef fallthrough +#undef fallthrough +#endif
Why do we need to roll our own macro then?
Quoted 10 lines
include/qemu/compiler.h +4
-1+ +#if __has_attribute (__fallthrough__) +# define fallthrough __attribute__((__fallthrough__))#else -# define QEMU_FALLTHROUGH do {} while (0)/* fallthrough */ +# define fallthrough do {} while (0)/* fallthrough */ #endif #ifdef CONFIG_CFI /*
[...]
Quoted 614 lines
include/qemu/osdep.h +2
-2@@ -1,171 +1,171 @@/* * OS includes and handling of OS dependencies * * This header exists to pull in some common system headers that * most code in QEMU will want, and to fix up some possible issues with * it (missing defines, Windows weirdness, and so on). * * To avoid getting into possible circular include dependencies, this * file should not include any other QEMU headers, with the exceptions * of config-host.h, config-target.h, qemu/compiler.h, * sysemu/os-posix.h, sysemu/os-win32.h, glib-compat.h and * qemu/typedefs.h, all of which are doing a similar job to this file * and are under similar constraints. * * This header also contains prototypes for functions defined in * os-*.c and util/oslib-*.c; those would probably be better split * out into separate header files. * * In an ideal world this header would contain only: * (1) things which everybody needs * (2) things without which code would work on most platforms but * fail to compile or misbehave on a minority of host OSes * * This work is licensed under the terms of the GNU GPL, version 2 or later. * See the COPYING file in the top-level directory. */ #ifndef QEMU_OSDEP_H #define QEMU_OSDEP_H #if !defined _FORTIFY_SOURCE && defined __OPTIMIZE__ && __OPTIMIZE__ && defined __linux__# define _FORTIFY_SOURCE 2#endif #include "config-host.h" #ifdef NEED_CPU_H #include CONFIG_TARGET #else #include "exec/poison.h" #endif /* * HOST_WORDS_BIGENDIAN was replaced with HOST_BIG_ENDIAN. Prevent it from * creeping back in. */ #pragma GCC poison HOST_WORDS_BIGENDIAN/* * TARGET_WORDS_BIGENDIAN was replaced with TARGET_BIG_ENDIAN. Prevent it from * creeping back in. */ #pragma GCC poison TARGET_WORDS_BIGENDIAN -#include "qemu/compiler.h" -/* Older versions of C++ don't get definitions of various macros from * stdlib.h unless we define these macros before first inclusion of * that system header. */ #ifndef __STDC_CONSTANT_MACROS#define __STDC_CONSTANT_MACROS#endif #ifndef __STDC_LIMIT_MACROS#define __STDC_LIMIT_MACROS#endif #ifndef __STDC_FORMAT_MACROS#define __STDC_FORMAT_MACROS#endif /* The following block of code temporarily renames the daemon() function so the * compiler does not see the warning associated with it in stdlib.h on OSX */ #ifdef __APPLE__#define daemon qemu_fake_daemon_function#include <stdlib.h> #undef daemon QEMU_EXTERN_C int daemon(int, int);#endif #ifdef _WIN32/* as defined in sdkddkver.h */ #ifndef _WIN32_WINNT#define _WIN32_WINNT 0x0602/* Windows 8 API (should be >= the one from glib) */ #endif /* reduces the number of implicitly included headers */ #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #endif /* enable C99/POSIX format strings (needs mingw32-runtime 3.15 or later) */ #ifdef __MINGW32__#define __USE_MINGW_ANSI_STDIO 1#endif /* * We need the FreeBSD "legacy" definitions. Rust needs the FreeBSD 11 system * calls since it doesn't use libc at all, so we have to emulate that despite * FreeBSD 11 being EOL'd. */ #ifdef __FreeBSD__#define _WANT_FREEBSD11_STAT#define _WANT_FREEBSD11_STATFS#define _WANT_FREEBSD11_DIRENT#define _WANT_KERNEL_ERRNO#define _WANT_SEMUN#endif #include <stdarg.h> #include <stddef.h> #include <stdbool.h> #include <stdint.h> #include <sys/types.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <strings.h> #include <inttypes.h> #include <limits.h> /* Put unistd.h before time.h as that triggers localtime_r/gmtime_r * function availability on recentish Mingw-w64 platforms. */ #include <unistd.h> #include <time.h> #include <ctype.h> #include <errno.h> #include <fcntl.h> #include <getopt.h> #include <sys/stat.h> #include <sys/time.h> #include <assert.h> /* setjmp must be declared before sysemu/os-win32.h * because it is redefined there. */ #include <setjmp.h> #include <signal.h> #ifdef CONFIG_IOVEC #include <sys/uio.h> #endif #if defined(__linux__) && defined(__sparc__)/* The SPARC definition of QEMU_VMALLOC_ALIGN needs SHMLBA */ #include <sys/shm.h> #endif #ifndef _WIN32#include <sys/wait.h> #else #define WIFEXITED (x) 1#define WEXITSTATUS (x) (x)#endif #ifdef __APPLE__#include <AvailabilityMacros.h> #endif /* * This is somewhat like a system header; it must be outside any extern "C" * block because it includes system headers itself, including glib.h, * which will not compile if inside an extern "C" block. */ #include "glib-compat.h" +#include "qemu/compiler.h" +#ifdef _WIN32#include "sysemu/os-win32.h" #endif #ifdef CONFIG_POSIX #include "sysemu/os-posix.h" #endif #ifdef __cplusplustarget/loongarch/cpu.c +2
-2@@ -142,145 +142,145 @@ static inline bool cpu_loongarch_hw_interrupts_pending(CPULoongArchState *env)static void loongarch_cpu_do_interrupt (CPUState *cs) {LoongArchCPU *cpu =LOONGARCH_CPU (cs);CPULoongArchState *env = &cpu->env;bool update_badinstr =1 ;int cause =-1 ;const char *name;bool tlbfill =FIELD_EX64 (env->CSR_TLBRERA,CSR_TLBRERA ,ISTLBR );uint32_t vec_size =FIELD_EX64 (env->CSR_ECFG,CSR_ECFG ,VS );if (cs->exception_index !=EXCCODE_INT ) {if (cs->exception_index <0 || cs->exception_index >=ARRAY_SIZE (excp_names)) { name ="unknown" ; }else { name = excp_names[cs->exception_index]; }qemu_log_mask (CPU_LOG_INT ,"%s enter: pc " TARGET_FMT_lx" ERA " TARGET_FMT_lx" TLBRERA " TARGET_FMT_lx" %s exception\n" , __func__, env->pc, env->CSR_ERA, env->CSR_TLBRERA, name); }switch (cs->exception_index) {case EXCCODE_DBP : env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,DCL ,1 ); env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,ECODE ,0xC ); goto set_DERA; set_DERA: env->CSR_DERA = env->pc; env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,DST ,1 );set_pc (env, env->CSR_EENTRY +0x480 );break ;case EXCCODE_INT :if (FIELD_EX64 (env->CSR_DBG,CSR_DBG ,DST )) { env->CSR_DBG =FIELD_DP64 (env->CSR_DBG,CSR_DBG ,DEI ,1 ); goto set_DERA; } -QEMU_FALLTHROUGH ; + fallthrough;case EXCCODE_PIF :case EXCCODE_ADEF : cause = cs->exception_index; update_badinstr =0 ;break ;case EXCCODE_SYS :case EXCCODE_BRK :case EXCCODE_INE :case EXCCODE_IPE :case EXCCODE_FPD :case EXCCODE_FPE :case EXCCODE_SXD :case EXCCODE_ASXD : env->CSR_BADV = env->pc; -QEMU_FALLTHROUGH ; + fallthrough;case EXCCODE_BCE :case EXCCODE_ADEM :case EXCCODE_PIL :case EXCCODE_PIS :case EXCCODE_PME :case EXCCODE_PNR :case EXCCODE_PNX :case EXCCODE_PPI : cause = cs->exception_index;break ;default :qemu_log ("Error: exception(%d) has not been supported\n" , cs->exception_index);abort (); }if (update_badinstr) { env->CSR_BADI =cpu_ldl_code (env, env->pc); }/* Save PLV and IE */ if (tlbfill) { env->CSR_TLBRPRMD =FIELD_DP64 (env->CSR_TLBRPRMD,CSR_TLBRPRMD ,PPLV ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,PLV )); env->CSR_TLBRPRMD =FIELD_DP64 (env->CSR_TLBRPRMD,CSR_TLBRPRMD ,PIE ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,IE ));/* set the DA mode */ env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,DA ,1 ); env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,PG ,0 ); env->CSR_TLBRERA =FIELD_DP64 (env->CSR_TLBRERA,CSR_TLBRERA ,PC , (env->pc >>2 )); }else { env->CSR_ESTAT =FIELD_DP64 (env->CSR_ESTAT,CSR_ESTAT ,ECODE ,EXCODE_MCODE (cause)); env->CSR_ESTAT =FIELD_DP64 (env->CSR_ESTAT,CSR_ESTAT ,ESUBCODE ,EXCODE_SUBCODE (cause)); env->CSR_PRMD =FIELD_DP64 (env->CSR_PRMD,CSR_PRMD ,PPLV ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,PLV )); env->CSR_PRMD =FIELD_DP64 (env->CSR_PRMD,CSR_PRMD ,PIE ,FIELD_EX64 (env->CSR_CRMD,CSR_CRMD ,IE )); env->CSR_ERA = env->pc; } env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,PLV ,0 ); env->CSR_CRMD =FIELD_DP64 (env->CSR_CRMD,CSR_CRMD ,IE ,0 );if (vec_size) { vec_size = (1 << vec_size) *4 ; }if (cs->exception_index ==EXCCODE_INT ) {/* Interrupt */ uint32_t vector =0 ;uint32_t pending =FIELD_EX64 (env->CSR_ESTAT,CSR_ESTAT ,IS ); pending &=FIELD_EX64 (env->CSR_ECFG,CSR_ECFG ,LIE );/* Find the highest-priority interrupt. */ vector =31 -clz32 (pending);set_pc (env, env->CSR_EENTRY + \ (EXCCODE_EXTERNAL_INT + vector) * vec_size);qemu_log_mask (CPU_LOG_INT ,"%s: PC " TARGET_FMT_lx" ERA " TARGET_FMT_lx" cause %d\n" " A " TARGET_FMT_lx" D " TARGET_FMT_lx" vector = %d ExC " TARGET_FMT_lx"ExS" TARGET_FMT_lx"\n" , __func__, env->pc, env->CSR_ERA, cause, env->CSR_BADV, env->CSR_DERA, vector, env->CSR_ECFG, env->CSR_ESTAT); }else {if (tlbfill) {set_pc (env, env->CSR_TLBRENTRY); }else {set_pc (env, env->CSR_EENTRY +EXCODE_MCODE (cause) * vec_size); }qemu_log_mask (CPU_LOG_INT ,"%s: PC " TARGET_FMT_lx" ERA " TARGET_FMT_lx" cause %d%s\n, ESTAT " TARGET_FMT_lx" EXCFG " TARGET_FMT_lx" BADVA " TARGET_FMT_lx"BADI " TARGET_FMT_lx" SYS_NUM " TARGET_FMT_lu" cpu %d asid " TARGET_FMT_lx"\n" , __func__, env->pc, tlbfill ? env->CSR_TLBRERA : env->CSR_ERA, cause, tlbfill ?"(refill)" :"" , env->CSR_ESTAT, env->CSR_ECFG, tlbfill ? env->CSR_TLBRBADV : env->CSR_BADV, env->CSR_BADI, env->gpr[11 ], cs->cpu_index, env->CSR_ASID); } cs->exception_index =-1 ; }target/loongarch/translate.c +1
-1@@ -304,24 +304,24 @@ static void loongarch_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)static void loongarch_tr_tb_stop (DisasContextBase *dcbase,CPUState *cs) {DisasContext *ctx =container_of (dcbase, DisasContext, base);switch (ctx->base.is_jmp) {case DISAS_STOP :tcg_gen_movi_tl (cpu_pc, ctx->base.pc_next);tcg_gen_lookup_and_goto_ptr ();break ;case DISAS_TOO_MANY :gen_goto_tb (ctx,0 , ctx->base.pc_next);break ;case DISAS_NORETURN :break ;case DISAS_EXIT_UPDATE :tcg_gen_movi_tl (cpu_pc, ctx->base.pc_next); -QEMU_FALLTHROUGH ; + fallthrough;case DISAS_EXIT :tcg_gen_exit_tb (NULL ,0 );break ;default :g_assert_not_reached (); } }tcg/optimize.c +4
-4@@ -1062,81 +1062,81 @@ static bool fold_brcond(OptContext *ctx, TCGOp *op)static bool fold_brcond2 (OptContext *ctx,TCGOp *op) {TCGCond cond = op->args[4 ];TCGArg label = op->args[5 ];int i, inv =0 ;if (swap_commutative2 (&op->args[0 ], &op->args[2 ])) { op->args[4 ] = cond =tcg_swap_cond (cond); } i =do_constant_folding_cond2 (&op->args[0 ], &op->args[2 ], cond);if (i >=0 ) { goto do_brcond_const; }switch (cond) {case TCG_COND_LT :case TCG_COND_GE :/* * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ if (arg_is_const (op->args[2 ]) &&arg_info (op->args[2 ])->val ==0 &&arg_is_const (op->args[3 ]) &&arg_info (op->args[3 ])->val ==0 ) { goto do_brcond_high; }break ;case TCG_COND_NE : inv =1 ; -QEMU_FALLTHROUGH ; + fallthrough;case TCG_COND_EQ :/* * Simplify EQ/NE comparisons where one of the pairs * can be simplified. */ i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[0 ], op->args[2 ], cond);switch (i ^ inv) {case 0 : goto do_brcond_const;case 1 : goto do_brcond_high; } i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[1 ], op->args[3 ], cond);switch (i ^ inv) {case 0 : goto do_brcond_const;case 1 : op->opc = INDEX_op_brcond_i32; op->args[1 ] = op->args[2 ]; op->args[2 ] = cond; op->args[3 ] = label;break ; }break ;default :break ; do_brcond_high: op->opc = INDEX_op_brcond_i32; op->args[0 ] = op->args[1 ]; op->args[1 ] = op->args[3 ]; op->args[2 ] = cond; op->args[3 ] = label;break ; do_brcond_const:if (i ==0 ) {tcg_op_remove (ctx->tcg, op);return true; } op->opc = INDEX_op_br; op->args[0 ] = label;break ; }return false; }@@ -1424,46 +1424,46 @@ static bool fold_extract2(OptContext *ctx, TCGOp *op)static bool fold_exts (OptContext *ctx,TCGOp *op) {uint64_t s_mask_old, s_mask, z_mask, sign;bool type_change = false;if (fold_const1 (ctx, op)) {return true; } z_mask =arg_info (op->args[1 ])->z_mask; s_mask =arg_info (op->args[1 ])->s_mask; s_mask_old = s_mask;switch (op->opc) { CASE_OP_32_64(ext8s): sign =INT8_MIN ; z_mask = (uint8_t )z_mask;break ; CASE_OP_32_64(ext16s): sign =INT16_MIN ; z_mask = (uint16_t )z_mask;break ;case INDEX_op_ext_i32_i64: type_change = true; -QEMU_FALLTHROUGH ; + fallthrough;case INDEX_op_ext32s_i64: sign =INT32_MIN ; z_mask = (uint32_t )z_mask;break ;default :g_assert_not_reached (); }if (z_mask & sign) { z_mask |= sign; } s_mask |= sign <<1 ; ctx->z_mask = z_mask; ctx->s_mask = s_mask;if (!type_change) { ctx->a_mask = s_mask & ~s_mask_old; }return fold_masks (ctx, op); }@@ -1471,40 +1471,40 @@ static bool fold_exts(OptContext *ctx, TCGOp *op)static bool fold_extu (OptContext *ctx,TCGOp *op) {uint64_t z_mask_old, z_mask;bool type_change = false;if (fold_const1 (ctx, op)) {return true; } z_mask_old = z_mask =arg_info (op->args[1 ])->z_mask;switch (op->opc) { CASE_OP_32_64(ext8u): z_mask = (uint8_t )z_mask;break ; CASE_OP_32_64(ext16u): z_mask = (uint16_t )z_mask;break ;case INDEX_op_extrl_i64_i32:case INDEX_op_extu_i32_i64: type_change = true; -QEMU_FALLTHROUGH ; + fallthrough;case INDEX_op_ext32u_i64: z_mask = (uint32_t )z_mask;break ;case INDEX_op_extrh_i64_i32: type_change = true; z_mask >>=32 ;break ;default :g_assert_not_reached (); } ctx->z_mask = z_mask; ctx->s_mask =smask_from_zmask (z_mask);if (!type_change) { ctx->a_mask = z_mask_old ^ z_mask; }return fold_masks (ctx, op); }@@ -1835,75 +1835,75 @@ static bool fold_negsetcond(OptContext *ctx, TCGOp *op)static bool fold_setcond2 (OptContext *ctx,TCGOp *op) {TCGCond cond = op->args[5 ];int i, inv =0 ;if (swap_commutative2 (&op->args[1 ], &op->args[3 ])) { op->args[5 ] = cond =tcg_swap_cond (cond); } i =do_constant_folding_cond2 (&op->args[1 ], &op->args[3 ], cond);if (i >=0 ) { goto do_setcond_const; }switch (cond) {case TCG_COND_LT :case TCG_COND_GE :/* * Simplify LT/GE comparisons vs zero to a single compare * vs the high word of the input. */ if (arg_is_const (op->args[3 ]) &&arg_info (op->args[3 ])->val ==0 &&arg_is_const (op->args[4 ]) &&arg_info (op->args[4 ])->val ==0 ) { goto do_setcond_high; }break ;case TCG_COND_NE : inv =1 ; -QEMU_FALLTHROUGH ; + fallthrough;case TCG_COND_EQ :/* * Simplify EQ/NE comparisons where one of the pairs * can be simplified. */ i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[1 ], op->args[3 ], cond);switch (i ^ inv) {case 0 : goto do_setcond_const;case 1 : goto do_setcond_high; } i =do_constant_folding_cond (TCG_TYPE_I32 , op->args[2 ], op->args[4 ], cond);switch (i ^ inv) {case 0 : goto do_setcond_const;case 1 : op->args[2 ] = op->args[3 ]; op->args[3 ] = cond; op->opc = INDEX_op_setcond_i32;break ; }break ;default :break ; do_setcond_high: op->args[1 ] = op->args[2 ]; op->args[2 ] = op->args[4 ]; op->args[3 ] = cond; op->opc = INDEX_op_setcond_i32;break ; } ctx->z_mask =1 ; ctx->s_mask =smask_from_zmask (1 );return false; do_setcond_const:return tcg_opt_gen_movi (ctx, op, op->args[0 ], i); }
Re: [RFC PATCH 01/78] include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough
Hello Markus,
Quoted 1 line · Markus Armbruster
The commit message needs to explain why.
Certainly.
Quoted 13 lines
This is wrong.
docs/devel/style.rst:Include directives ------------------ Order include directives as follows: .. code-block:: c #include "qemu/osdep.h" /* Always first... */ #include <...> /* then system headers... */ #include "..." /* and finally QEMU headers. */
Quoted 1 line
Separate patch, please.
I know. spa headers use the fallthrough attribute and qemu/compiler.h defines it as a macro, so it breaks compilation. If the spa headers go after, we'd need to undef fallthrough before including them and re-define or re-include qemu/compiler.h after. What do you think would be best?
Quoted 12 lines
Quoted 6 lines
include/qemu/compiler.h +0
-0@@ -1,215 +1,231 @@[...]
Quoted 3 lines
#define
QEMU_ALWAYS_INLINE
#endif
Quoted 8 lines
include/qemu/compiler.h line 169
Quoted 6 lines
include/qemu/compiler.h +2
-4-/** -* In most cases, normal "fallthrough" comments are good enough for -* switch-case statements, but sometimes the compiler has problems -* with those. In that case you can use QEMU_FALLTHROUGH instead. +/* +* Add the pseudo keyword 'fallthrough' so case statement blocks Pseudo-keyword? It's a macro.
C calls reserved words that you cannot redefine 'keywords'. Like 'break', 'continue', 'return'. Hence it's a pseudo-keyword. It's also a macro. They are not mutually exclusive.
I did not write this, it was taken verbatim from the linux kernel source, see: /include/linux/compiler_attributes.h
Quoted 9 lines
Quoted 7 lines
+ * must end with any of these keywords:
+ * break; + * fallthrough; + * continue; + * goto <label>; + * return [expression];These are statements, not keywords.
I'm pretty sure it refers to {break, fallthrough, continue, goto, return} by themselves.
Quoted 6 lines
Quoted 3 lines
+ *
+ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-AttributesNot sure we need to point to the docs here. We have hundreds of
__attribute__uses in the tree.
Again, copied from /include/linux/compiler_attributes.h
Quoted 15 lines
include/qemu/compiler.h line 187
Quoted 13 lines
*/
include/qemu/compiler.h +9
-2-#if __has_attribute (fallthrough) -# define QEMU_FALLTHROUGH __attribute__((fallthrough)) + +/* +* glib_macros.h contains its own definition of fallthrough, so if we define +* the pseudokeyword here it will expand when the glib header checks for the +* attribute. glib headers must be #included after this header. +*/ +#ifdef fallthrough +#undef fallthrough +#endif Why do we need to roll our own macro then?
Glib uses a different name. The problem is when it checks for the compiler attribute, which expands into our macro.
--
Manos
RFC PATCH 2/78 block: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- block/block-copy.c | 1 + block/file-posix.c | 1 + block/io.c | 1 + block/iscsi.c | 1 + block/qcow2-cluster.c | 5 ++++- block/vhdx.c | 17 +++++++++++++---- 6 files changed, 21 insertions(+), 5 deletions(-)
block/block-copy.c +1 -0
@@ -473,78 +473,79 @@ static int coroutine_fn GRAPH_RDLOCK block_copy_do_copy(BlockCopyState *s, int64_t offset, int64_t bytes, BlockCopyMethod *method, bool *error_is_read) {int ret;int64_t nbytes =MIN (offset + bytes, s->len) - offset;void *bounce_buffer =NULL ;assert (offset >=0 && bytes >0 &&INT64_MAX - offset >= bytes);assert (QEMU_IS_ALIGNED (offset, s->cluster_size));assert (QEMU_IS_ALIGNED (bytes, s->cluster_size));assert (offset < s->len);assert (offset + bytes <= s->len || offset + bytes ==QEMU_ALIGN_UP (s->len, s->cluster_size));assert (nbytes <INT_MAX );switch (*method) {case COPY_WRITE_ZEROES : ret =bdrv_co_pwrite_zeroes (s->target, offset, nbytes, s->write_flags & ~BDRV_REQ_WRITE_COMPRESSED );if (ret <0 ) {trace_block_copy_write_zeroes_fail (s, offset, ret); *error_is_read = false; }return ret;case COPY_RANGE_SMALL :case COPY_RANGE_FULL : ret =bdrv_co_copy_range (s->source, offset, s->target, offset, nbytes,0 , s->write_flags);if (ret >=0 ) {/* Successful copy-range, increase chunk size. */ *method =COPY_RANGE_FULL ;return 0 ; }trace_block_copy_copy_range_fail (s, offset, ret); *method =COPY_READ_WRITE ;/* Fall through to read+write with allocated buffer */ + fallthrough;case COPY_READ_WRITE_CLUSTER :case COPY_READ_WRITE :/* * In case of failed copy_range request above, we may proceed with * buffered request larger than BLOCK_COPY_MAX_BUFFER. * Still, further requests will be properly limited, so don't care too * much. Moreover the most likely case (copy_range is unsupported for * the configuration, so the very first copy_range request fails) * is handled by setting large copy_size only after first successful * copy_range. */ bounce_buffer =qemu_blockalign (s->source->bs, nbytes); ret =bdrv_co_pread (s->source, offset, nbytes, bounce_buffer,0 );if (ret <0 ) {trace_block_copy_read_fail (s, offset, ret); *error_is_read = true; goto out; } ret =bdrv_co_pwrite (s->target, offset, nbytes, bounce_buffer, s->write_flags);if (ret <0 ) {trace_block_copy_write_fail (s, offset, ret); *error_is_read = false; goto out; } out:qemu_vfree (bounce_buffer);break ;default :abort (); }return ret; }
block/file-posix.c +1 -0
@@ -972,69 +972,70 @@ static int raw_check_lock_bytes(int fd, uint64_t perm, uint64_t shared_perm,static int raw_handle_perm_lock (BlockDriverState *bs,RawPermLockOp op,uint64_t new_perm,uint64_t new_shared,Error **errp) {BDRVRawState *s = bs->opaque;int ret =0 ;Error *local_err =NULL ;if (!s->use_lock) {return 0 ; }if (bdrv_get_flags (bs) &BDRV_O_INACTIVE ) {return 0 ; }switch (op) {case RAW_PL_PREPARE :if ((s->perm | new_perm) == s->perm && (s->shared_perm & new_shared) == s->shared_perm) {/* * We are going to unlock bytes, it should not fail. If it fail due * to some fs-dependent permission-unrelated reasons (which occurs * sometimes on NFS and leads to abort in bdrv_replace_child) we * can't prevent such errors by any check here. And we ignore them * anyway in ABORT and COMMIT. */ return 0 ; } ret =raw_apply_lock_bytes (s, s->fd, s->perm | new_perm, ~s->shared_perm | ~new_shared, false, errp);if (!ret) { ret =raw_check_lock_bytes (s->fd, new_perm, new_shared, errp);if (!ret) {return 0 ; }error_append_hint (errp,"Is another process using the image [%s]?\n" , bs->filename); }/* fall through to unlock bytes. */ + fallthrough;case RAW_PL_ABORT :raw_apply_lock_bytes (s, s->fd, s->perm, ~s->shared_perm, true, &local_err);if (local_err) {/* Theoretically the above call only unlocks bytes and it cannot * fail. Something weird happened, report it. */ warn_report_err (local_err); }break ;case RAW_PL_COMMIT :raw_apply_lock_bytes (s, s->fd, new_perm, ~new_shared, true, &local_err);if (local_err) {/* Theoretically the above call only unlocks bytes and it cannot * fail. Something weird happened, report it. */ warn_report_err (local_err); }break ; }return ret; }/* Sets a specific flag */
block/io.c +1 -0
@@ -2007,43 +2007,44 @@ static inline void coroutine_fn bdrv_co_write_req_finish(BdrvChild *child, int64_t offset, int64_t bytes, BdrvTrackedRequest *req, int ret) {int64_t end_sector =DIV_ROUND_UP (offset + bytes,BDRV_SECTOR_SIZE );BlockDriverState *bs = child->bs;bdrv_check_request (offset, bytes, &error_abort);qatomic_inc (&bs->write_gen);/* * Discard cannot extend the image, but in error handling cases, such as * when reverting a qcow2 cluster allocation, the discarded range can pass * the end of image file, so we cannot assert about BDRV_TRACKED_DISCARD * here. Instead, just skip it, since semantically a discard request * beyond EOF cannot expand the image anyway. */ if (ret ==0 && (req->type ==BDRV_TRACKED_TRUNCATE || end_sector > bs->total_sectors) && req->type !=BDRV_TRACKED_DISCARD ) { bs->total_sectors = end_sector;bdrv_parent_cb_resize (bs);bdrv_dirty_bitmap_truncate (bs, end_sector <<BDRV_SECTOR_BITS ); }if (req->bytes) {switch (req->type) {case BDRV_TRACKED_WRITE :stat64_max (&bs->wr_highest_offset, offset + bytes);/* fall through, to set dirty bits */ + fallthrough;case BDRV_TRACKED_DISCARD :bdrv_set_dirty (bs, offset, bytes);break ;default :break ; } } }/* * Forwards an already correctly aligned write request to the BlockDriver, * after possibly fragmenting it. */
block/iscsi.c +1 -0
@@ -1430,69 +1430,70 @@ static void iscsi_nop_timed_event(void *opaque)static void iscsi_readcapacity_sync (IscsiLun *iscsilun,Error **errp) {struct scsi_task *task =NULL ;struct scsi_readcapacity10 *rc10 =NULL ;struct scsi_readcapacity16 *rc16 =NULL ;int retries =ISCSI_CMD_RETRIES ;do {if (task !=NULL ) {scsi_free_scsi_task (task); task =NULL ; }switch (iscsilun->type) {case TYPE_DISK : task =iscsi_readcapacity16_sync (iscsilun->iscsi, iscsilun->lun);if (task !=NULL && task->status ==SCSI_STATUS_GOOD ) { rc16 =scsi_datain_unmarshall (task);if (rc16 ==NULL ) {error_setg (errp,"iSCSI: Failed to unmarshall readcapacity16 data." ); }else { iscsilun->block_size = rc16->block_length; iscsilun->num_blocks = rc16->returned_lba +1 ; iscsilun->lbpme = !!rc16->lbpme; iscsilun->lbprz = !!rc16->lbprz; iscsilun->use_16_for_rw = (rc16->returned_lba >0xffffffff ); }break ; }if (task !=NULL && task->status ==SCSI_STATUS_CHECK_CONDITION && task->sense.key ==SCSI_SENSE_UNIT_ATTENTION ) {break ; }/* Fall through and try READ CAPACITY(10) instead. */ + fallthrough;case TYPE_ROM : task =iscsi_readcapacity10_sync (iscsilun->iscsi, iscsilun->lun,0 ,0 );if (task !=NULL && task->status ==SCSI_STATUS_GOOD ) { rc10 =scsi_datain_unmarshall (task);if (rc10 ==NULL ) {error_setg (errp,"iSCSI: Failed to unmarshall readcapacity10 data." ); }else { iscsilun->block_size = rc10->block_size;if (rc10->lba ==0 ) {/* blank disk loaded */ iscsilun->num_blocks =0 ; }else { iscsilun->num_blocks = rc10->lba +1 ; } } }break ;default :return ; } }while (task !=NULL && task->status ==SCSI_STATUS_CHECK_CONDITION && task->sense.key ==SCSI_SENSE_UNIT_ATTENTION && retries-- >0 );if (task ==NULL || task->status !=SCSI_STATUS_GOOD ) {error_setg (errp,"iSCSI: failed to send readcapacity10/16 command" ); }else if (!iscsilun->block_size || iscsilun->block_size %BDRV_SECTOR_SIZE ) {error_setg (errp,"iSCSI: the target returned an invalid " "block size of %d." , iscsilun->block_size); }if (task) {scsi_free_scsi_task (task); } }
block/qcow2-cluster.c +4 -1
@@ -1327,36 +1327,39 @@ static int coroutine_fn calculate_l2_meta(BlockDriverState *bs,/* * Returns true if writing to the cluster pointed to by @l2_entry * requires a new allocation (that is, if the cluster is unallocated * or has refcount > 1 and therefore cannot be written in-place). */ static bool cluster_needs_new_alloc (BlockDriverState *bs,uint64_t l2_entry) {switch (qcow2_get_cluster_type (bs, l2_entry)) {case QCOW2_CLUSTER_NORMAL : + fallthrough;case QCOW2_CLUSTER_ZERO_ALLOC :if (l2_entry &QCOW_OFLAG_COPIED ) {return false; } -/* fallthrough */ + fallthrough;case QCOW2_CLUSTER_UNALLOCATED : + fallthrough;case QCOW2_CLUSTER_COMPRESSED : + fallthrough;case QCOW2_CLUSTER_ZERO_PLAIN :return true;default :abort (); } }/* * Returns the number of contiguous clusters that can be written to * using one single write request, starting from @l2_index. * At most @nb_clusters are checked. * * If @new_alloc is true this counts clusters that are either * unallocated, or allocated but with refcount > 1 (so they need to be * newly allocated and COWed). * * If @new_alloc is false this counts clusters that are already * allocated and can be overwritten in-place (this includes clusters * of type QCOW2_CLUSTER_ZERO_ALLOC). */
block/vhdx.c +13 -4
@@ -1176,60 +1176,65 @@ static int coroutine_fn GRAPH_RDLOCK vhdx_co_readv(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) {BDRVVHDXState *s = bs->opaque;int ret =0 ;VHDXSectorInfo sinfo;uint64_t bytes_done =0 ;QEMUIOVector hd_qiov;qemu_iovec_init (&hd_qiov, qiov->niov);qemu_co_mutex_lock (&s->lock);while (nb_sectors >0 ) {/* We are a differencing file, so we need to inspect the sector bitmap * to see if we have the data or not */ if (s->params.data_bits &VHDX_PARAMS_HAS_PARENT ) {/* not supported yet */ ret = -ENOTSUP ; goto exit; }else {vhdx_block_translate (s, sector_num, nb_sectors, &sinfo);qemu_iovec_reset (&hd_qiov);qemu_iovec_concat (&hd_qiov, qiov, bytes_done, sinfo.bytes_avail);/* check the payload block state */ switch (s->bat[sinfo.bat_idx] &VHDX_BAT_STATE_BIT_MASK ) { -case PAYLOAD_BLOCK_NOT_PRESENT :/* fall through */ +case PAYLOAD_BLOCK_NOT_PRESENT : + fallthrough;case PAYLOAD_BLOCK_UNDEFINED : + fallthrough;case PAYLOAD_BLOCK_UNMAPPED : + fallthrough;case PAYLOAD_BLOCK_UNMAPPED_v095: + fallthrough;case PAYLOAD_BLOCK_ZERO :/* return zero */ qemu_iovec_memset (&hd_qiov,0 ,0 , sinfo.bytes_avail);break ;case PAYLOAD_BLOCK_FULLY_PRESENT :qemu_co_mutex_unlock (&s->lock); ret =bdrv_co_preadv (bs->file, sinfo.file_offset, sinfo.sectors_avail *BDRV_SECTOR_SIZE , &hd_qiov,0 );qemu_co_mutex_lock (&s->lock);if (ret <0 ) { goto exit; }break ;case PAYLOAD_BLOCK_PARTIALLY_PRESENT :/* we don't yet support difference files, fall through * to error */ + fallthrough;default : ret = -EIO ; goto exit;break ; } nb_sectors -= sinfo.sectors_avail; sector_num += sinfo.sectors_avail; bytes_done += sinfo.bytes_avail; } } ret =0 ;
@@ -1330,155 +1335,159 @@ static int coroutine_fn GRAPH_RDLOCK vhdx_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int flags) {int ret = -ENOTSUP ;BDRVVHDXState *s = bs->opaque;VHDXSectorInfo sinfo;uint64_t bytes_done =0 ;uint64_t bat_entry =0 ;uint64_t bat_entry_offset =0 ;QEMUIOVector hd_qiov;struct iovec iov1 = {0 };struct iovec iov2 = {0 };int sectors_to_write;int bat_state;uint64_t bat_prior_offset =0 ;bool bat_update = false;qemu_iovec_init (&hd_qiov, qiov->niov);qemu_co_mutex_lock (&s->lock); ret =vhdx_user_visible_write (bs, s);if (ret <0 ) { goto exit; }while (nb_sectors >0 ) {bool use_zero_buffers = false; bat_update = false;if (s->params.data_bits &VHDX_PARAMS_HAS_PARENT ) {/* not supported yet */ ret = -ENOTSUP ; goto exit; }else {vhdx_block_translate (s, sector_num, nb_sectors, &sinfo); sectors_to_write = sinfo.sectors_avail;qemu_iovec_reset (&hd_qiov);/* check the payload block state */ bat_state = s->bat[sinfo.bat_idx] &VHDX_BAT_STATE_BIT_MASK ;switch (bat_state) {case PAYLOAD_BLOCK_ZERO :/* in this case, we need to preserve zero writes for * data that is not part of this write, so we must pad * the rest of the buffer to zeroes */ use_zero_buffers = true; -/* fall through */ -case PAYLOAD_BLOCK_NOT_PRESENT :/* fall through */ + fallthrough; +case PAYLOAD_BLOCK_NOT_PRESENT : + fallthrough;case PAYLOAD_BLOCK_UNMAPPED : + fallthrough;case PAYLOAD_BLOCK_UNMAPPED_v095: + fallthrough;case PAYLOAD_BLOCK_UNDEFINED : bat_prior_offset = sinfo.file_offset; ret =vhdx_allocate_block (bs, s, &sinfo.file_offset, &use_zero_buffers);if (ret <0 ) { goto exit; }/* * once we support differencing files, this may also be * partially present */ /* update block state to the newly specified state */ vhdx_update_bat_table_entry (bs, s, &sinfo, &bat_entry, &bat_entry_offset,PAYLOAD_BLOCK_FULLY_PRESENT ); bat_update = true;/* * Since we just allocated a block, file_offset is the * beginning of the payload block. It needs to be the * write address, which includes the offset into the * block, unless the entire block needs to read as * zeroes but truncation was not able to provide them, * in which case we need to fill in the rest. */ if (!use_zero_buffers) { sinfo.file_offset += sinfo.block_offset; }else {/* zero fill the front, if any */ if (sinfo.block_offset) { iov1.iov_len = sinfo.block_offset; iov1.iov_base =qemu_blockalign (bs, iov1.iov_len);memset (iov1.iov_base,0 , iov1.iov_len);qemu_iovec_concat_iov (&hd_qiov, &iov1,1 ,0 , iov1.iov_len); sectors_to_write += iov1.iov_len >>BDRV_SECTOR_BITS ; }/* our actual data */ qemu_iovec_concat (&hd_qiov, qiov, bytes_done, sinfo.bytes_avail);/* zero fill the back, if any */ if ((sinfo.bytes_avail - sinfo.block_offset) < s->block_size) { iov2.iov_len = s->block_size - (sinfo.bytes_avail + sinfo.block_offset); iov2.iov_base =qemu_blockalign (bs, iov2.iov_len);memset (iov2.iov_base,0 , iov2.iov_len);qemu_iovec_concat_iov (&hd_qiov, &iov2,1 ,0 , iov2.iov_len); sectors_to_write += iov2.iov_len >>BDRV_SECTOR_BITS ; } } -/* fall through */ + fallthrough;case PAYLOAD_BLOCK_FULLY_PRESENT :/* if the file offset address is in the header zone, * there is a problem */ if (sinfo.file_offset < (1 * MiB)) { ret = -EFAULT ; goto error_bat_restore; }if (!use_zero_buffers) {qemu_iovec_concat (&hd_qiov, qiov, bytes_done, sinfo.bytes_avail); }/* block exists, so we can just overwrite it */ qemu_co_mutex_unlock (&s->lock); ret =bdrv_co_pwritev (bs->file, sinfo.file_offset, sectors_to_write *BDRV_SECTOR_SIZE , &hd_qiov,0 );qemu_co_mutex_lock (&s->lock);if (ret <0 ) { goto error_bat_restore; }break ;case PAYLOAD_BLOCK_PARTIALLY_PRESENT :/* we don't yet support difference files, fall through * to error */ + fallthrough;default : ret = -EIO ; goto exit;break ; }if (bat_update) {/* this will update the BAT entry into the log journal, and * then flush the log journal out to disk */ ret =vhdx_log_write_and_flush (bs, s, &bat_entry,sizeof (VHDXBatEntry), bat_entry_offset);if (ret <0 ) { goto exit; } } nb_sectors -= sinfo.sectors_avail; sector_num += sinfo.sectors_avail; bytes_done += sinfo.bytes_avail; } } goto exit;
Signature · 1 line
2.39.2
RFC PATCH 3/78 fpu/softfloat: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- fpu/softfloat-parts.c.inc | 8 ++++---- fpu/softfloat.c | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-)
fpu/softfloat-parts.c.inc +4 -4
@@ -138,166 +138,166 @@ static void partsN(canonicalize)(FloatPartsN *p, float_status *status, /* * Round and uncanonicalize a floating-point number by parts. There * are FRAC_SHIFT bits that may require rounding at the bottom of the * fraction; these bits will be removed. The exponent will be biased * by EXP_BIAS and must be bounded by [EXP_MAX-1, 0]. */ static void partsN(uncanon_normal)(FloatPartsN *p, float_status *s, const FloatFmt *fmt) { const int exp_max = fmt->exp_max; const int frac_shift = fmt->frac_shift; const uint64_t round_mask = fmt->round_mask; const uint64_t frac_lsb = round_mask + 1; const uint64_t frac_lsbm1 = round_mask ^ (round_mask >> 1); const uint64_t roundeven_mask = round_mask | frac_lsb; uint64_t inc; bool overflow_norm = false; int exp, flags = 0; switch (s->float_rounding_mode) { case float_round_nearest_even: if (N > 64 && frac_lsb == 0) { inc = ((p->frac_hi & 1) || (p->frac_lo & round_mask) != frac_lsbm1 ? frac_lsbm1 : 0); } else { inc = ((p->frac_lo & roundeven_mask) != frac_lsbm1 ? frac_lsbm1 : 0); } break; case float_round_ties_away: inc = frac_lsbm1; break; case float_round_to_zero: overflow_norm = true; inc = 0; break; case float_round_up: inc = p->sign ? 0 : round_mask; overflow_norm = p->sign; break; case float_round_down: inc = p->sign ? round_mask : 0; overflow_norm = !p->sign; break; case float_round_to_odd: overflow_norm = true; - /* fall through */ + fallthrough; case float_round_to_odd_inf: if (N > 64 && frac_lsb == 0) { inc = p->frac_hi & 1 ? 0 : round_mask; } else { inc = p->frac_lo & frac_lsb ? 0 : round_mask; } break; default: g_assert_not_reached(); } exp = p->exp + fmt->exp_bias; if (likely(exp > 0)) { if (p->frac_lo & round_mask) { flags |= float_flag_inexact; if (frac_addi(p, p, inc)) { frac_shr(p, 1); p->frac_hi |= DECOMPOSED_IMPLICIT_BIT; exp++; } p->frac_lo &= ~round_mask; } if (fmt->arm_althp) { /* ARM Alt HP eschews Inf and NaN for a wider exponent. */ if (unlikely(exp > exp_max)) { /* Overflow. Return the maximum normal. */ flags = float_flag_invalid; exp = exp_max; frac_allones(p); p->frac_lo &= ~round_mask; } } else if (unlikely(exp >= exp_max)) { flags |= float_flag_overflow; if (s->rebias_overflow) { exp -= fmt->exp_re_bias; } else if (overflow_norm) { flags |= float_flag_inexact; exp = exp_max - 1; frac_allones(p); p->frac_lo &= ~round_mask; } else { flags |= float_flag_inexact; p->cls = float_class_inf; exp = exp_max; frac_clear(p); } } frac_shr(p, frac_shift); } else if (unlikely(s->rebias_underflow)) { flags |= float_flag_underflow; exp += fmt->exp_re_bias; if (p->frac_lo & round_mask) { flags |= float_flag_inexact; if (frac_addi(p, p, inc)) { frac_shr(p, 1); p->frac_hi |= DECOMPOSED_IMPLICIT_BIT; exp++; } p->frac_lo &= ~round_mask; } frac_shr(p, frac_shift); } else if (s->flush_to_zero) { flags |= float_flag_output_denormal; p->cls = float_class_zero; exp = 0; frac_clear(p); } else { bool is_tiny = s->tininess_before_rounding || exp < 0; if (!is_tiny) { FloatPartsN discard; is_tiny = !frac_addi(&discard, p, inc); } frac_shrjam(p, !fmt->m68k_denormal - exp); if (p->frac_lo & round_mask) { /* Need to recompute round-to-even/round-to-odd. */ switch (s->float_rounding_mode) { case float_round_nearest_even: if (N > 64 && frac_lsb == 0) { inc = ((p->frac_hi & 1) || (p->frac_lo & round_mask) != frac_lsbm1 ? frac_lsbm1 : 0); } else { inc = ((p->frac_lo & roundeven_mask) != frac_lsbm1 ? frac_lsbm1 : 0); } break; case float_round_to_odd: case float_round_to_odd_inf: if (N > 64 && frac_lsb == 0) { inc = p->frac_hi & 1 ? 0 : round_mask; } else { inc = p->frac_lo & frac_lsb ? 0 : round_mask; } break; default: break; } flags |= float_flag_inexact; frac_addi(p, p, inc); p->frac_lo &= ~round_mask; } exp = (p->frac_hi & DECOMPOSED_IMPLICIT_BIT) && !fmt->m68k_denormal; frac_shr(p, frac_shift); if (is_tiny && (flags & float_flag_inexact)) { flags |= float_flag_underflow; } if (exp == 0 && frac_eqz(p)) { p->cls = float_class_zero; } } p->exp = exp; float_raise(flags, s); }
@@ -1051,219 +1051,219 @@ static void partsN(round_to_int)(FloatPartsN *a, FloatRoundMode rmode, /* * Returns the result of converting the floating-point value `a' to * the two's complement integer format. The conversion is performed * according to the IEC/IEEE Standard for Binary Floating-Point * Arithmetic---which means in particular that the conversion is * rounded according to the current rounding mode. If `a' is a NaN, * the largest positive integer is returned. Otherwise, if the * conversion overflows, the largest integer with the same sign as `a' * is returned. */ static int64_t partsN(float_to_sint)(FloatPartsN *p, FloatRoundMode rmode, int scale, int64_t min, int64_t max, float_status *s) { int flags = 0; uint64_t r; switch (p->cls) { case float_class_snan: flags |= float_flag_invalid_snan; - /* fall through */ + fallthrough; case float_class_qnan: flags |= float_flag_invalid; r = max; break; case float_class_inf: flags = float_flag_invalid | float_flag_invalid_cvti; r = p->sign ? min : max; break; case float_class_zero: return 0; case float_class_normal: /* TODO: N - 2 is frac_size for rounding; could use input fmt. */ if (parts_round_to_int_normal(p, rmode, scale, N - 2)) { flags = float_flag_inexact; } if (p->exp <= DECOMPOSED_BINARY_POINT) { r = p->frac_hi >> (DECOMPOSED_BINARY_POINT - p->exp); } else { r = UINT64_MAX; } if (p->sign) { if (r <= -(uint64_t)min) { r = -r; } else { flags = float_flag_invalid | float_flag_invalid_cvti; r = min; } } else if (r > max) { flags = float_flag_invalid | float_flag_invalid_cvti; r = max; } break; default: g_assert_not_reached(); } float_raise(flags, s); return r; } /* * Returns the result of converting the floating-point value `a' to * the unsigned integer format. The conversion is performed according * to the IEC/IEEE Standard for Binary Floating-Point * Arithmetic---which means in particular that the conversion is * rounded according to the current rounding mode. If `a' is a NaN, * the largest unsigned integer is returned. Otherwise, if the * conversion overflows, the largest unsigned integer is returned. If * the 'a' is negative, the result is rounded and zero is returned; * values that do not round to zero will raise the inexact exception * flag. */ static uint64_t partsN(float_to_uint)(FloatPartsN *p, FloatRoundMode rmode, int scale, uint64_t max, float_status *s) { int flags = 0; uint64_t r; switch (p->cls) { case float_class_snan: flags |= float_flag_invalid_snan; - /* fall through */ + fallthrough; case float_class_qnan: flags |= float_flag_invalid; r = max; break; case float_class_inf: flags = float_flag_invalid | float_flag_invalid_cvti; r = p->sign ? 0 : max; break; case float_class_zero: return 0; case float_class_normal: /* TODO: N - 2 is frac_size for rounding; could use input fmt. */ if (parts_round_to_int_normal(p, rmode, scale, N - 2)) { flags = float_flag_inexact; if (p->cls == float_class_zero) { r = 0; break; } } if (p->sign) { flags = float_flag_invalid | float_flag_invalid_cvti; r = 0; } else if (p->exp > DECOMPOSED_BINARY_POINT) { flags = float_flag_invalid | float_flag_invalid_cvti; r = max; } else { r = p->frac_hi >> (DECOMPOSED_BINARY_POINT - p->exp); if (r > max) { flags = float_flag_invalid | float_flag_invalid_cvti; r = max; } } break; default: g_assert_not_reached(); } float_raise(flags, s); return r; } /* * Like partsN(float_to_sint), except do not saturate the result. * Instead, return the rounded unbounded precision two's compliment result, * modulo 2**(bitsm1 + 1). */ static int64_t partsN(float_to_sint_modulo)(FloatPartsN *p, FloatRoundMode rmode, int bitsm1, float_status *s) { int flags = 0; uint64_t r; bool overflow = false; switch (p->cls) { case float_class_snan: flags |= float_flag_invalid_snan; - /* fall through */ + fallthrough; case float_class_qnan: flags |= float_flag_invalid; r = 0; break; case float_class_inf: overflow = true; r = 0; break; case float_class_zero: return 0; case float_class_normal: /* TODO: N - 2 is frac_size for rounding; could use input fmt. */ if (parts_round_to_int_normal(p, rmode, 0, N - 2)) { flags = float_flag_inexact; } if (p->exp <= DECOMPOSED_BINARY_POINT) { /* * Because we rounded to integral, and exp < 64, * we know frac_low is zero. */ r = p->frac_hi >> (DECOMPOSED_BINARY_POINT - p->exp); if (p->exp < bitsm1) { /* Result in range. */ } else if (p->exp == bitsm1) { /* The only in-range value is INT_MIN. */ overflow = !p->sign || p->frac_hi != DECOMPOSED_IMPLICIT_BIT; } else { overflow = true; } } else { /* Overflow, but there might still be bits to return. */ int shl = p->exp - DECOMPOSED_BINARY_POINT; if (shl < N) { frac_shl(p, shl); r = p->frac_hi; } else { r = 0; } overflow = true; } if (p->sign) { r = -r; } break; default: g_assert_not_reached(); } if (overflow) { flags = float_flag_invalid | float_flag_invalid_cvti; } float_raise(flags, s); return r; } /* * Integer to float conversions * * Returns the result of converting the two's complement integer `a' * to the floating-point format. The conversion is performed according * to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. */
fpu/softfloat.c +4 -3
@@ -1811,56 +1811,57 @@ static bool floatx80_unpack_canonical(FloatParts128 *p, floatx80 f,static floatx80 floatx80_round_pack_canonical (FloatParts128 *p,float_status *s) {const FloatFmt *fmt = &floatx80_params[s->floatx80_rounding_precision];uint64_t frac;int exp;switch (p->cls) {case float_class_normal:if (s->floatx80_rounding_precision == floatx80_precision_x) {parts_uncanon_normal (p, s, fmt); frac = p->frac_hi; exp = p->exp; }else {FloatParts64 p64; p64.sign = p->sign; p64.exp = p->exp;frac_truncjam (&p64, p);parts_uncanon_normal (&p64, s, fmt); frac = p64.frac; exp = p64.exp; }if (exp != fmt->exp_max) {break ; }/* rounded to inf -- fall through to set frac correctly */ + fallthrough;case float_class_inf:/* x86 and m68k differ in the setting of the integer bit. */ frac = floatx80_infinity_low; exp = fmt->exp_max;break ;case float_class_zero: frac =0 ; exp =0 ;break ;case float_class_snan:case float_class_qnan:/* NaNs have the integer bit set. */ frac = p->frac_hi | (1ull <<63 ); exp = fmt->exp_max;break ;default :g_assert_not_reached (); }return packFloatx80 (p->sign, exp, frac); }/* * Addition and subtraction */
@@ -2668,35 +2669,35 @@ floatx80 floatx80_mod(floatx80 a, floatx80 b, float_status *status)static void parts_float_to_ahp (FloatParts64 *a,float_status *s) {switch (a->cls) {case float_class_snan:float_raise (float_flag_invalid_snan, s); -/* fall through */ + fallthrough;case float_class_qnan:/* * There is no NaN in the destination format. Raise Invalid * and return a zero with the sign of the input NaN. */ float_raise (float_flag_invalid, s); a->cls = float_class_zero;break ;case float_class_inf:/* * There is no Inf in the destination format. Raise Invalid * and return the maximum normal with the correct sign. */ float_raise (float_flag_invalid, s); a->cls = float_class_normal; a->exp = float16_params_ahp.exp_max; a->frac =MAKE_64BIT_MASK (float16_params_ahp.frac_shift, float16_params_ahp.frac_size +1 );break ;case float_class_normal:case float_class_zero:break ;default :g_assert_not_reached (); } }
@@ -3190,53 +3191,53 @@ static int64_t float128_to_int64_scalbn(float128 a, FloatRoundMode rmode,static Int128 float128_to_int128_scalbn (float128 a,FloatRoundMode rmode,int scale,float_status *s) {int flags =0 ;Int128 r;FloatParts128 p;float128_unpack_canonical (&p, a, s);switch (p.cls) {case float_class_snan: flags |= float_flag_invalid_snan; -/* fall through */ + fallthrough;case float_class_qnan: flags |= float_flag_invalid; r =UINT128_MAX ;break ;case float_class_inf: flags = float_flag_invalid | float_flag_invalid_cvti; r = p.sign ?INT128_MIN :INT128_MAX ;break ;case float_class_zero:return int128_zero ();case float_class_normal:if (parts_round_to_int_normal (&p, rmode, scale,128 -2 )) { flags = float_flag_inexact; }if (p.exp <127 ) {int shift =127 - p.exp; r =int128_urshift (int128_make128 (p.frac_lo, p.frac_hi), shift);if (p.sign) { r =int128_neg (r); } }else if (p.exp ==127 && p.sign && p.frac_lo ==0 && p.frac_hi ==DECOMPOSED_IMPLICIT_BIT ) { r =INT128_MIN ; }else { flags = float_flag_invalid | float_flag_invalid_cvti; r = p.sign ?INT128_MIN :INT128_MAX ; }break ;default :g_assert_not_reached (); }float_raise (flags, s);return r; }
@@ -3617,54 +3618,54 @@ static uint64_t float128_to_uint64_scalbn(float128 a, FloatRoundMode rmode,static Int128 float128_to_uint128_scalbn (float128 a,FloatRoundMode rmode,int scale,float_status *s) {int flags =0 ;Int128 r;FloatParts128 p;float128_unpack_canonical (&p, a, s);switch (p.cls) {case float_class_snan: flags |= float_flag_invalid_snan; -/* fall through */ + fallthrough;case float_class_qnan: flags |= float_flag_invalid; r =UINT128_MAX ;break ;case float_class_inf: flags = float_flag_invalid | float_flag_invalid_cvti; r = p.sign ?int128_zero () :UINT128_MAX ;break ;case float_class_zero:return int128_zero ();case float_class_normal:if (parts_round_to_int_normal (&p, rmode, scale,128 -2 )) { flags = float_flag_inexact;if (p.cls == float_class_zero) { r =int128_zero ();break ; } }if (p.sign) { flags = float_flag_invalid | float_flag_invalid_cvti; r =int128_zero (); }else if (p.exp <=127 ) {int shift =127 - p.exp; r =int128_urshift (int128_make128 (p.frac_lo, p.frac_hi), shift); }else { flags = float_flag_invalid | float_flag_invalid_cvti; r =UINT128_MAX ; }break ;default :g_assert_not_reached (); }float_raise (flags, s);return r; }
Signature · 1 line
2.39.2
RFC PATCH 4/78 qapi/opts-visitor: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- qapi/opts-visitor.c | 1 + qapi/string-input-visitor.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
qapi/opts-visitor.c +1 -0
@@ -249,41 +249,42 @@ static GenericList * opts_next_list(Visitor *v, GenericList *tail, size_t size) {OptsVisitor *ov =to_ov (v);switch (ov->list_mode) {case LM_TRAVERSED :return NULL ;case LM_SIGNED_INTERVAL :case LM_UNSIGNED_INTERVAL :if (ov->list_mode ==LM_SIGNED_INTERVAL ) {if (ov->range_next.s < ov->range_limit.s) { ++ov->range_next.s;break ; } }else if (ov->range_next.u < ov->range_limit.u) { ++ov->range_next.u;break ; } ov->list_mode =LM_IN_PROGRESS ;/* range has been completed, fall through in order to pop option */ + fallthrough;case LM_IN_PROGRESS : {const QemuOpt *opt; opt =g_queue_pop_head (ov->repeated_opts);if (g_queue_is_empty (ov->repeated_opts)) {g_hash_table_remove (ov->unprocessed_opts, opt->name); ov->repeated_opts =NULL ; ov->list_mode =LM_TRAVERSED ;return NULL ; }break ; }default :abort (); } tail->next =g_malloc0 (size);return tail->next; }
qapi/string-input-visitor.c +2 -2
@@ -182,41 +182,41 @@ static int try_parse_int64_list_entry(StringInputVisitor *siv, int64_t *obj)static bool parse_type_int64 (Visitor *v,const char *name,int64_t *obj,Error **errp) {StringInputVisitor *siv =to_siv (v);int64_t val;switch (siv->lm) {case LM_NONE :/* just parse a simple int64, bail out if not completely consumed */ if (qemu_strtoi64 (siv->string,NULL ,0 , &val)) {error_setg (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" ,"int64" );return false; } *obj = val;return true;case LM_UNPARSED :if (try_parse_int64_list_entry (siv, obj)) {error_setg (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" ,"list of int64 values or ranges" );return false; }assert (siv->lm ==LM_INT64_RANGE ); -/* fall through */ + fallthrough;case LM_INT64_RANGE :/* return the next element in the range */ assert (siv->rangeNext.i64 <= siv->rangeEnd.i64); *obj = siv->rangeNext.i64++;if (siv->rangeNext.i64 > siv->rangeEnd.i64 || *obj ==INT64_MAX ) {/* end of range, check if there is more to parse */ siv->lm = siv->unparsed_string[0 ] ?LM_UNPARSED :LM_END ; }return true;case LM_END :error_setg (errp,"Fewer list elements expected" );return false;default :abort (); } }
@@ -272,41 +272,41 @@ static int try_parse_uint64_list_entry(StringInputVisitor *siv, uint64_t *obj)static bool parse_type_uint64 (Visitor *v,const char *name,uint64_t *obj,Error **errp) {StringInputVisitor *siv =to_siv (v);uint64_t val;switch (siv->lm) {case LM_NONE :/* just parse a simple uint64, bail out if not completely consumed */ if (qemu_strtou64 (siv->string,NULL ,0 , &val)) {error_setg (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" ,"uint64" );return false; } *obj = val;return true;case LM_UNPARSED :if (try_parse_uint64_list_entry (siv, obj)) {error_setg (errp,QERR_INVALID_PARAMETER_VALUE , name ? name :"null" ,"list of uint64 values or ranges" );return false; }assert (siv->lm ==LM_UINT64_RANGE ); -/* fall through */ + fallthrough;case LM_UINT64_RANGE :/* return the next element in the range */ assert (siv->rangeNext.u64 <= siv->rangeEnd.u64); *obj = siv->rangeNext.u64++;if (siv->rangeNext.u64 > siv->rangeEnd.u64 || *obj ==UINT64_MAX ) {/* end of range, check if there is more to parse */ siv->lm = siv->unparsed_string[0 ] ?LM_UNPARSED :LM_END ; }return true;case LM_END :error_setg (errp,"Fewer list elements expected" );return false;default :abort (); } }
Signature · 1 line
2.39.2
RFC PATCH 5/78 qobject/json: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- qobject/json-lexer.c | 4 ++-- qobject/json-parser.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-)
qobject/json-lexer.c +2 -2
@@ -283,61 +283,61 @@ void json_lexer_init(JSONLexer *lexer, bool enable_interpolation)static void json_lexer_feed_char (JSONLexer *lexer,char ch,bool flush) {int new_state;bool char_consumed = false; lexer->x++;if (ch =='\n' ) { lexer->x =0 ; lexer->y++; }while (flush ? lexer->state != lexer->start_state : !char_consumed) { new_state =next_state (lexer, ch, flush, &char_consumed);if (char_consumed) {assert (!flush);g_string_append_c (lexer->token, ch); }switch (new_state) {case JSON_LCURLY :case JSON_RCURLY :case JSON_LSQUARE :case JSON_RSQUARE :case JSON_COLON :case JSON_COMMA :case JSON_INTERP :case JSON_INTEGER :case JSON_FLOAT :case JSON_KEYWORD :case JSON_STRING :json_message_process_token (lexer, lexer->token, new_state, lexer->x, lexer->y); -/* fall through */ + fallthrough;case IN_START :g_string_truncate (lexer->token,0 ); new_state = lexer->start_state;break ;case JSON_ERROR :json_message_process_token (lexer, lexer->token,JSON_ERROR , lexer->x, lexer->y); new_state =IN_RECOVERY ; -/* fall through */ + fallthrough;case IN_RECOVERY :g_string_truncate (lexer->token,0 );break ;default :break ; } lexer->state = new_state; }/* Do not let a single token grow to an arbitrarily large size, * this is a security consideration. */ if (lexer->token->len >MAX_TOKEN_SIZE ) {json_message_process_token (lexer, lexer->token, lexer->state, lexer->x, lexer->y);g_string_truncate (lexer->token,0 ); lexer->state = lexer->start_state; } }
qobject/json-parser.c +3 -2
@@ -95,137 +95,137 @@ static int cvt4hex(const char *s)/** * parse_string(): Parse a JSON string * * From RFC 8259 "The JavaScript Object Notation (JSON) Data * Interchange Format": * * char = unescaped / * escape ( * %x22 / ; " quotation mark U+0022 * %x5C / ; \ reverse solidus U+005C * %x2F / ; / solidus U+002F * %x62 / ; b backspace U+0008 * %x66 / ; f form feed U+000C * %x6E / ; n line feed U+000A * %x72 / ; r carriage return U+000D * %x74 / ; t tab U+0009 * %x75 4HEXDIG ) ; uXXXX U+XXXX * escape = %x5C ; \ * quotation-mark = %x22 ; " * unescaped = %x20-21 / %x23-5B / %x5D-10FFFF * * Extensions over RFC 8259: * - Extra escape sequence in strings: * 0x27 (apostrophe) is recognized after escape, too * - Single-quoted strings: * Like double-quoted strings, except they're delimited by %x27 * (apostrophe) instead of %x22 (quotation mark), and can't contain * unescaped apostrophe, but can contain unescaped quotation mark. * * Note: * - Encoding is modified UTF-8. * - Invalid Unicode characters are rejected. * - Control characters \x00..\x1F are rejected by the lexer. */ static QString *parse_string (JSONParserContext *ctxt,JSONToken *token) {const char *ptr = token->str;GString *str;char quote;const char *beg;int cp, trailing;char *end;ssize_t len;char utf8_buf[5 ];assert (*ptr =='"' || *ptr =='\'' ); quote = *ptr++; str =g_string_new (NULL );while (*ptr != quote) {assert (*ptr);switch (*ptr) {case '\\' : beg = ptr++;switch (*ptr++) {case '"' :g_string_append_c (str,'"' );break ;case '\'' :g_string_append_c (str,'\'' );break ;case '\\' :g_string_append_c (str,'\\' );break ;case '/' :g_string_append_c (str,'/' );break ;case 'b' :g_string_append_c (str,'\b' );break ;case 'f' :g_string_append_c (str,'\f' );break ;case 'n' :g_string_append_c (str,'\n' );break ;case 'r' :g_string_append_c (str,'\r' );break ;case 't' :g_string_append_c (str,'\t' );break ;case 'u' : cp =cvt4hex (ptr); ptr +=4 ;/* handle surrogate pairs */ if (cp >=0xD800 && cp <=0xDBFF && ptr[0 ] =='\\' && ptr[1 ] =='u' ) {/* leading surrogate followed by \u */ cp =0x10000 + ((cp &0x3FF ) <<10 ); trailing =cvt4hex (ptr +2 );if (trailing >=0xDC00 && trailing <=0xDFFF ) {/* followed by trailing surrogate */ cp |= trailing &0x3FF ; ptr +=6 ; }else { cp =-1 ;/* invalid */ } }if (mod_utf8_encode (utf8_buf,sizeof (utf8_buf), cp) <0 ) {parse_error (ctxt, token,"%.*s is not a valid Unicode character" , (int )(ptr - beg), beg); goto out; }g_string_append (str, utf8_buf);break ;default :parse_error (ctxt, token,"invalid escape sequence in string" ); goto out; }break ;case '%' :if (ctxt->ap) {if (ptr[1 ] !='%' ) {parse_error (ctxt, token,"can't interpolate into string" ); goto out; } ptr++; } -/* fall through */ + fallthrough;default : cp =mod_utf8_codepoint (ptr,6 , &end);if (cp <0 ) {parse_error (ctxt, token,"invalid UTF-8 sequence in string" ); goto out; } ptr = end; len =mod_utf8_encode (utf8_buf,sizeof (utf8_buf), cp);assert (len >=0 );g_string_append (str, utf8_buf); } }return qstring_from_gstring (str);
@@ -481,51 +481,52 @@ static QObject *parse_interpolation(JSONParserContext *ctxt)static QObject *parse_literal (JSONParserContext *ctxt) {JSONToken *token; token =parser_context_pop_token (ctxt);assert (token);switch (token->type) {case JSON_STRING :return QOBJECT (parse_string (ctxt, token));case JSON_INTEGER : {/* * Represent JSON_INTEGER as QNUM_I64 if possible, else as * QNUM_U64, else as QNUM_DOUBLE. Note that qemu_strtoi64() * and qemu_strtou64() fail with ERANGE when it's not * possible. * * qnum_get_int() will then work for any signed 64-bit * JSON_INTEGER, qnum_get_uint() for any unsigned 64-bit * integer, and qnum_get_double() both for any JSON_INTEGER * and any JSON_FLOAT (with precision loss for integers beyond * 53 bits) */ int ret;int64_t value;uint64_t uvalue; ret =qemu_strtoi64 (token->str,NULL ,10 , &value);if (!ret) {return QOBJECT (qnum_from_int (value)); }assert (ret == -ERANGE );if (token->str[0 ] !='-' ) { ret =qemu_strtou64 (token->str,NULL ,10 , &uvalue);if (!ret) {return QOBJECT (qnum_from_uint (uvalue)); }assert (ret == -ERANGE ); } +/* fall through to JSON_FLOAT */ + fallthrough; } -/* fall through to JSON_FLOAT */ case JSON_FLOAT :/* FIXME dependent on locale; a pervasive issue in QEMU */ /* FIXME our lexer matches RFC 8259 in forbidding Inf or NaN, * but those might be useful extensions beyond JSON */ return QOBJECT (qnum_from_double (strtod (token->str,NULL )));default :abort (); } }
Signature · 1 line
2.39.2
RFC PATCH 6/78 tcg: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- target/i386/tcg/translate.c | 3 +++ tcg/aarch64/tcg-target.c.inc | 15 ++++++++++++++- tcg/arm/tcg-target.c.inc | 5 +++-- tcg/i386/tcg-target.c.inc | 20 ++++++++++++++------ tcg/loongarch64/tcg-target.c.inc | 4 ++-- tcg/mips/tcg-target.c.inc | 8 ++++++-- tcg/ppc/tcg-target.c.inc | 19 ++++++++++++++----- tcg/riscv/tcg-target.c.inc | 5 +++-- tcg/s390x/tcg-target.c.inc | 8 ++++++-- tcg/tcg-op-gvec.c | 24 ++++++++++++------------ tcg/tcg-op-ldst.c | 2 +- tcg/tcg.c | 24 +++++++++++++----------- tcg/tci.c | 2 +- tcg/tci/tcg-target.c.inc | 2 +- 14 files changed, 93 insertions(+), 48 deletions(-)
target/i386/tcg/translate.c +3 -0
@@ -1966,83 +1966,84 @@ static void gen_rotc_rm_T1(DisasContext *s, MemOp ot, int op1,/* XXX: add faster immediate case */ static void gen_shiftd_rm_T1 (DisasContext *s,MemOp ot,int op1,bool is_right,TCGv count_in) {target_ulong mask = (ot ==MO_64 ?63 :31 );TCGv count;/* load */ if (op1 ==OR_TMP0 ) {gen_op_ld_v (s, ot, s->T0, s->A0); }else {gen_op_mov_v_reg (s, ot, s->T0, op1); } count =tcg_temp_new ();tcg_gen_andi_tl (count, count_in, mask);switch (ot) {case MO_16 :/* Note: we implement the Intel behaviour for shift count > 16. This means "shrdw C, B, A" shifts A:B:A >> C. Build the B:A portion by constructing it as a 32-bit value. */ if (is_right) {tcg_gen_deposit_tl (s->tmp0, s->T0, s->T1,16 ,16 );tcg_gen_mov_tl (s->T1, s->T0);tcg_gen_mov_tl (s->T0, s->tmp0); }else {tcg_gen_deposit_tl (s->T1, s->T0, s->T1,16 ,16 ); }/* * If TARGET_X86_64 defined then fall through into MO_32 case, * otherwise fall through default case. */ + fallthrough;case MO_32 :#ifdef TARGET_X86_64 /* Concatenate the two 32-bit values and use a 64-bit shift. */ tcg_gen_subi_tl (s->tmp0, count,1 );if (is_right) {tcg_gen_concat_tl_i64 (s->T0, s->T0, s->T1);tcg_gen_shr_i64 (s->tmp0, s->T0, s->tmp0);tcg_gen_shr_i64 (s->T0, s->T0, count); }else {tcg_gen_concat_tl_i64 (s->T0, s->T1, s->T0);tcg_gen_shl_i64 (s->tmp0, s->T0, s->tmp0);tcg_gen_shl_i64 (s->T0, s->T0, count);tcg_gen_shri_i64 (s->tmp0, s->tmp0,32 );tcg_gen_shri_i64 (s->T0, s->T0,32 ); }break ;#endif default :tcg_gen_subi_tl (s->tmp0, count,1 );if (is_right) {tcg_gen_shr_tl (s->tmp0, s->T0, s->tmp0);tcg_gen_subfi_tl (s->tmp4, mask +1 , count);tcg_gen_shr_tl (s->T0, s->T0, count);tcg_gen_shl_tl (s->T1, s->T1, s->tmp4); }else {tcg_gen_shl_tl (s->tmp0, s->T0, s->tmp0);if (ot ==MO_16 ) {/* Only needed if count > 16, for Intel behaviour. */ tcg_gen_subfi_tl (s->tmp4,33 , count);tcg_gen_shr_tl (s->tmp4, s->T1, s->tmp4);tcg_gen_or_tl (s->tmp0, s->tmp0, s->tmp4); }tcg_gen_subfi_tl (s->tmp4, mask +1 , count);tcg_gen_shl_tl (s->T0, s->T0, count);tcg_gen_shr_tl (s->T1, s->T1, s->tmp4); }tcg_gen_movi_tl (s->tmp4,0 );tcg_gen_movcond_tl (TCG_COND_EQ , s->T1, count, s->tmp4, s->tmp4, s->T1);tcg_gen_or_tl (s->T0, s->T0, s->T1);break ; }/* store */ gen_op_st_rm_T0_A0 (s, ot, op1);gen_shift_flags (s, ot, s->T0, s->tmp0, count, is_right); }
@@ -3078,3750 +3079,3751 @@ static void gen_cmpxchg16b(DisasContext *s, CPUX86State *env, int modrm)/* convert one instruction. s->base.is_jmp is set if the translation must be stopped. Return the next pc value */ static bool disas_insn (DisasContext *s,CPUState *cpu) {CPUX86State *env =cpu_env (cpu);int b, prefixes;int shift;MemOp ot, aflag, dflag;int modrm, reg, rm, mod, op, opreg, val;bool orig_cc_op_dirty = s->cc_op_dirty;CCOp orig_cc_op = s->cc_op;target_ulong orig_pc_save = s->pc_save; s->pc = s->base.pc_next; s->override =-1 ;#ifdef TARGET_X86_64 s->rex_r =0 ; s->rex_x =0 ; s->rex_b =0 ;#endif s->rip_offset =0 ;/* for relative ip address */ s->vex_l =0 ; s->vex_v =0 ; s->vex_w = false;switch (sigsetjmp (s->jmpbuf,0 )) {case 0 :break ;case 1 :gen_exception_gpf (s);return true;case 2 :/* Restore state that may affect the next instruction. */ s->pc = s->base.pc_next;/* * TODO: These save/restore can be removed after the table-based * decoder is complete; we will be decoding the insn completely * before any code generation that might affect these variables. */ s->cc_op_dirty = orig_cc_op_dirty; s->cc_op = orig_cc_op; s->pc_save = orig_pc_save;/* END TODO */ s->base.num_insns--;tcg_remove_ops_after (s->prev_insn_end); s->base.is_jmp =DISAS_TOO_MANY ;return false;default :g_assert_not_reached (); } prefixes =0 ; next_byte: s->prefix = prefixes; b =x86_ldub_code (env, s);/* Collect prefixes. */ switch (b) {default :break ;case 0x0f : b =x86_ldub_code (env, s) +0x100 ;break ;case 0xf3 : prefixes |=PREFIX_REPZ ; prefixes &= ~PREFIX_REPNZ ; goto next_byte;case 0xf2 : prefixes |=PREFIX_REPNZ ; prefixes &= ~PREFIX_REPZ ; goto next_byte;case 0xf0 : prefixes |=PREFIX_LOCK ; goto next_byte;case 0x2e : s->override =R_CS ; goto next_byte;case 0x36 : s->override =R_SS ; goto next_byte;case 0x3e : s->override =R_DS ; goto next_byte;case 0x26 : s->override =R_ES ; goto next_byte;case 0x64 : s->override =R_FS ; goto next_byte;case 0x65 : s->override =R_GS ; goto next_byte;case 0x66 : prefixes |=PREFIX_DATA ; goto next_byte;case 0x67 : prefixes |=PREFIX_ADR ; goto next_byte;#ifdef TARGET_X86_64 case 0x40 ... 0x4f:if (CODE64 (s)) {/* REX prefix */ prefixes |=PREFIX_REX ; s->vex_w = (b >>3 ) &1 ; s->rex_r = (b &0x4 ) <<1 ; s->rex_x = (b &0x2 ) <<2 ; s->rex_b = (b &0x1 ) <<3 ; goto next_byte; }break ;#endif case 0xc5 :/* 2-byte VEX */ case 0xc4 :/* 3-byte VEX */ if (CODE32 (s) && !VM86 (s)) {int vex2 =x86_ldub_code (env, s); s->pc--;/* rewind the advance_pc() x86_ldub_code() did */ if (!CODE64 (s) && (vex2 &0xc0 ) !=0xc0 ) {/* 4.1.4.6: In 32-bit mode, bits [7:6] must be 11b, otherwise the instruction is LES or LDS. */ break ; }disas_insn_new (s, cpu, b);return s->pc; }break ; }/* Post-process prefixes. */ if (CODE64 (s)) {/* In 64-bit mode, the default data size is 32-bit. Select 64-bit data with rex_w, and 16-bit data with 0x66; rex_w takes precedence over 0x66 if both are present. */ dflag = (REX_W (s) ?MO_64 : prefixes &PREFIX_DATA ?MO_16 :MO_32 );/* In 64-bit mode, 0x67 selects 32-bit addressing. */ aflag = (prefixes &PREFIX_ADR ?MO_32 :MO_64 ); }else {/* In 16/32-bit mode, 0x66 selects the opposite data size. */ if (CODE32 (s) ^ ((prefixes &PREFIX_DATA ) !=0 )) { dflag =MO_32 ; }else { dflag =MO_16 ; }/* In 16/32-bit mode, 0x67 selects the opposite addressing. */ if (CODE32 (s) ^ ((prefixes &PREFIX_ADR ) !=0 )) { aflag =MO_32 ; }else { aflag =MO_16 ; } } s->prefix = prefixes; s->aflag = aflag; s->dflag = dflag;/* now check op code */ switch (b) {/**************************/ /* arith & logic */ case 0x00 ... 0x05: case 0x08 ... 0x0d: case 0x10 ... 0x15: case 0x18 ... 0x1d: case 0x20 ... 0x25: case 0x28 ... 0x2d: case 0x30 ... 0x35: case 0x38 ... 0x3d: {int f; op = (b >>3 ) &7 ; f = (b >>1 ) &3 ; ot =mo_b_d (b, dflag);switch (f) {case 0 :/* OP Ev, Gv */ modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s); mod = (modrm >>6 ) &3 ; rm = (modrm &7 ) |REX_B (s);if (mod !=3 ) {gen_lea_modrm (env, s, modrm); opreg =OR_TMP0 ; }else if (op ==OP_XORL && rm == reg) { xor_zero:/* xor reg, reg optimisation */ set_cc_op (s,CC_OP_CLR );tcg_gen_movi_tl (s->T0,0 );gen_op_mov_reg_v (s, ot, reg, s->T0);break ; }else { opreg = rm; }gen_op_mov_v_reg (s, ot, s->T1, reg);gen_op (s, op, ot, opreg);break ;case 1 :/* OP Gv, Ev */ modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ; reg = ((modrm >>3 ) &7 ) |REX_R (s); rm = (modrm &7 ) |REX_B (s);if (mod !=3 ) {gen_lea_modrm (env, s, modrm);gen_op_ld_v (s, ot, s->T1, s->A0); }else if (op ==OP_XORL && rm == reg) { goto xor_zero; }else {gen_op_mov_v_reg (s, ot, s->T1, rm); }gen_op (s, op, ot, reg);break ;case 2 :/* OP A, Iv */ val =insn_get (env, s, ot);tcg_gen_movi_tl (s->T1, val);gen_op (s, op, ot,OR_EAX );break ; } }break ;case 0x82 :if (CODE64 (s)) goto illegal_op;/* fall through */ + fallthrough;case 0x80 :/* GRP1 */ case 0x81 :case 0x83 : { ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ; rm = (modrm &7 ) |REX_B (s); op = (modrm >>3 ) &7 ;if (mod !=3 ) {if (b ==0x83 ) s->rip_offset =1 ;else s->rip_offset =insn_const_size (ot);gen_lea_modrm (env, s, modrm); opreg =OR_TMP0 ; }else { opreg = rm; }switch (b) {default :case 0x80 :case 0x81 :case 0x82 : val =insn_get (env, s, ot);break ;case 0x83 : val = (int8_t )insn_get (env, s,MO_8 );break ; }tcg_gen_movi_tl (s->T1, val);gen_op (s, op, ot, opreg); }break ;/**************************/ /* inc, dec, and other misc arith */ case 0x40 ... 0x47: /* inc Gv */ ot = dflag;gen_inc (s, ot,OR_EAX + (b &7 ),1 );break ; case 0x48 ... 0x4f: /* dec Gv */ ot = dflag;gen_inc (s, ot,OR_EAX + (b &7 ),-1 );break ;case 0xf6 :/* GRP3 */ case 0xf7 : ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ; rm = (modrm &7 ) |REX_B (s); op = (modrm >>3 ) &7 ;if (mod !=3 ) {if (op ==0 ) { s->rip_offset =insn_const_size (ot); }gen_lea_modrm (env, s, modrm);/* For those below that handle locked memory, don't load here. */ if (!(s->prefix &PREFIX_LOCK ) || op !=2 ) {gen_op_ld_v (s, ot, s->T0, s->A0); } }else {gen_op_mov_v_reg (s, ot, s->T0, rm); }switch (op) {case 0 :/* test */ val =insn_get (env, s, ot);tcg_gen_movi_tl (s->T1, val);gen_op_testl_T0_T1_cc (s);set_cc_op (s,CC_OP_LOGICB + ot);break ;case 2 :/* not */ if (s->prefix &PREFIX_LOCK ) {if (mod ==3 ) { goto illegal_op; }tcg_gen_movi_tl (s->T0, ~0 );tcg_gen_atomic_xor_fetch_tl (s->T0, s->A0, s->T0, s->mem_index, ot |MO_LE ); }else {tcg_gen_not_tl (s->T0, s->T0);if (mod !=3 ) {gen_op_st_v (s, ot, s->T0, s->A0); }else {gen_op_mov_reg_v (s, ot, rm, s->T0); } }break ;case 3 :/* neg */ if (s->prefix &PREFIX_LOCK ) {TCGLabel *label1;TCGv a0, t0, t1, t2;if (mod ==3 ) { goto illegal_op; } a0 = s->A0; t0 = s->T0; label1 =gen_new_label ();gen_set_label (label1); t1 =tcg_temp_new (); t2 =tcg_temp_new ();tcg_gen_mov_tl (t2, t0);tcg_gen_neg_tl (t1, t0);tcg_gen_atomic_cmpxchg_tl (t0, a0, t0, t1, s->mem_index, ot |MO_LE );tcg_gen_brcond_tl (TCG_COND_NE , t0, t2, label1);tcg_gen_neg_tl (s->T0, t0); }else {tcg_gen_neg_tl (s->T0, s->T0);if (mod !=3 ) {gen_op_st_v (s, ot, s->T0, s->A0); }else {gen_op_mov_reg_v (s, ot, rm, s->T0); } }gen_op_update_neg_cc (s);set_cc_op (s,CC_OP_SUBB + ot);break ;case 4 :/* mul */ switch (ot) {case MO_8 :gen_op_mov_v_reg (s,MO_8 , s->T1,R_EAX );tcg_gen_ext8u_tl (s->T0, s->T0);tcg_gen_ext8u_tl (s->T1, s->T1);/* XXX: use 32 bit mul which could be faster */ tcg_gen_mul_tl (s->T0, s->T0, s->T1);gen_op_mov_reg_v (s,MO_16 ,R_EAX , s->T0);tcg_gen_mov_tl (cpu_cc_dst, s->T0);tcg_gen_andi_tl (cpu_cc_src, s->T0,0xff00 );set_cc_op (s,CC_OP_MULB );break ;case MO_16 :gen_op_mov_v_reg (s,MO_16 , s->T1,R_EAX );tcg_gen_ext16u_tl (s->T0, s->T0);tcg_gen_ext16u_tl (s->T1, s->T1);/* XXX: use 32 bit mul which could be faster */ tcg_gen_mul_tl (s->T0, s->T0, s->T1);gen_op_mov_reg_v (s,MO_16 ,R_EAX , s->T0);tcg_gen_mov_tl (cpu_cc_dst, s->T0);tcg_gen_shri_tl (s->T0, s->T0,16 );gen_op_mov_reg_v (s,MO_16 ,R_EDX , s->T0);tcg_gen_mov_tl (cpu_cc_src, s->T0);set_cc_op (s,CC_OP_MULW );break ;default :case MO_32 :tcg_gen_trunc_tl_i32 (s->tmp2_i32, s->T0);tcg_gen_trunc_tl_i32 (s->tmp3_i32, cpu_regs[R_EAX ]);tcg_gen_mulu2_i32 (s->tmp2_i32, s->tmp3_i32, s->tmp2_i32, s->tmp3_i32);tcg_gen_extu_i32_tl (cpu_regs[R_EAX ], s->tmp2_i32);tcg_gen_extu_i32_tl (cpu_regs[R_EDX ], s->tmp3_i32);tcg_gen_mov_tl (cpu_cc_dst, cpu_regs[R_EAX ]);tcg_gen_mov_tl (cpu_cc_src, cpu_regs[R_EDX ]);set_cc_op (s,CC_OP_MULL );break ;#ifdef TARGET_X86_64 case MO_64 :tcg_gen_mulu2_i64 (cpu_regs[R_EAX ], cpu_regs[R_EDX ], s->T0, cpu_regs[R_EAX ]);tcg_gen_mov_tl (cpu_cc_dst, cpu_regs[R_EAX ]);tcg_gen_mov_tl (cpu_cc_src, cpu_regs[R_EDX ]);set_cc_op (s,CC_OP_MULQ );break ;#endif }break ;case 5 :/* imul */ switch (ot) {case MO_8 :gen_op_mov_v_reg (s,MO_8 , s->T1,R_EAX );tcg_gen_ext8s_tl (s->T0, s->T0);tcg_gen_ext8s_tl (s->T1, s->T1);/* XXX: use 32 bit mul which could be faster */ tcg_gen_mul_tl (s->T0, s->T0, s->T1);gen_op_mov_reg_v (s,MO_16 ,R_EAX , s->T0);tcg_gen_mov_tl (cpu_cc_dst, s->T0);tcg_gen_ext8s_tl (s->tmp0, s->T0);tcg_gen_sub_tl (cpu_cc_src, s->T0, s->tmp0);set_cc_op (s,CC_OP_MULB );break ;case MO_16 :gen_op_mov_v_reg (s,MO_16 , s->T1,R_EAX );tcg_gen_ext16s_tl (s->T0, s->T0);tcg_gen_ext16s_tl (s->T1, s->T1);/* XXX: use 32 bit mul which could be faster */ tcg_gen_mul_tl (s->T0, s->T0, s->T1);gen_op_mov_reg_v (s,MO_16 ,R_EAX , s->T0);tcg_gen_mov_tl (cpu_cc_dst, s->T0);tcg_gen_ext16s_tl (s->tmp0, s->T0);tcg_gen_sub_tl (cpu_cc_src, s->T0, s->tmp0);tcg_gen_shri_tl (s->T0, s->T0,16 );gen_op_mov_reg_v (s,MO_16 ,R_EDX , s->T0);set_cc_op (s,CC_OP_MULW );break ;default :case MO_32 :tcg_gen_trunc_tl_i32 (s->tmp2_i32, s->T0);tcg_gen_trunc_tl_i32 (s->tmp3_i32, cpu_regs[R_EAX ]);tcg_gen_muls2_i32 (s->tmp2_i32, s->tmp3_i32, s->tmp2_i32, s->tmp3_i32);tcg_gen_extu_i32_tl (cpu_regs[R_EAX ], s->tmp2_i32);tcg_gen_extu_i32_tl (cpu_regs[R_EDX ], s->tmp3_i32);tcg_gen_sari_i32 (s->tmp2_i32, s->tmp2_i32,31 );tcg_gen_mov_tl (cpu_cc_dst, cpu_regs[R_EAX ]);tcg_gen_sub_i32 (s->tmp2_i32, s->tmp2_i32, s->tmp3_i32);tcg_gen_extu_i32_tl (cpu_cc_src, s->tmp2_i32);set_cc_op (s,CC_OP_MULL );break ;#ifdef TARGET_X86_64 case MO_64 :tcg_gen_muls2_i64 (cpu_regs[R_EAX ], cpu_regs[R_EDX ], s->T0, cpu_regs[R_EAX ]);tcg_gen_mov_tl (cpu_cc_dst, cpu_regs[R_EAX ]);tcg_gen_sari_tl (cpu_cc_src, cpu_regs[R_EAX ],63 );tcg_gen_sub_tl (cpu_cc_src, cpu_cc_src, cpu_regs[R_EDX ]);set_cc_op (s,CC_OP_MULQ );break ;#endif }break ;case 6 :/* div */ switch (ot) {case MO_8 :gen_helper_divb_AL (tcg_env, s->T0);break ;case MO_16 :gen_helper_divw_AX (tcg_env, s->T0);break ;default :case MO_32 :gen_helper_divl_EAX (tcg_env, s->T0);break ;#ifdef TARGET_X86_64 case MO_64 :gen_helper_divq_EAX (tcg_env, s->T0);break ;#endif }break ;case 7 :/* idiv */ switch (ot) {case MO_8 :gen_helper_idivb_AL (tcg_env, s->T0);break ;case MO_16 :gen_helper_idivw_AX (tcg_env, s->T0);break ;default :case MO_32 :gen_helper_idivl_EAX (tcg_env, s->T0);break ;#ifdef TARGET_X86_64 case MO_64 :gen_helper_idivq_EAX (tcg_env, s->T0);break ;#endif }break ;default : goto unknown_op; }break ;case 0xfe :/* GRP4 */ case 0xff :/* GRP5 */ ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ; rm = (modrm &7 ) |REX_B (s); op = (modrm >>3 ) &7 ;if (op >=2 && b ==0xfe ) { goto unknown_op; }if (CODE64 (s)) {if (op ==2 || op ==4 ) {/* operand size for jumps is 64 bit */ ot =MO_64 ; }else if (op ==3 || op ==5 ) { ot = dflag !=MO_16 ?MO_32 +REX_W (s) :MO_16 ; }else if (op ==6 ) {/* default push size is 64 bit */ ot =mo_pushpop (s, dflag); } }if (mod !=3 ) {gen_lea_modrm (env, s, modrm);if (op >=2 && op !=3 && op !=5 )gen_op_ld_v (s, ot, s->T0, s->A0); }else {gen_op_mov_v_reg (s, ot, s->T0, rm); }switch (op) {case 0 :/* inc Ev */ if (mod !=3 ) opreg =OR_TMP0 ;else opreg = rm;gen_inc (s, ot, opreg,1 );break ;case 1 :/* dec Ev */ if (mod !=3 ) opreg =OR_TMP0 ;else opreg = rm;gen_inc (s, ot, opreg,-1 );break ;case 2 :/* call Ev */ /* XXX: optimize if memory (no 'and' is necessary) */ if (dflag ==MO_16 ) {tcg_gen_ext16u_tl (s->T0, s->T0); }gen_push_v (s,eip_next_tl (s));gen_op_jmp_v (s, s->T0);gen_bnd_jmp (s); s->base.is_jmp =DISAS_JUMP ;break ;case 3 :/* lcall Ev */ if (mod ==3 ) { goto illegal_op; }gen_op_ld_v (s, ot, s->T1, s->A0);gen_add_A0_im (s,1 << ot);gen_op_ld_v (s,MO_16 , s->T0, s->A0); do_lcall:if (PE (s) && !VM86 (s)) {tcg_gen_trunc_tl_i32 (s->tmp2_i32, s->T0);gen_helper_lcall_protected (tcg_env, s->tmp2_i32, s->T1,tcg_constant_i32 (dflag -1 ),eip_next_tl (s)); }else {tcg_gen_trunc_tl_i32 (s->tmp2_i32, s->T0);tcg_gen_trunc_tl_i32 (s->tmp3_i32, s->T1);gen_helper_lcall_real (tcg_env, s->tmp2_i32, s->tmp3_i32,tcg_constant_i32 (dflag -1 ),eip_next_i32 (s)); } s->base.is_jmp =DISAS_JUMP ;break ;case 4 :/* jmp Ev */ if (dflag ==MO_16 ) {tcg_gen_ext16u_tl (s->T0, s->T0); }gen_op_jmp_v (s, s->T0);gen_bnd_jmp (s); s->base.is_jmp =DISAS_JUMP ;break ;case 5 :/* ljmp Ev */ if (mod ==3 ) { goto illegal_op; }gen_op_ld_v (s, ot, s->T1, s->A0);gen_add_A0_im (s,1 << ot);gen_op_ld_v (s,MO_16 , s->T0, s->A0); do_ljmp:if (PE (s) && !VM86 (s)) {tcg_gen_trunc_tl_i32 (s->tmp2_i32, s->T0);gen_helper_ljmp_protected (tcg_env, s->tmp2_i32, s->T1,eip_next_tl (s)); }else {gen_op_movl_seg_T0_vm (s,R_CS );gen_op_jmp_v (s, s->T1); } s->base.is_jmp =DISAS_JUMP ;break ;case 6 :/* push Ev */ gen_push_v (s, s->T0);break ;default : goto unknown_op; }break ;case 0x84 :/* test Ev, Gv */ case 0x85 : ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s);gen_ldst_modrm (env, s, modrm, ot,OR_TMP0 ,0 );gen_op_mov_v_reg (s, ot, s->T1, reg);gen_op_testl_T0_T1_cc (s);set_cc_op (s,CC_OP_LOGICB + ot);break ;case 0xa8 :/* test eAX, Iv */ case 0xa9 : ot =mo_b_d (b, dflag); val =insn_get (env, s, ot);gen_op_mov_v_reg (s, ot, s->T0,OR_EAX );tcg_gen_movi_tl (s->T1, val);gen_op_testl_T0_T1_cc (s);set_cc_op (s,CC_OP_LOGICB + ot);break ;case 0x98 :/* CWDE/CBW */ switch (dflag) {#ifdef TARGET_X86_64 case MO_64 :gen_op_mov_v_reg (s,MO_32 , s->T0,R_EAX );tcg_gen_ext32s_tl (s->T0, s->T0);gen_op_mov_reg_v (s,MO_64 ,R_EAX , s->T0);break ;#endif case MO_32 :gen_op_mov_v_reg (s,MO_16 , s->T0,R_EAX );tcg_gen_ext16s_tl (s->T0, s->T0);gen_op_mov_reg_v (s,MO_32 ,R_EAX , s->T0);break ;case MO_16 :gen_op_mov_v_reg (s,MO_8 , s->T0,R_EAX );tcg_gen_ext8s_tl (s->T0, s->T0);gen_op_mov_reg_v (s,MO_16 ,R_EAX , s->T0);break ;default :g_assert_not_reached (); }break ;case 0x99 :/* CDQ/CWD */ switch (dflag) {#ifdef TARGET_X86_64 case MO_64 :gen_op_mov_v_reg (s,MO_64 , s->T0,R_EAX );tcg_gen_sari_tl (s->T0, s->T0,63 );gen_op_mov_reg_v (s,MO_64 ,R_EDX , s->T0);break ;#endif case MO_32 :gen_op_mov_v_reg (s,MO_32 , s->T0,R_EAX );tcg_gen_ext32s_tl (s->T0, s->T0);tcg_gen_sari_tl (s->T0, s->T0,31 );gen_op_mov_reg_v (s,MO_32 ,R_EDX , s->T0);break ;case MO_16 :gen_op_mov_v_reg (s,MO_16 , s->T0,R_EAX );tcg_gen_ext16s_tl (s->T0, s->T0);tcg_gen_sari_tl (s->T0, s->T0,15 );gen_op_mov_reg_v (s,MO_16 ,R_EDX , s->T0);break ;default :g_assert_not_reached (); }break ;case 0x1af :/* imul Gv, Ev */ case 0x69 :/* imul Gv, Ev, I */ case 0x6b : ot = dflag; modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s);if (b ==0x69 ) s->rip_offset =insn_const_size (ot);else if (b ==0x6b ) s->rip_offset =1 ;gen_ldst_modrm (env, s, modrm, ot,OR_TMP0 ,0 );if (b ==0x69 ) { val =insn_get (env, s, ot);tcg_gen_movi_tl (s->T1, val); }else if (b ==0x6b ) { val = (int8_t )insn_get (env, s,MO_8 );tcg_gen_movi_tl (s->T1, val); }else {gen_op_mov_v_reg (s, ot, s->T1, reg); }switch (ot) {#ifdef TARGET_X86_64 case MO_64 :tcg_gen_muls2_i64 (cpu_regs[reg], s->T1, s->T0, s->T1);tcg_gen_mov_tl (cpu_cc_dst, cpu_regs[reg]);tcg_gen_sari_tl (cpu_cc_src, cpu_cc_dst,63 );tcg_gen_sub_tl (cpu_cc_src, cpu_cc_src, s->T1);break ;#endif case MO_32 :tcg_gen_trunc_tl_i32 (s->tmp2_i32, s->T0);tcg_gen_trunc_tl_i32 (s->tmp3_i32, s->T1);tcg_gen_muls2_i32 (s->tmp2_i32, s->tmp3_i32, s->tmp2_i32, s->tmp3_i32);tcg_gen_extu_i32_tl (cpu_regs[reg], s->tmp2_i32);tcg_gen_sari_i32 (s->tmp2_i32, s->tmp2_i32,31 );tcg_gen_mov_tl (cpu_cc_dst, cpu_regs[reg]);tcg_gen_sub_i32 (s->tmp2_i32, s->tmp2_i32, s->tmp3_i32);tcg_gen_extu_i32_tl (cpu_cc_src, s->tmp2_i32);break ;default :tcg_gen_ext16s_tl (s->T0, s->T0);tcg_gen_ext16s_tl (s->T1, s->T1);/* XXX: use 32 bit mul which could be faster */ tcg_gen_mul_tl (s->T0, s->T0, s->T1);tcg_gen_mov_tl (cpu_cc_dst, s->T0);tcg_gen_ext16s_tl (s->tmp0, s->T0);tcg_gen_sub_tl (cpu_cc_src, s->T0, s->tmp0);gen_op_mov_reg_v (s, ot, reg, s->T0);break ; }set_cc_op (s,CC_OP_MULB + ot);break ;case 0x1c0 :case 0x1c1 :/* xadd Ev, Gv */ ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s); mod = (modrm >>6 ) &3 ;gen_op_mov_v_reg (s, ot, s->T0, reg);if (mod ==3 ) { rm = (modrm &7 ) |REX_B (s);gen_op_mov_v_reg (s, ot, s->T1, rm);tcg_gen_add_tl (s->T0, s->T0, s->T1);gen_op_mov_reg_v (s, ot, reg, s->T1);gen_op_mov_reg_v (s, ot, rm, s->T0); }else {gen_lea_modrm (env, s, modrm);if (s->prefix &PREFIX_LOCK ) {tcg_gen_atomic_fetch_add_tl (s->T1, s->A0, s->T0, s->mem_index, ot |MO_LE );tcg_gen_add_tl (s->T0, s->T0, s->T1); }else {gen_op_ld_v (s, ot, s->T1, s->A0);tcg_gen_add_tl (s->T0, s->T0, s->T1);gen_op_st_v (s, ot, s->T0, s->A0); }gen_op_mov_reg_v (s, ot, reg, s->T1); }gen_op_update2_cc (s);set_cc_op (s,CC_OP_ADDB + ot);break ;case 0x1b0 :case 0x1b1 :/* cmpxchg Ev, Gv */ {TCGv oldv, newv, cmpv, dest; ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s); mod = (modrm >>6 ) &3 ; oldv =tcg_temp_new (); newv =tcg_temp_new (); cmpv =tcg_temp_new ();gen_op_mov_v_reg (s, ot, newv, reg);tcg_gen_mov_tl (cmpv, cpu_regs[R_EAX ]);gen_extu (ot, cmpv);if (s->prefix &PREFIX_LOCK ) {if (mod ==3 ) { goto illegal_op; }gen_lea_modrm (env, s, modrm);tcg_gen_atomic_cmpxchg_tl (oldv, s->A0, cmpv, newv, s->mem_index, ot |MO_LE ); }else {if (mod ==3 ) { rm = (modrm &7 ) |REX_B (s);gen_op_mov_v_reg (s, ot, oldv, rm);gen_extu (ot, oldv);/* * Unlike the memory case, where "the destination operand receives * a write cycle without regard to the result of the comparison", * rm must not be touched altogether if the write fails, including * not zero-extending it on 64-bit processors. So, precompute * the result of a successful writeback and perform the movcond * directly on cpu_regs. Also need to write accumulator first, in * case rm is part of RAX too. */ dest =gen_op_deposit_reg_v (s, ot, rm, newv, newv);tcg_gen_movcond_tl (TCG_COND_EQ , dest, oldv, cmpv, newv, dest); }else {gen_lea_modrm (env, s, modrm);gen_op_ld_v (s, ot, oldv, s->A0);/* * Perform an unconditional store cycle like physical cpu; * must be before changing accumulator to ensure * idempotency if the store faults and the instruction * is restarted */ tcg_gen_movcond_tl (TCG_COND_EQ , newv, oldv, cmpv, newv, oldv);gen_op_st_v (s, ot, newv, s->A0); } }/* * Write EAX only if the cmpxchg fails; reuse newv as the destination, * since it's dead here. */ dest =gen_op_deposit_reg_v (s, ot,R_EAX , newv, oldv);tcg_gen_movcond_tl (TCG_COND_EQ , dest, oldv, cmpv, dest, newv);tcg_gen_mov_tl (cpu_cc_src, oldv);tcg_gen_mov_tl (s->cc_srcT, cmpv);tcg_gen_sub_tl (cpu_cc_dst, cmpv, oldv);set_cc_op (s,CC_OP_SUBB + ot); }break ;case 0x1c7 :/* cmpxchg8b */ modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ;switch ((modrm >>3 ) &7 ) {case 1 :/* CMPXCHG8, CMPXCHG16 */ if (mod ==3 ) { goto illegal_op; }#ifdef TARGET_X86_64 if (dflag ==MO_64 ) {if (!(s->cpuid_ext_features &CPUID_EXT_CX16 )) { goto illegal_op; }gen_cmpxchg16b (s, env, modrm);break ; }#endif if (!(s->cpuid_features &CPUID_CX8 )) { goto illegal_op; }gen_cmpxchg8b (s, env, modrm);break ;case 7 :/* RDSEED, RDPID with f3 prefix */ if (mod !=3 || (s->prefix & (PREFIX_LOCK |PREFIX_REPNZ ))) { goto illegal_op; }if (s->prefix &PREFIX_REPZ ) {if (!(s->cpuid_ext_features &CPUID_7_0_ECX_RDPID )) { goto illegal_op; }gen_helper_rdpid (s->T0, tcg_env); rm = (modrm &7 ) |REX_B (s);gen_op_mov_reg_v (s, dflag, rm, s->T0);break ; }else {if (!(s->cpuid_7_0_ebx_features &CPUID_7_0_EBX_RDSEED )) { goto illegal_op; } goto do_rdrand; }case 6 :/* RDRAND */ if (mod !=3 || (s->prefix & (PREFIX_LOCK |PREFIX_REPZ |PREFIX_REPNZ )) || !(s->cpuid_ext_features &CPUID_EXT_RDRAND )) { goto illegal_op; } do_rdrand:translator_io_start (&s->base);gen_helper_rdrand (s->T0, tcg_env); rm = (modrm &7 ) |REX_B (s);gen_op_mov_reg_v (s, dflag, rm, s->T0);set_cc_op (s,CC_OP_EFLAGS );break ;default : goto illegal_op; }break ;/**************************/ /* push/pop */ case 0x50 ... 0x57: /* push */gen_op_mov_v_reg (s,MO_32 , s->T0, (b &7 ) |REX_B (s));gen_push_v (s, s->T0);break ; case 0x58 ... 0x5f: /* pop */ ot =gen_pop_T0 (s);/* NOTE: order is important for pop %sp */ gen_pop_update (s, ot);gen_op_mov_reg_v (s, ot, (b &7 ) |REX_B (s), s->T0);break ;case 0x60 :/* pusha */ if (CODE64 (s)) goto illegal_op;gen_pusha (s);break ;case 0x61 :/* popa */ if (CODE64 (s)) goto illegal_op;gen_popa (s);break ;case 0x68 :/* push Iv */ case 0x6a : ot =mo_pushpop (s, dflag);if (b ==0x68 ) val =insn_get (env, s, ot);else val = (int8_t )insn_get (env, s,MO_8 );tcg_gen_movi_tl (s->T0, val);gen_push_v (s, s->T0);break ;case 0x8f :/* pop Ev */ modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ; ot =gen_pop_T0 (s);if (mod ==3 ) {/* NOTE: order is important for pop %sp */ gen_pop_update (s, ot); rm = (modrm &7 ) |REX_B (s);gen_op_mov_reg_v (s, ot, rm, s->T0); }else {/* NOTE: order is important too for MMU exceptions */ s->popl_esp_hack =1 << ot;gen_ldst_modrm (env, s, modrm, ot,OR_TMP0 ,1 ); s->popl_esp_hack =0 ;gen_pop_update (s, ot); }break ;case 0xc8 :/* enter */ {int level; val =x86_lduw_code (env, s); level =x86_ldub_code (env, s);gen_enter (s, val, level); }break ;case 0xc9 :/* leave */ gen_leave (s);break ;case 0x06 :/* push es */ case 0x0e :/* push cs */ case 0x16 :/* push ss */ case 0x1e :/* push ds */ if (CODE64 (s)) goto illegal_op;gen_op_movl_T0_seg (s, b >>3 );gen_push_v (s, s->T0);break ;case 0x1a0 :/* push fs */ case 0x1a8 :/* push gs */ gen_op_movl_T0_seg (s, (b >>3 ) &7 );gen_push_v (s, s->T0);break ;case 0x07 :/* pop es */ case 0x17 :/* pop ss */ case 0x1f :/* pop ds */ if (CODE64 (s)) goto illegal_op; reg = b >>3 ; ot =gen_pop_T0 (s);gen_movl_seg_T0 (s, reg);gen_pop_update (s, ot);break ;case 0x1a1 :/* pop fs */ case 0x1a9 :/* pop gs */ ot =gen_pop_T0 (s);gen_movl_seg_T0 (s, (b >>3 ) &7 );gen_pop_update (s, ot);break ;/**************************/ /* mov */ case 0x88 :case 0x89 :/* mov Gv, Ev */ ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s);/* generate a generic store */ gen_ldst_modrm (env, s, modrm, ot, reg,1 );break ;case 0xc6 :case 0xc7 :/* mov Ev, Iv */ ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ;if (mod !=3 ) { s->rip_offset =insn_const_size (ot);gen_lea_modrm (env, s, modrm); } val =insn_get (env, s, ot);tcg_gen_movi_tl (s->T0, val);if (mod !=3 ) {gen_op_st_v (s, ot, s->T0, s->A0); }else {gen_op_mov_reg_v (s, ot, (modrm &7 ) |REX_B (s), s->T0); }break ;case 0x8a :case 0x8b :/* mov Ev, Gv */ ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s);gen_ldst_modrm (env, s, modrm, ot,OR_TMP0 ,0 );gen_op_mov_reg_v (s, ot, reg, s->T0);break ;case 0x8e :/* mov seg, Gv */ modrm =x86_ldub_code (env, s); reg = (modrm >>3 ) &7 ;if (reg >=6 || reg ==R_CS ) goto illegal_op;gen_ldst_modrm (env, s, modrm,MO_16 ,OR_TMP0 ,0 );gen_movl_seg_T0 (s, reg);break ;case 0x8c :/* mov Gv, seg */ modrm =x86_ldub_code (env, s); reg = (modrm >>3 ) &7 ; mod = (modrm >>6 ) &3 ;if (reg >=6 ) goto illegal_op;gen_op_movl_T0_seg (s, reg); ot = mod ==3 ? dflag :MO_16 ;gen_ldst_modrm (env, s, modrm, ot,OR_TMP0 ,1 );break ;case 0x1b6 :/* movzbS Gv, Eb */ case 0x1b7 :/* movzwS Gv, Eb */ case 0x1be :/* movsbS Gv, Eb */ case 0x1bf :/* movswS Gv, Eb */ {MemOp d_ot;MemOp s_ot;/* d_ot is the size of destination */ d_ot = dflag;/* ot is the size of source */ ot = (b &1 ) +MO_8 ;/* s_ot is the sign+size of source */ s_ot = b &8 ?MO_SIGN | ot : ot; modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s); mod = (modrm >>6 ) &3 ; rm = (modrm &7 ) |REX_B (s);if (mod ==3 ) {if (s_ot ==MO_SB &&byte_reg_is_xH (s, rm)) {tcg_gen_sextract_tl (s->T0, cpu_regs[rm -4 ],8 ,8 ); }else {gen_op_mov_v_reg (s, ot, s->T0, rm);switch (s_ot) {case MO_UB :tcg_gen_ext8u_tl (s->T0, s->T0);break ;case MO_SB :tcg_gen_ext8s_tl (s->T0, s->T0);break ;case MO_UW :tcg_gen_ext16u_tl (s->T0, s->T0);break ;default :case MO_SW :tcg_gen_ext16s_tl (s->T0, s->T0);break ; } }gen_op_mov_reg_v (s, d_ot, reg, s->T0); }else {gen_lea_modrm (env, s, modrm);gen_op_ld_v (s, s_ot, s->T0, s->A0);gen_op_mov_reg_v (s, d_ot, reg, s->T0); } }break ;case 0x8d :/* lea */ modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ;if (mod ==3 ) goto illegal_op; reg = ((modrm >>3 ) &7 ) |REX_R (s); {AddressParts a =gen_lea_modrm_0 (env, s, modrm);TCGv ea =gen_lea_modrm_1 (s, a, false);gen_lea_v_seg (s, s->aflag, ea,-1 ,-1 );gen_op_mov_reg_v (s, dflag, reg, s->A0); }break ;case 0xa0 :/* mov EAX, Ov */ case 0xa1 :case 0xa2 :/* mov Ov, EAX */ case 0xa3 : {target_ulong offset_addr; ot =mo_b_d (b, dflag); offset_addr =insn_get_addr (env, s, s->aflag);tcg_gen_movi_tl (s->A0, offset_addr);gen_add_A0_ds_seg (s);if ((b &2 ) ==0 ) {gen_op_ld_v (s, ot, s->T0, s->A0);gen_op_mov_reg_v (s, ot,R_EAX , s->T0); }else {gen_op_mov_v_reg (s, ot, s->T0,R_EAX );gen_op_st_v (s, ot, s->T0, s->A0); } }break ;case 0xd7 :/* xlat */ tcg_gen_mov_tl (s->A0, cpu_regs[R_EBX ]);tcg_gen_ext8u_tl (s->T0, cpu_regs[R_EAX ]);tcg_gen_add_tl (s->A0, s->A0, s->T0);gen_extu (s->aflag, s->A0);gen_add_A0_ds_seg (s);gen_op_ld_v (s,MO_8 , s->T0, s->A0);gen_op_mov_reg_v (s,MO_8 ,R_EAX , s->T0);break ; case 0xb0 ... 0xb7: /* mov R, Ib */ val =insn_get (env, s,MO_8 );tcg_gen_movi_tl (s->T0, val);gen_op_mov_reg_v (s,MO_8 , (b &7 ) |REX_B (s), s->T0);break ; case 0xb8 ... 0xbf: /* mov R, Iv */#ifdef TARGET_X86_64 if (dflag ==MO_64 ) {uint64_t tmp;/* 64 bit case */ tmp =x86_ldq_code (env, s); reg = (b &7 ) |REX_B (s);tcg_gen_movi_tl (s->T0, tmp);gen_op_mov_reg_v (s,MO_64 , reg, s->T0); } else#endif { ot = dflag; val =insn_get (env, s, ot); reg = (b &7 ) |REX_B (s);tcg_gen_movi_tl (s->T0, val);gen_op_mov_reg_v (s, ot, reg, s->T0); }break ; case 0x91 ... 0x97: /* xchg R, EAX */ do_xchg_reg_eax: ot = dflag; reg = (b &7 ) |REX_B (s); rm =R_EAX ; goto do_xchg_reg;case 0x86 :case 0x87 :/* xchg Ev, Gv */ ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s); mod = (modrm >>6 ) &3 ;if (mod ==3 ) { rm = (modrm &7 ) |REX_B (s); do_xchg_reg:gen_op_mov_v_reg (s, ot, s->T0, reg);gen_op_mov_v_reg (s, ot, s->T1, rm);gen_op_mov_reg_v (s, ot, rm, s->T0);gen_op_mov_reg_v (s, ot, reg, s->T1); }else {gen_lea_modrm (env, s, modrm);gen_op_mov_v_reg (s, ot, s->T0, reg);/* for xchg, lock is implicit */ tcg_gen_atomic_xchg_tl (s->T1, s->A0, s->T0, s->mem_index, ot |MO_LE );gen_op_mov_reg_v (s, ot, reg, s->T1); }break ;case 0xc4 :/* les Gv */ /* In CODE64 this is VEX3; see above. */ op =R_ES ; goto do_lxx;case 0xc5 :/* lds Gv */ /* In CODE64 this is VEX2; see above. */ op =R_DS ; goto do_lxx;case 0x1b2 :/* lss Gv */ op =R_SS ; goto do_lxx;case 0x1b4 :/* lfs Gv */ op =R_FS ; goto do_lxx;case 0x1b5 :/* lgs Gv */ op =R_GS ; do_lxx: ot = dflag !=MO_16 ?MO_32 :MO_16 ; modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s); mod = (modrm >>6 ) &3 ;if (mod ==3 ) goto illegal_op;gen_lea_modrm (env, s, modrm);gen_op_ld_v (s, ot, s->T1, s->A0);gen_add_A0_im (s,1 << ot);/* load the segment first to handle exceptions properly */ gen_op_ld_v (s,MO_16 , s->T0, s->A0);gen_movl_seg_T0 (s, op);/* then put the data */ gen_op_mov_reg_v (s, ot, reg, s->T1);break ;/************************/ /* shifts */ case 0xc0 :case 0xc1 :/* shift Ev,Ib */ shift =2 ; grp2: { ot =mo_b_d (b, dflag); modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ; op = (modrm >>3 ) &7 ;if (mod !=3 ) {if (shift ==2 ) { s->rip_offset =1 ; }gen_lea_modrm (env, s, modrm); opreg =OR_TMP0 ; }else { opreg = (modrm &7 ) |REX_B (s); }/* simpler op */ if (shift ==0 ) {gen_shift (s, op, ot, opreg,OR_ECX ); }else {if (shift ==2 ) { shift =x86_ldub_code (env, s); }gen_shifti (s, op, ot, opreg, shift); } }break ;case 0xd0 :case 0xd1 :/* shift Ev,1 */ shift =1 ; goto grp2;case 0xd2 :case 0xd3 :/* shift Ev,cl */ shift =0 ; goto grp2;case 0x1a4 :/* shld imm */ op =0 ; shift =1 ; goto do_shiftd;case 0x1a5 :/* shld cl */ op =0 ; shift =0 ; goto do_shiftd;case 0x1ac :/* shrd imm */ op =1 ; shift =1 ; goto do_shiftd;case 0x1ad :/* shrd cl */ op =1 ; shift =0 ; do_shiftd: ot = dflag; modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ; rm = (modrm &7 ) |REX_B (s); reg = ((modrm >>3 ) &7 ) |REX_R (s);if (mod !=3 ) {gen_lea_modrm (env, s, modrm); opreg =OR_TMP0 ; }else { opreg = rm; }gen_op_mov_v_reg (s, ot, s->T1, reg);if (shift) {TCGv imm =tcg_constant_tl (x86_ldub_code (env, s));gen_shiftd_rm_T1 (s, ot, opreg, op, imm); }else {gen_shiftd_rm_T1 (s, ot, opreg, op, cpu_regs[R_ECX ]); }break ;/************************/ /* floats */ case 0xd8 ... 0xdf: {bool update_fip = true;if (s->flags & (HF_EM_MASK |HF_TS_MASK )) {/* if CR0.EM or CR0.TS are set, generate an FPU exception */ /* XXX: what to do if illegal op ? */ gen_exception (s,EXCP07_PREX );break ; } modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ; rm = modrm &7 ; op = ((b &7 ) <<3 ) | ((modrm >>3 ) &7 );if (mod !=3 ) {/* memory op */ AddressParts a =gen_lea_modrm_0 (env, s, modrm);TCGv ea =gen_lea_modrm_1 (s, a, false);TCGv last_addr =tcg_temp_new ();bool update_fdp = true;tcg_gen_mov_tl (last_addr, ea);gen_lea_v_seg (s, s->aflag, ea, a.def_seg, s->override);switch (op) { case 0x00 ... 0x07: /* fxxxs */ case 0x10 ... 0x17: /* fixxxl */ case 0x20 ... 0x27: /* fxxxl */ case 0x30 ... 0x37: /* fixxx */ {int op1; op1 = op &7 ;switch (op >>4 ) {case 0 :tcg_gen_qemu_ld_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUL );gen_helper_flds_FT0 (tcg_env, s->tmp2_i32);break ;case 1 :tcg_gen_qemu_ld_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUL );gen_helper_fildl_FT0 (tcg_env, s->tmp2_i32);break ;case 2 :tcg_gen_qemu_ld_i64 (s->tmp1_i64, s->A0, s->mem_index,MO_LEUQ );gen_helper_fldl_FT0 (tcg_env, s->tmp1_i64);break ;case 3 :default :tcg_gen_qemu_ld_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LESW );gen_helper_fildl_FT0 (tcg_env, s->tmp2_i32);break ; }gen_helper_fp_arith_ST0_FT0 (op1);if (op1 ==3 ) {/* fcomp needs pop */ gen_helper_fpop (tcg_env); } }break ;case 0x08 :/* flds */ case 0x0a :/* fsts */ case 0x0b :/* fstps */ case 0x18 ... 0x1b: /* fildl, fisttpl, fistl, fistpl */ case 0x28 ... 0x2b: /* fldl, fisttpll, fstl, fstpl */ case 0x38 ... 0x3b: /* filds, fisttps, fists, fistps */switch (op &7 ) {case 0 :switch (op >>4 ) {case 0 :tcg_gen_qemu_ld_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUL );gen_helper_flds_ST0 (tcg_env, s->tmp2_i32);break ;case 1 :tcg_gen_qemu_ld_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUL );gen_helper_fildl_ST0 (tcg_env, s->tmp2_i32);break ;case 2 :tcg_gen_qemu_ld_i64 (s->tmp1_i64, s->A0, s->mem_index,MO_LEUQ );gen_helper_fldl_ST0 (tcg_env, s->tmp1_i64);break ;case 3 :default :tcg_gen_qemu_ld_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LESW );gen_helper_fildl_ST0 (tcg_env, s->tmp2_i32);break ; }break ;case 1 :/* XXX: the corresponding CPUID bit must be tested ! */ switch (op >>4 ) {case 1 :gen_helper_fisttl_ST0 (s->tmp2_i32, tcg_env);tcg_gen_qemu_st_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUL );break ;case 2 :gen_helper_fisttll_ST0 (s->tmp1_i64, tcg_env);tcg_gen_qemu_st_i64 (s->tmp1_i64, s->A0, s->mem_index,MO_LEUQ );break ;case 3 :default :gen_helper_fistt_ST0 (s->tmp2_i32, tcg_env);tcg_gen_qemu_st_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUW );break ; }gen_helper_fpop (tcg_env);break ;default :switch (op >>4 ) {case 0 :gen_helper_fsts_ST0 (s->tmp2_i32, tcg_env);tcg_gen_qemu_st_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUL );break ;case 1 :gen_helper_fistl_ST0 (s->tmp2_i32, tcg_env);tcg_gen_qemu_st_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUL );break ;case 2 :gen_helper_fstl_ST0 (s->tmp1_i64, tcg_env);tcg_gen_qemu_st_i64 (s->tmp1_i64, s->A0, s->mem_index,MO_LEUQ );break ;case 3 :default :gen_helper_fist_ST0 (s->tmp2_i32, tcg_env);tcg_gen_qemu_st_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUW );break ; }if ((op &7 ) ==3 ) {gen_helper_fpop (tcg_env); }break ; }break ;case 0x0c :/* fldenv mem */ gen_helper_fldenv (tcg_env, s->A0,tcg_constant_i32 (dflag -1 )); update_fip = update_fdp = false;break ;case 0x0d :/* fldcw mem */ tcg_gen_qemu_ld_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUW );gen_helper_fldcw (tcg_env, s->tmp2_i32); update_fip = update_fdp = false;break ;case 0x0e :/* fnstenv mem */ gen_helper_fstenv (tcg_env, s->A0,tcg_constant_i32 (dflag -1 )); update_fip = update_fdp = false;break ;case 0x0f :/* fnstcw mem */ gen_helper_fnstcw (s->tmp2_i32, tcg_env);tcg_gen_qemu_st_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUW ); update_fip = update_fdp = false;break ;case 0x1d :/* fldt mem */ gen_helper_fldt_ST0 (tcg_env, s->A0);break ;case 0x1f :/* fstpt mem */ gen_helper_fstt_ST0 (tcg_env, s->A0);gen_helper_fpop (tcg_env);break ;case 0x2c :/* frstor mem */ gen_helper_frstor (tcg_env, s->A0,tcg_constant_i32 (dflag -1 )); update_fip = update_fdp = false;break ;case 0x2e :/* fnsave mem */ gen_helper_fsave (tcg_env, s->A0,tcg_constant_i32 (dflag -1 )); update_fip = update_fdp = false;break ;case 0x2f :/* fnstsw mem */ gen_helper_fnstsw (s->tmp2_i32, tcg_env);tcg_gen_qemu_st_i32 (s->tmp2_i32, s->A0, s->mem_index,MO_LEUW ); update_fip = update_fdp = false;break ;case 0x3c :/* fbld */ gen_helper_fbld_ST0 (tcg_env, s->A0);break ;case 0x3e :/* fbstp */ gen_helper_fbst_ST0 (tcg_env, s->A0);gen_helper_fpop (tcg_env);break ;case 0x3d :/* fildll */ tcg_gen_qemu_ld_i64 (s->tmp1_i64, s->A0, s->mem_index,MO_LEUQ );gen_helper_fildll_ST0 (tcg_env, s->tmp1_i64);break ;case 0x3f :/* fistpll */ gen_helper_fistll_ST0 (s->tmp1_i64, tcg_env);tcg_gen_qemu_st_i64 (s->tmp1_i64, s->A0, s->mem_index,MO_LEUQ );gen_helper_fpop (tcg_env);break ;default : goto unknown_op; }if (update_fdp) {int last_seg = s->override >=0 ? s->override : a.def_seg;tcg_gen_ld_i32 (s->tmp2_i32, tcg_env, offsetof(CPUX86State , segs[last_seg].selector));tcg_gen_st16_i32 (s->tmp2_i32, tcg_env, offsetof(CPUX86State , fpds));tcg_gen_st_tl (last_addr, tcg_env, offsetof(CPUX86State , fpdp)); } }else {/* register float ops */ opreg = rm;switch (op) {case 0x08 :/* fld sti */ gen_helper_fpush (tcg_env);gen_helper_fmov_ST0_STN (tcg_env,tcg_constant_i32 ((opreg +1 ) &7 ));break ;case 0x09 :/* fxchg sti */ case 0x29 :/* fxchg4 sti, undocumented op */ case 0x39 :/* fxchg7 sti, undocumented op */ gen_helper_fxchg_ST0_STN (tcg_env,tcg_constant_i32 (opreg));break ;case 0x0a :/* grp d9/2 */ switch (rm) {case 0 :/* fnop */ /* * check exceptions (FreeBSD FPU probe) * needs to be treated as I/O because of ferr_irq */ translator_io_start (&s->base);gen_helper_fwait (tcg_env); update_fip = false;break ;default : goto unknown_op; }break ;case 0x0c :/* grp d9/4 */ switch (rm) {case 0 :/* fchs */ gen_helper_fchs_ST0 (tcg_env);break ;case 1 :/* fabs */ gen_helper_fabs_ST0 (tcg_env);break ;case 4 :/* ftst */ gen_helper_fldz_FT0 (tcg_env);gen_helper_fcom_ST0_FT0 (tcg_env);break ;case 5 :/* fxam */ gen_helper_fxam_ST0 (tcg_env);break ;default : goto unknown_op; }break ;case 0x0d :/* grp d9/5 */ {switch (rm) {case 0 :gen_helper_fpush (tcg_env);gen_helper_fld1_ST0 (tcg_env);break ;case 1 :gen_helper_fpush (tcg_env);gen_helper_fldl2t_ST0 (tcg_env);break ;case 2 :gen_helper_fpush (tcg_env);gen_helper_fldl2e_ST0 (tcg_env);break ;case 3 :gen_helper_fpush (tcg_env);gen_helper_fldpi_ST0 (tcg_env);break ;case 4 :gen_helper_fpush (tcg_env);gen_helper_fldlg2_ST0 (tcg_env);break ;case 5 :gen_helper_fpush (tcg_env);gen_helper_fldln2_ST0 (tcg_env);break ;case 6 :gen_helper_fpush (tcg_env);gen_helper_fldz_ST0 (tcg_env);break ;default : goto unknown_op; } }break ;case 0x0e :/* grp d9/6 */ switch (rm) {case 0 :/* f2xm1 */ gen_helper_f2xm1 (tcg_env);break ;case 1 :/* fyl2x */ gen_helper_fyl2x (tcg_env);break ;case 2 :/* fptan */ gen_helper_fptan (tcg_env);break ;case 3 :/* fpatan */ gen_helper_fpatan (tcg_env);break ;case 4 :/* fxtract */ gen_helper_fxtract (tcg_env);break ;case 5 :/* fprem1 */ gen_helper_fprem1 (tcg_env);break ;case 6 :/* fdecstp */ gen_helper_fdecstp (tcg_env);break ;default :case 7 :/* fincstp */ gen_helper_fincstp (tcg_env);break ; }break ;case 0x0f :/* grp d9/7 */ switch (rm) {case 0 :/* fprem */ gen_helper_fprem (tcg_env);break ;case 1 :/* fyl2xp1 */ gen_helper_fyl2xp1 (tcg_env);break ;case 2 :/* fsqrt */ gen_helper_fsqrt (tcg_env);break ;case 3 :/* fsincos */ gen_helper_fsincos (tcg_env);break ;case 5 :/* fscale */ gen_helper_fscale (tcg_env);break ;case 4 :/* frndint */ gen_helper_frndint (tcg_env);break ;case 6 :/* fsin */ gen_helper_fsin (tcg_env);break ;default :case 7 :/* fcos */ gen_helper_fcos (tcg_env);break ; }break ; case 0x00: case 0x01: case 0x04 ... 0x07: /* fxxx st, sti */ case 0x20: case 0x21: case 0x24 ... 0x27: /* fxxx sti, st */ case 0x30: case 0x31: case 0x34 ... 0x37: /* fxxxp sti, st */ {int op1; op1 = op &7 ;if (op >=0x20 ) {gen_helper_fp_arith_STN_ST0 (op1, opreg);if (op >=0x30 ) {gen_helper_fpop (tcg_env); } }else {gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (opreg));gen_helper_fp_arith_ST0_FT0 (op1); } }break ;case 0x02 :/* fcom */ case 0x22 :/* fcom2, undocumented op */ gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (opreg));gen_helper_fcom_ST0_FT0 (tcg_env);break ;case 0x03 :/* fcomp */ case 0x23 :/* fcomp3, undocumented op */ case 0x32 :/* fcomp5, undocumented op */ gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (opreg));gen_helper_fcom_ST0_FT0 (tcg_env);gen_helper_fpop (tcg_env);break ;case 0x15 :/* da/5 */ switch (rm) {case 1 :/* fucompp */ gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (1 ));gen_helper_fucom_ST0_FT0 (tcg_env);gen_helper_fpop (tcg_env);gen_helper_fpop (tcg_env);break ;default : goto unknown_op; }break ;case 0x1c :switch (rm) {case 0 :/* feni (287 only, just do nop here) */ break ;case 1 :/* fdisi (287 only, just do nop here) */ break ;case 2 :/* fclex */ gen_helper_fclex (tcg_env); update_fip = false;break ;case 3 :/* fninit */ gen_helper_fninit (tcg_env); update_fip = false;break ;case 4 :/* fsetpm (287 only, just do nop here) */ break ;default : goto unknown_op; }break ;case 0x1d :/* fucomi */ if (!(s->cpuid_features &CPUID_CMOV )) { goto illegal_op; }gen_update_cc_op (s);gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (opreg));gen_helper_fucomi_ST0_FT0 (tcg_env);set_cc_op (s,CC_OP_EFLAGS );break ;case 0x1e :/* fcomi */ if (!(s->cpuid_features &CPUID_CMOV )) { goto illegal_op; }gen_update_cc_op (s);gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (opreg));gen_helper_fcomi_ST0_FT0 (tcg_env);set_cc_op (s,CC_OP_EFLAGS );break ;case 0x28 :/* ffree sti */ gen_helper_ffree_STN (tcg_env,tcg_constant_i32 (opreg));break ;case 0x2a :/* fst sti */ gen_helper_fmov_STN_ST0 (tcg_env,tcg_constant_i32 (opreg));break ;case 0x2b :/* fstp sti */ case 0x0b :/* fstp1 sti, undocumented op */ case 0x3a :/* fstp8 sti, undocumented op */ case 0x3b :/* fstp9 sti, undocumented op */ gen_helper_fmov_STN_ST0 (tcg_env,tcg_constant_i32 (opreg));gen_helper_fpop (tcg_env);break ;case 0x2c :/* fucom st(i) */ gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (opreg));gen_helper_fucom_ST0_FT0 (tcg_env);break ;case 0x2d :/* fucomp st(i) */ gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (opreg));gen_helper_fucom_ST0_FT0 (tcg_env);gen_helper_fpop (tcg_env);break ;case 0x33 :/* de/3 */ switch (rm) {case 1 :/* fcompp */ gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (1 ));gen_helper_fcom_ST0_FT0 (tcg_env);gen_helper_fpop (tcg_env);gen_helper_fpop (tcg_env);break ;default : goto unknown_op; }break ;case 0x38 :/* ffreep sti, undocumented op */ gen_helper_ffree_STN (tcg_env,tcg_constant_i32 (opreg));gen_helper_fpop (tcg_env);break ;case 0x3c :/* df/4 */ switch (rm) {case 0 :gen_helper_fnstsw (s->tmp2_i32, tcg_env);tcg_gen_extu_i32_tl (s->T0, s->tmp2_i32);gen_op_mov_reg_v (s,MO_16 ,R_EAX , s->T0);break ;default : goto unknown_op; }break ;case 0x3d :/* fucomip */ if (!(s->cpuid_features &CPUID_CMOV )) { goto illegal_op; }gen_update_cc_op (s);gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (opreg));gen_helper_fucomi_ST0_FT0 (tcg_env);gen_helper_fpop (tcg_env);set_cc_op (s,CC_OP_EFLAGS );break ;case 0x3e :/* fcomip */ if (!(s->cpuid_features &CPUID_CMOV )) { goto illegal_op; }gen_update_cc_op (s);gen_helper_fmov_FT0_STN (tcg_env,tcg_constant_i32 (opreg));gen_helper_fcomi_ST0_FT0 (tcg_env);gen_helper_fpop (tcg_env);set_cc_op (s,CC_OP_EFLAGS );break ; case 0x10 ... 0x13: /* fcmovxx */ case 0x18 ... 0x1b: {int op1;TCGLabel *l1;static const uint8_t fcmov_cc[8 ] = { (JCC_B <<1 ), (JCC_Z <<1 ), (JCC_BE <<1 ), (JCC_P <<1 ), };if (!(s->cpuid_features &CPUID_CMOV )) { goto illegal_op; } op1 = fcmov_cc[op &3 ] | (((op >>3 ) &1 ) ^1 ); l1 =gen_new_label ();gen_jcc1_noeob (s, op1, l1);gen_helper_fmov_ST0_STN (tcg_env,tcg_constant_i32 (opreg));gen_set_label (l1); }break ;default : goto unknown_op; } }if (update_fip) {tcg_gen_ld_i32 (s->tmp2_i32, tcg_env, offsetof(CPUX86State, segs[R_CS].selector));tcg_gen_st16_i32 (s->tmp2_i32, tcg_env, offsetof(CPUX86State , fpcs));tcg_gen_st_tl (eip_cur_tl (s), tcg_env, offsetof(CPUX86State , fpip)); } }break ;/************************/ /* string ops */ case 0xa4 :/* movsS */ case 0xa5 : ot =mo_b_d (b, dflag);if (prefixes & (PREFIX_REPZ |PREFIX_REPNZ )) {gen_repz_movs (s, ot); }else {gen_movs (s, ot); }break ;case 0xaa :/* stosS */ case 0xab : ot =mo_b_d (b, dflag);if (prefixes & (PREFIX_REPZ |PREFIX_REPNZ )) {gen_repz_stos (s, ot); }else {gen_stos (s, ot); }break ;case 0xac :/* lodsS */ case 0xad : ot =mo_b_d (b, dflag);if (prefixes & (PREFIX_REPZ |PREFIX_REPNZ )) {gen_repz_lods (s, ot); }else {gen_lods (s, ot); }break ;case 0xae :/* scasS */ case 0xaf : ot =mo_b_d (b, dflag);if (prefixes &PREFIX_REPNZ ) {gen_repz_scas (s, ot,1 ); }else if (prefixes &PREFIX_REPZ ) {gen_repz_scas (s, ot,0 ); }else {gen_scas (s, ot); }break ;case 0xa6 :/* cmpsS */ case 0xa7 : ot =mo_b_d (b, dflag);if (prefixes &PREFIX_REPNZ ) {gen_repz_cmps (s, ot,1 ); }else if (prefixes &PREFIX_REPZ ) {gen_repz_cmps (s, ot,0 ); }else {gen_cmps (s, ot); }break ;case 0x6c :/* insS */ case 0x6d : ot =mo_b_d32 (b, dflag);tcg_gen_trunc_tl_i32 (s->tmp2_i32, cpu_regs[R_EDX ]);tcg_gen_ext16u_i32 (s->tmp2_i32, s->tmp2_i32);if (!gen_check_io (s, ot, s->tmp2_i32,SVM_IOIO_TYPE_MASK |SVM_IOIO_STR_MASK )) {break ; }translator_io_start (&s->base);if (prefixes & (PREFIX_REPZ |PREFIX_REPNZ )) {gen_repz_ins (s, ot); }else {gen_ins (s, ot); }break ;case 0x6e :/* outsS */ case 0x6f : ot =mo_b_d32 (b, dflag);tcg_gen_trunc_tl_i32 (s->tmp2_i32, cpu_regs[R_EDX ]);tcg_gen_ext16u_i32 (s->tmp2_i32, s->tmp2_i32);if (!gen_check_io (s, ot, s->tmp2_i32,SVM_IOIO_STR_MASK )) {break ; }translator_io_start (&s->base);if (prefixes & (PREFIX_REPZ |PREFIX_REPNZ )) {gen_repz_outs (s, ot); }else {gen_outs (s, ot); }break ;/************************/ /* port I/O */ case 0xe4 :case 0xe5 : ot =mo_b_d32 (b, dflag); val =x86_ldub_code (env, s);tcg_gen_movi_i32 (s->tmp2_i32, val);if (!gen_check_io (s, ot, s->tmp2_i32,SVM_IOIO_TYPE_MASK )) {break ; }translator_io_start (&s->base);gen_helper_in_func (ot, s->T1, s->tmp2_i32);gen_op_mov_reg_v (s, ot,R_EAX , s->T1);gen_bpt_io (s, s->tmp2_i32, ot);break ;case 0xe6 :case 0xe7 : ot =mo_b_d32 (b, dflag); val =x86_ldub_code (env, s);tcg_gen_movi_i32 (s->tmp2_i32, val);if (!gen_check_io (s, ot, s->tmp2_i32,0 )) {break ; }translator_io_start (&s->base);gen_op_mov_v_reg (s, ot, s->T1,R_EAX );tcg_gen_trunc_tl_i32 (s->tmp3_i32, s->T1);gen_helper_out_func (ot, s->tmp2_i32, s->tmp3_i32);gen_bpt_io (s, s->tmp2_i32, ot);break ;case 0xec :case 0xed : ot =mo_b_d32 (b, dflag);tcg_gen_trunc_tl_i32 (s->tmp2_i32, cpu_regs[R_EDX ]);tcg_gen_ext16u_i32 (s->tmp2_i32, s->tmp2_i32);if (!gen_check_io (s, ot, s->tmp2_i32,SVM_IOIO_TYPE_MASK )) {break ; }translator_io_start (&s->base);gen_helper_in_func (ot, s->T1, s->tmp2_i32);gen_op_mov_reg_v (s, ot,R_EAX , s->T1);gen_bpt_io (s, s->tmp2_i32, ot);break ;case 0xee :case 0xef : ot =mo_b_d32 (b, dflag);tcg_gen_trunc_tl_i32 (s->tmp2_i32, cpu_regs[R_EDX ]);tcg_gen_ext16u_i32 (s->tmp2_i32, s->tmp2_i32);if (!gen_check_io (s, ot, s->tmp2_i32,0 )) {break ; }translator_io_start (&s->base);gen_op_mov_v_reg (s, ot, s->T1,R_EAX );tcg_gen_trunc_tl_i32 (s->tmp3_i32, s->T1);gen_helper_out_func (ot, s->tmp2_i32, s->tmp3_i32);gen_bpt_io (s, s->tmp2_i32, ot);break ;/************************/ /* control */ case 0xc2 :/* ret im */ val =x86_ldsw_code (env, s); ot =gen_pop_T0 (s);gen_stack_update (s, val + (1 << ot));/* Note that gen_pop_T0 uses a zero-extending load. */ gen_op_jmp_v (s, s->T0);gen_bnd_jmp (s); s->base.is_jmp =DISAS_JUMP ;break ;case 0xc3 :/* ret */ ot =gen_pop_T0 (s);gen_pop_update (s, ot);/* Note that gen_pop_T0 uses a zero-extending load. */ gen_op_jmp_v (s, s->T0);gen_bnd_jmp (s); s->base.is_jmp =DISAS_JUMP ;break ;case 0xca :/* lret im */ val =x86_ldsw_code (env, s); do_lret:if (PE (s) && !VM86 (s)) {gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_lret_protected (tcg_env,tcg_constant_i32 (dflag -1 ),tcg_constant_i32 (val)); }else {gen_stack_A0 (s);/* pop offset */ gen_op_ld_v (s, dflag, s->T0, s->A0);/* NOTE: keeping EIP updated is not a problem in case of exception */ gen_op_jmp_v (s, s->T0);/* pop selector */ gen_add_A0_im (s,1 << dflag);gen_op_ld_v (s, dflag, s->T0, s->A0);gen_op_movl_seg_T0_vm (s,R_CS );/* add stack offset */ gen_stack_update (s, val + (2 << dflag)); } s->base.is_jmp =DISAS_EOB_ONLY ;break ;case 0xcb :/* lret */ val =0 ; goto do_lret;case 0xcf :/* iret */ gen_svm_check_intercept (s,SVM_EXIT_IRET );if (!PE (s) ||VM86 (s)) {/* real mode or vm86 mode */ if (!check_vm86_iopl (s)) {break ; }gen_helper_iret_real (tcg_env,tcg_constant_i32 (dflag -1 )); }else {gen_helper_iret_protected (tcg_env,tcg_constant_i32 (dflag -1 ),eip_next_i32 (s)); }set_cc_op (s,CC_OP_EFLAGS ); s->base.is_jmp =DISAS_EOB_ONLY ;break ;case 0xe8 :/* call im */ {int diff = (dflag !=MO_16 ? (int32_t )insn_get (env, s,MO_32 ) : (int16_t )insn_get (env, s,MO_16 ));gen_push_v (s,eip_next_tl (s));gen_bnd_jmp (s);gen_jmp_rel (s, dflag, diff,0 ); }break ;case 0x9a :/* lcall im */ {unsigned int selector, offset;if (CODE64 (s)) goto illegal_op; ot = dflag; offset =insn_get (env, s, ot); selector =insn_get (env, s,MO_16 );tcg_gen_movi_tl (s->T0, selector);tcg_gen_movi_tl (s->T1, offset); } goto do_lcall;case 0xe9 :/* jmp im */ {int diff = (dflag !=MO_16 ? (int32_t )insn_get (env, s,MO_32 ) : (int16_t )insn_get (env, s,MO_16 ));gen_bnd_jmp (s);gen_jmp_rel (s, dflag, diff,0 ); }break ;case 0xea :/* ljmp im */ {unsigned int selector, offset;if (CODE64 (s)) goto illegal_op; ot = dflag; offset =insn_get (env, s, ot); selector =insn_get (env, s,MO_16 );tcg_gen_movi_tl (s->T0, selector);tcg_gen_movi_tl (s->T1, offset); } goto do_ljmp;case 0xeb :/* jmp Jb */ {int diff = (int8_t )insn_get (env, s,MO_8 );gen_jmp_rel (s, dflag, diff,0 ); }break ; case 0x70 ... 0x7f: /* jcc Jb */ {int diff = (int8_t )insn_get (env, s,MO_8 );gen_bnd_jmp (s);gen_jcc (s, b, diff); }break ; case 0x180 ... 0x18f: /* jcc Jv */ {int diff = (dflag !=MO_16 ? (int32_t )insn_get (env, s,MO_32 ) : (int16_t )insn_get (env, s,MO_16 ));gen_bnd_jmp (s);gen_jcc (s, b, diff); }break ; case 0x190 ... 0x19f: /* setcc Gv */ modrm =x86_ldub_code (env, s);gen_setcc1 (s, b, s->T0);gen_ldst_modrm (env, s, modrm,MO_8 ,OR_TMP0 ,1 );break ; case 0x140 ... 0x14f: /* cmov Gv, Ev */if (!(s->cpuid_features &CPUID_CMOV )) { goto illegal_op; } ot = dflag; modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s);gen_cmovcc1 (env, s, ot, b, modrm, reg);break ;/************************/ /* flags */ case 0x9c :/* pushf */ gen_svm_check_intercept (s,SVM_EXIT_PUSHF );if (check_vm86_iopl (s)) {gen_update_cc_op (s);gen_helper_read_eflags (s->T0, tcg_env);gen_push_v (s, s->T0); }break ;case 0x9d :/* popf */ gen_svm_check_intercept (s,SVM_EXIT_POPF );if (check_vm86_iopl (s)) {int mask =TF_MASK |AC_MASK |ID_MASK |NT_MASK ;if (CPL (s) ==0 ) { mask |=IF_MASK |IOPL_MASK ; }else if (CPL (s) <=IOPL (s)) { mask |=IF_MASK ; }if (dflag ==MO_16 ) { mask &=0xffff ; } ot =gen_pop_T0 (s);gen_helper_write_eflags (tcg_env, s->T0,tcg_constant_i32 (mask));gen_pop_update (s, ot);set_cc_op (s,CC_OP_EFLAGS );/* abort translation because TF/AC flag may change */ s->base.is_jmp =DISAS_EOB_NEXT ; }break ;case 0x9e :/* sahf */ if (CODE64 (s) && !(s->cpuid_ext3_features &CPUID_EXT3_LAHF_LM )) goto illegal_op;tcg_gen_shri_tl (s->T0, cpu_regs[R_EAX ],8 );gen_compute_eflags (s);tcg_gen_andi_tl (cpu_cc_src, cpu_cc_src,CC_O );tcg_gen_andi_tl (s->T0, s->T0,CC_S |CC_Z |CC_A |CC_P |CC_C );tcg_gen_or_tl (cpu_cc_src, cpu_cc_src, s->T0);break ;case 0x9f :/* lahf */ if (CODE64 (s) && !(s->cpuid_ext3_features &CPUID_EXT3_LAHF_LM )) goto illegal_op;gen_compute_eflags (s);/* Note: gen_compute_eflags() only gives the condition codes */ tcg_gen_ori_tl (s->T0, cpu_cc_src,0x02 );tcg_gen_deposit_tl (cpu_regs[R_EAX ], cpu_regs[R_EAX ], s->T0,8 ,8 );break ;case 0xf5 :/* cmc */ gen_compute_eflags (s);tcg_gen_xori_tl (cpu_cc_src, cpu_cc_src,CC_C );break ;case 0xf8 :/* clc */ gen_compute_eflags (s);tcg_gen_andi_tl (cpu_cc_src, cpu_cc_src, ~CC_C );break ;case 0xf9 :/* stc */ gen_compute_eflags (s);tcg_gen_ori_tl (cpu_cc_src, cpu_cc_src,CC_C );break ;case 0xfc :/* cld */ tcg_gen_movi_i32 (s->tmp2_i32,1 );tcg_gen_st_i32 (s->tmp2_i32, tcg_env, offsetof(CPUX86State , df));break ;case 0xfd :/* std */ tcg_gen_movi_i32 (s->tmp2_i32,-1 );tcg_gen_st_i32 (s->tmp2_i32, tcg_env, offsetof(CPUX86State , df));break ;/************************/ /* bit operations */ case 0x1ba :/* bt/bts/btr/btc Gv, im */ ot = dflag; modrm =x86_ldub_code (env, s); op = (modrm >>3 ) &7 ; mod = (modrm >>6 ) &3 ; rm = (modrm &7 ) |REX_B (s);if (mod !=3 ) { s->rip_offset =1 ;gen_lea_modrm (env, s, modrm);if (!(s->prefix &PREFIX_LOCK )) {gen_op_ld_v (s, ot, s->T0, s->A0); } }else {gen_op_mov_v_reg (s, ot, s->T0, rm); }/* load shift */ val =x86_ldub_code (env, s);tcg_gen_movi_tl (s->T1, val);if (op <4 ) goto unknown_op; op -=4 ; goto bt_op;case 0x1a3 :/* bt Gv, Ev */ op =0 ; goto do_btx;case 0x1ab :/* bts */ op =1 ; goto do_btx;case 0x1b3 :/* btr */ op =2 ; goto do_btx;case 0x1bb :/* btc */ op =3 ; do_btx: ot = dflag; modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s); mod = (modrm >>6 ) &3 ; rm = (modrm &7 ) |REX_B (s);gen_op_mov_v_reg (s,MO_32 , s->T1, reg);if (mod !=3 ) {AddressParts a =gen_lea_modrm_0 (env, s, modrm);/* specific case: we need to add a displacement */ gen_exts (ot, s->T1);tcg_gen_sari_tl (s->tmp0, s->T1,3 + ot);tcg_gen_shli_tl (s->tmp0, s->tmp0, ot);tcg_gen_add_tl (s->A0,gen_lea_modrm_1 (s, a, false), s->tmp0);gen_lea_v_seg (s, s->aflag, s->A0, a.def_seg, s->override);if (!(s->prefix &PREFIX_LOCK )) {gen_op_ld_v (s, ot, s->T0, s->A0); } }else {gen_op_mov_v_reg (s, ot, s->T0, rm); } bt_op:tcg_gen_andi_tl (s->T1, s->T1, (1 << (3 + ot)) -1 );tcg_gen_movi_tl (s->tmp0,1 );tcg_gen_shl_tl (s->tmp0, s->tmp0, s->T1);if (s->prefix &PREFIX_LOCK ) {switch (op) {case 0 :/* bt */ /* Needs no atomic ops; we suppressed the normal memory load for LOCK above so do it now. */ gen_op_ld_v (s, ot, s->T0, s->A0);break ;case 1 :/* bts */ tcg_gen_atomic_fetch_or_tl (s->T0, s->A0, s->tmp0, s->mem_index, ot |MO_LE );break ;case 2 :/* btr */ tcg_gen_not_tl (s->tmp0, s->tmp0);tcg_gen_atomic_fetch_and_tl (s->T0, s->A0, s->tmp0, s->mem_index, ot |MO_LE );break ;default :case 3 :/* btc */ tcg_gen_atomic_fetch_xor_tl (s->T0, s->A0, s->tmp0, s->mem_index, ot |MO_LE );break ; }tcg_gen_shr_tl (s->tmp4, s->T0, s->T1); }else {tcg_gen_shr_tl (s->tmp4, s->T0, s->T1);switch (op) {case 0 :/* bt */ /* Data already loaded; nothing to do. */ break ;case 1 :/* bts */ tcg_gen_or_tl (s->T0, s->T0, s->tmp0);break ;case 2 :/* btr */ tcg_gen_andc_tl (s->T0, s->T0, s->tmp0);break ;default :case 3 :/* btc */ tcg_gen_xor_tl (s->T0, s->T0, s->tmp0);break ; }if (op !=0 ) {if (mod !=3 ) {gen_op_st_v (s, ot, s->T0, s->A0); }else {gen_op_mov_reg_v (s, ot, rm, s->T0); } } }/* Delay all CC updates until after the store above. Note that C is the result of the test, Z is unchanged, and the others are all undefined. */ switch (s->cc_op) { case CC_OP_MULB ... CC_OP_MULQ: case CC_OP_ADDB ... CC_OP_ADDQ: case CC_OP_ADCB ... CC_OP_ADCQ: case CC_OP_SUBB ... CC_OP_SUBQ: case CC_OP_SBBB ... CC_OP_SBBQ: case CC_OP_LOGICB ... CC_OP_LOGICQ: case CC_OP_INCB ... CC_OP_INCQ: case CC_OP_DECB ... CC_OP_DECQ: case CC_OP_SHLB ... CC_OP_SHLQ: case CC_OP_SARB ... CC_OP_SARQ: case CC_OP_BMILGB ... CC_OP_BMILGQ:/* Z was going to be computed from the non-zero status of CC_DST. We can get that same Z value (and the new C value) by leaving CC_DST alone, setting CC_SRC, and using a CC_OP_SAR of the same width. */ tcg_gen_mov_tl (cpu_cc_src, s->tmp4);set_cc_op (s, ((s->cc_op -CC_OP_MULB ) &3 ) +CC_OP_SARB );break ;default :/* Otherwise, generate EFLAGS and replace the C bit. */ gen_compute_eflags (s);tcg_gen_deposit_tl (cpu_cc_src, cpu_cc_src, s->tmp4,ctz32 (CC_C ),1 );break ; }break ;case 0x1bc :/* bsf / tzcnt */ case 0x1bd :/* bsr / lzcnt */ ot = dflag; modrm =x86_ldub_code (env, s); reg = ((modrm >>3 ) &7 ) |REX_R (s);gen_ldst_modrm (env, s, modrm, ot,OR_TMP0 ,0 );gen_extu (ot, s->T0);/* Note that lzcnt and tzcnt are in different extensions. */ if ((prefixes &PREFIX_REPZ ) && (b &1 ? s->cpuid_ext3_features &CPUID_EXT3_ABM : s->cpuid_7_0_ebx_features &CPUID_7_0_EBX_BMI1 )) {int size =8 << ot;/* For lzcnt/tzcnt, C bit is defined related to the input. */ tcg_gen_mov_tl (cpu_cc_src, s->T0);if (b &1 ) {/* For lzcnt, reduce the target_ulong result by the number of zeros that we expect to find at the top. */ tcg_gen_clzi_tl (s->T0, s->T0,TARGET_LONG_BITS );tcg_gen_subi_tl (s->T0, s->T0,TARGET_LONG_BITS - size); }else {/* For tzcnt, a zero input must return the operand size. */ tcg_gen_ctzi_tl (s->T0, s->T0, size); }/* For lzcnt/tzcnt, Z bit is defined related to the result. */ gen_op_update1_cc (s);set_cc_op (s,CC_OP_BMILGB + ot); }else {/* For bsr/bsf, only the Z bit is defined and it is related to the input and not the result. */ tcg_gen_mov_tl (cpu_cc_dst, s->T0);set_cc_op (s,CC_OP_LOGICB + ot);/* ??? The manual says that the output is undefined when the input is zero, but real hardware leaves it unchanged, and real programs appear to depend on that. Accomplish this by passing the output as the value to return upon zero. */ if (b &1 ) {/* For bsr, return the bit index of the first 1 bit, not the count of leading zeros. */ tcg_gen_xori_tl (s->T1, cpu_regs[reg],TARGET_LONG_BITS -1 );tcg_gen_clz_tl (s->T0, s->T0, s->T1);tcg_gen_xori_tl (s->T0, s->T0,TARGET_LONG_BITS -1 ); }else {tcg_gen_ctz_tl (s->T0, s->T0, cpu_regs[reg]); } }gen_op_mov_reg_v (s, ot, reg, s->T0);break ;/************************/ /* bcd */ case 0x27 :/* daa */ if (CODE64 (s)) goto illegal_op;gen_update_cc_op (s);gen_helper_daa (tcg_env);set_cc_op (s,CC_OP_EFLAGS );break ;case 0x2f :/* das */ if (CODE64 (s)) goto illegal_op;gen_update_cc_op (s);gen_helper_das (tcg_env);set_cc_op (s,CC_OP_EFLAGS );break ;case 0x37 :/* aaa */ if (CODE64 (s)) goto illegal_op;gen_update_cc_op (s);gen_helper_aaa (tcg_env);set_cc_op (s,CC_OP_EFLAGS );break ;case 0x3f :/* aas */ if (CODE64 (s)) goto illegal_op;gen_update_cc_op (s);gen_helper_aas (tcg_env);set_cc_op (s,CC_OP_EFLAGS );break ;case 0xd4 :/* aam */ if (CODE64 (s)) goto illegal_op; val =x86_ldub_code (env, s);if (val ==0 ) {gen_exception (s,EXCP00_DIVZ ); }else {gen_helper_aam (tcg_env,tcg_constant_i32 (val));set_cc_op (s,CC_OP_LOGICB ); }break ;case 0xd5 :/* aad */ if (CODE64 (s)) goto illegal_op; val =x86_ldub_code (env, s);gen_helper_aad (tcg_env,tcg_constant_i32 (val));set_cc_op (s,CC_OP_LOGICB );break ;/************************/ /* misc */ case 0x90 :/* nop */ /* XXX: correct lock test for all insn */ if (prefixes &PREFIX_LOCK ) { goto illegal_op; }/* If REX_B is set, then this is xchg eax, r8d, not a nop. */ if (REX_B (s)) { goto do_xchg_reg_eax; }if (prefixes &PREFIX_REPZ ) {gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_pause (tcg_env,cur_insn_len_i32 (s)); s->base.is_jmp =DISAS_NORETURN ; }break ;case 0x9b :/* fwait */ if ((s->flags & (HF_MP_MASK |HF_TS_MASK )) == (HF_MP_MASK |HF_TS_MASK )) {gen_exception (s,EXCP07_PREX ); }else {/* needs to be treated as I/O because of ferr_irq */ translator_io_start (&s->base);gen_helper_fwait (tcg_env); }break ;case 0xcc :/* int3 */ gen_interrupt (s,EXCP03_INT3 );break ;case 0xcd :/* int N */ val =x86_ldub_code (env, s);if (check_vm86_iopl (s)) {gen_interrupt (s, val); }break ;case 0xce :/* into */ if (CODE64 (s)) goto illegal_op;gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_into (tcg_env,cur_insn_len_i32 (s));break ;#ifdef WANT_ICEBP case 0xf1 :/* icebp (undocumented, exits to external debugger) */ gen_svm_check_intercept (s,SVM_EXIT_ICEBP );gen_debug (s);break ;#endif case 0xfa :/* cli */ if (check_iopl (s)) {gen_reset_eflags (s,IF_MASK ); }break ;case 0xfb :/* sti */ if (check_iopl (s)) {gen_set_eflags (s,IF_MASK );/* interruptions are enabled only the first insn after sti */ gen_update_eip_next (s);gen_eob_inhibit_irq (s, true); }break ;case 0x62 :/* bound */ if (CODE64 (s)) goto illegal_op; ot = dflag; modrm =x86_ldub_code (env, s); reg = (modrm >>3 ) &7 ; mod = (modrm >>6 ) &3 ;if (mod ==3 ) goto illegal_op;gen_op_mov_v_reg (s, ot, s->T0, reg);gen_lea_modrm (env, s, modrm);tcg_gen_trunc_tl_i32 (s->tmp2_i32, s->T0);if (ot ==MO_16 ) {gen_helper_boundw (tcg_env, s->A0, s->tmp2_i32); }else {gen_helper_boundl (tcg_env, s->A0, s->tmp2_i32); }break ; case 0x1c8 ... 0x1cf: /* bswap reg */ reg = (b &7 ) |REX_B (s);#ifdef TARGET_X86_64 if (dflag ==MO_64 ) {tcg_gen_bswap64_i64 (cpu_regs[reg], cpu_regs[reg]);break ; }#endif tcg_gen_bswap32_tl (cpu_regs[reg], cpu_regs[reg],TCG_BSWAP_OZ );break ;case 0xd6 :/* salc */ if (CODE64 (s)) goto illegal_op;gen_compute_eflags_c (s, s->T0);tcg_gen_neg_tl (s->T0, s->T0);gen_op_mov_reg_v (s,MO_8 ,R_EAX , s->T0);break ;case 0xe0 :/* loopnz */ case 0xe1 :/* loopz */ case 0xe2 :/* loop */ case 0xe3 :/* jecxz */ {TCGLabel *l1, *l2;int diff = (int8_t )insn_get (env, s,MO_8 ); l1 =gen_new_label (); l2 =gen_new_label ();gen_update_cc_op (s); b &=3 ;switch (b) {case 0 :/* loopnz */ case 1 :/* loopz */ gen_op_add_reg_im (s, s->aflag,R_ECX ,-1 );gen_op_jz_ecx (s, l2);gen_jcc1 (s, (JCC_Z <<1 ) | (b ^1 ), l1);break ;case 2 :/* loop */ gen_op_add_reg_im (s, s->aflag,R_ECX ,-1 );gen_op_jnz_ecx (s, l1);break ;default :case 3 :/* jcxz */ gen_op_jz_ecx (s, l1);break ; }gen_set_label (l2);gen_jmp_rel_csize (s,0 ,1 );gen_set_label (l1);gen_jmp_rel (s, dflag, diff,0 ); }break ;case 0x130 :/* wrmsr */ case 0x132 :/* rdmsr */ if (check_cpl0 (s)) {gen_update_cc_op (s);gen_update_eip_cur (s);if (b &2 ) {gen_helper_rdmsr (tcg_env); }else {gen_helper_wrmsr (tcg_env); s->base.is_jmp =DISAS_EOB_NEXT ; } }break ;case 0x131 :/* rdtsc */ gen_update_cc_op (s);gen_update_eip_cur (s);translator_io_start (&s->base);gen_helper_rdtsc (tcg_env);break ;case 0x133 :/* rdpmc */ gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_rdpmc (tcg_env); s->base.is_jmp =DISAS_NORETURN ;break ;case 0x134 :/* sysenter */ /* For AMD SYSENTER is not valid in long mode */ if (LMA (s) && env->cpuid_vendor1 !=CPUID_VENDOR_INTEL_1 ) { goto illegal_op; }if (!PE (s)) {gen_exception_gpf (s); }else {gen_helper_sysenter (tcg_env); s->base.is_jmp =DISAS_EOB_ONLY ; }break ;case 0x135 :/* sysexit */ /* For AMD SYSEXIT is not valid in long mode */ if (LMA (s) && env->cpuid_vendor1 !=CPUID_VENDOR_INTEL_1 ) { goto illegal_op; }if (!PE (s) ||CPL (s) !=0 ) {gen_exception_gpf (s); }else {gen_helper_sysexit (tcg_env,tcg_constant_i32 (dflag -1 )); s->base.is_jmp =DISAS_EOB_ONLY ; }break ;case 0x105 :/* syscall */ /* For Intel SYSCALL is only valid in long mode */ if (!LMA (s) && env->cpuid_vendor1 ==CPUID_VENDOR_INTEL_1 ) { goto illegal_op; }gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_syscall (tcg_env,cur_insn_len_i32 (s));/* TF handling for the syscall insn is different. The TF bit is checked after the syscall insn completes. This allows #DB to not be generated after one has entered CPL0 if TF is set in FMASK. */ gen_eob_worker (s, false, true);break ;case 0x107 :/* sysret */ /* For Intel SYSRET is only valid in long mode */ if (!LMA (s) && env->cpuid_vendor1 ==CPUID_VENDOR_INTEL_1 ) { goto illegal_op; }if (!PE (s) ||CPL (s) !=0 ) {gen_exception_gpf (s); }else {gen_helper_sysret (tcg_env,tcg_constant_i32 (dflag -1 ));/* condition codes are modified only in long mode */ if (LMA (s)) {set_cc_op (s,CC_OP_EFLAGS ); }/* TF handling for the sysret insn is different. The TF bit is checked after the sysret insn completes. This allows #DB to be generated "as if" the syscall insn in userspace has just completed. */ gen_eob_worker (s, false, true); }break ;case 0x1a2 :/* cpuid */ gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_cpuid (tcg_env);break ;case 0xf4 :/* hlt */ if (check_cpl0 (s)) {gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_hlt (tcg_env,cur_insn_len_i32 (s)); s->base.is_jmp =DISAS_NORETURN ; }break ;case 0x100 : modrm =x86_ldub_code (env, s); mod = (modrm >>6 ) &3 ; op = (modrm >>3 ) &7 ;switch (op) {case 0 :/* sldt */ if (!PE (s) ||VM86 (s)) goto illegal_op;if (s->flags &HF_UMIP_MASK && !check_cpl0 (s)) {break ; }gen_svm_check_intercept (s,SVM_EXIT_LDTR_READ );tcg_gen_ld32u_tl (s->T0, tcg_env, offsetof(CPUX86State, ldt.selector)); ot = mod ==3 ? dflag :MO_16 ;gen_ldst_modrm (env, s, modrm, ot,OR_TMP0 ,1 );break ;case 2 :/* lldt */ if (!PE (s) ||VM86 (s)) goto illegal_op;if (check_cpl0 (s)) {gen_svm_check_intercept (s,SVM_EXIT_LDTR_WRITE );gen_ldst_modrm (env, s, modrm,MO_16 ,OR_TMP0 ,0 );tcg_gen_trunc_tl_i32 (s->tmp2_i32, s->T0);gen_helper_lldt (tcg_env, s->tmp2_i32); }break ;case 1 :/* str */ if (!PE (s) ||VM86 (s)) goto illegal_op;if (s->flags &HF_UMIP_MASK && !check_cpl0 (s)) {break ; }gen_svm_check_intercept (s,SVM_EXIT_TR_READ );tcg_gen_ld32u_tl (s->T0, tcg_env, offsetof(CPUX86State, tr.selector)); ot = mod ==3 ? dflag :MO_16 ;gen_ldst_modrm (env, s, modrm, ot,OR_TMP0 ,1 );break ;case 3 :/* ltr */ if (!PE (s) ||VM86 (s)) goto illegal_op;if (check_cpl0 (s)) {gen_svm_check_intercept (s,SVM_EXIT_TR_WRITE );gen_ldst_modrm (env, s, modrm,MO_16 ,OR_TMP0 ,0 );tcg_gen_trunc_tl_i32 (s->tmp2_i32, s->T0);gen_helper_ltr (tcg_env, s->tmp2_i32); }break ;case 4 :/* verr */ case 5 :/* verw */ if (!PE (s) ||VM86 (s)) goto illegal_op;gen_ldst_modrm (env, s, modrm,MO_16 ,OR_TMP0 ,0 );gen_update_cc_op (s);if (op ==4 ) {gen_helper_verr (tcg_env, s->T0); }else {gen_helper_verw (tcg_env, s->T0); }set_cc_op (s,CC_OP_EFLAGS );break ;default : goto unknown_op; }break ;case 0x101 : modrm =x86_ldub_code (env, s);switch (modrm) { CASE_MODRM_MEM_OP(0): /* sgdt */if (s->flags &HF_UMIP_MASK && !check_cpl0 (s)) {break ; }gen_svm_check_intercept (s,SVM_EXIT_GDTR_READ );gen_lea_modrm (env, s, modrm);tcg_gen_ld32u_tl (s->T0, tcg_env, offsetof(CPUX86State, gdt.limit));gen_op_st_v (s,MO_16 , s->T0, s->A0);gen_add_A0_im (s,2 ); tcg_gen_ld_tl(s->T0, tcg_env, offsetof(CPUX86State, gdt.base));if (dflag ==MO_16 ) {tcg_gen_andi_tl (s->T0, s->T0,0xffffff ); }gen_op_st_v (s,CODE64 (s) +MO_32 , s->T0, s->A0);break ;case 0xc8 :/* monitor */ if (!(s->cpuid_ext_features &CPUID_EXT_MONITOR ) ||CPL (s) !=0 ) { goto illegal_op; }gen_update_cc_op (s);gen_update_eip_cur (s);tcg_gen_mov_tl (s->A0, cpu_regs[R_EAX ]);gen_extu (s->aflag, s->A0);gen_add_A0_ds_seg (s);gen_helper_monitor (tcg_env, s->A0);break ;case 0xc9 :/* mwait */ if (!(s->cpuid_ext_features &CPUID_EXT_MONITOR ) ||CPL (s) !=0 ) { goto illegal_op; }gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_mwait (tcg_env,cur_insn_len_i32 (s)); s->base.is_jmp =DISAS_NORETURN ;break ;case 0xca :/* clac */ if (!(s->cpuid_7_0_ebx_features &CPUID_7_0_EBX_SMAP ) ||CPL (s) !=0 ) { goto illegal_op; }gen_reset_eflags (s,AC_MASK ); s->base.is_jmp =DISAS_EOB_NEXT ;break ;case 0xcb :/* stac */ if (!(s->cpuid_7_0_ebx_features &CPUID_7_0_EBX_SMAP ) ||CPL (s) !=0 ) { goto illegal_op; }gen_set_eflags (s,AC_MASK ); s->base.is_jmp =DISAS_EOB_NEXT ;break ; CASE_MODRM_MEM_OP(1): /* sidt */if (s->flags &HF_UMIP_MASK && !check_cpl0 (s)) {break ; }gen_svm_check_intercept (s,SVM_EXIT_IDTR_READ );gen_lea_modrm (env, s, modrm); tcg_gen_ld32u_tl(s->T0, tcg_env, offsetof(CPUX86State, idt.limit));gen_op_st_v (s,MO_16 , s->T0, s->A0);gen_add_A0_im (s,2 ); tcg_gen_ld_tl(s->T0, tcg_env, offsetof(CPUX86State, idt.base));if (dflag ==MO_16 ) {tcg_gen_andi_tl (s->T0, s->T0,0xffffff ); }gen_op_st_v (s,CODE64 (s) +MO_32 , s->T0, s->A0);break ;case 0xd0 :/* xgetbv */ if ((s->cpuid_ext_features &CPUID_EXT_XSAVE ) ==0 || (s->prefix & (PREFIX_LOCK |PREFIX_DATA |PREFIX_REPZ |PREFIX_REPNZ ))) { goto illegal_op; }tcg_gen_trunc_tl_i32 (s->tmp2_i32, cpu_regs[R_ECX ]);gen_helper_xgetbv (s->tmp1_i64, tcg_env, s->tmp2_i32);tcg_gen_extr_i64_tl (cpu_regs[R_EAX ], cpu_regs[R_EDX ], s->tmp1_i64);break ;case 0xd1 :/* xsetbv */ if ((s->cpuid_ext_features &CPUID_EXT_XSAVE ) ==0 || (s->prefix & (PREFIX_LOCK |PREFIX_DATA |PREFIX_REPZ |PREFIX_REPNZ ))) { goto illegal_op; }if (!check_cpl0 (s)) {break ; }tcg_gen_concat_tl_i64 (s->tmp1_i64, cpu_regs[R_EAX ], cpu_regs[R_EDX ]);tcg_gen_trunc_tl_i32 (s->tmp2_i32, cpu_regs[R_ECX ]);gen_helper_xsetbv (tcg_env, s->tmp2_i32, s->tmp1_i64);/* End TB because translation flags may change. */ s->base.is_jmp =DISAS_EOB_NEXT ;break ;case 0xd8 :/* VMRUN */ if (!SVME (s) || !PE (s)) { goto illegal_op; }if (!check_cpl0 (s)) {break ; }gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_vmrun (tcg_env,tcg_constant_i32 (s->aflag -1 ),cur_insn_len_i32 (s));tcg_gen_exit_tb (NULL ,0 ); s->base.is_jmp =DISAS_NORETURN ;break ;case 0xd9 :/* VMMCALL */ if (!SVME (s)) { goto illegal_op; }gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_vmmcall (tcg_env);break ;case 0xda :/* VMLOAD */ if (!SVME (s) || !PE (s)) { goto illegal_op; }if (!check_cpl0 (s)) {break ; }gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_vmload (tcg_env,tcg_constant_i32 (s->aflag -1 ));break ;case 0xdb :/* VMSAVE */ if (!SVME (s) || !PE (s)) { goto illegal_op; }if (!check_cpl0 (s)) {break ; }gen_update_cc_op (s);gen_update_eip_cur (s);gen_helper_vmsave (tcg_env,tcg_constant_i32 (s->aflag -1 ));break ;case 0xdc :/* STGI */ if ((!SVME (s) && !(s->cpuid_ext3_features &CPUID_EXT3_SKINIT )) || !PE (s)) { goto illegal_op; }if (!check_cpl0 (s)) {break ; }gen_update_cc_op (s);gen_helper_stgi (tcg_env); s->base.is_jmp =DISAS_EOB_NEXT ;break ;case 0xdd :/* CLGI */ if (!SVME (s) || !PE (s)) {
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.2
Part of the diff is not shown here. View the raw message.
RFC PATCH 7/78 hw/virtio/virtio-balloon.c: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- hw/virtio/virtio-balloon.c | 1 + 1 file changed, 1 insertion(+)
hw/virtio/virtio-balloon.c +1 -0
@@ -636,56 +636,57 @@ static int virtio_balloon_free_page_hint_notify(NotifierWithReturn *n, void *data) {VirtIOBalloon *dev =container_of (n, VirtIOBalloon, free_page_hint_notify);VirtIODevice *vdev =VIRTIO_DEVICE (dev);PrecopyNotifyData *pnd = data;if (!virtio_balloon_free_page_support (dev)) {/* * This is an optimization provided to migration, so just return 0 to * have the normal migration process not affected when this feature is * not supported. */ return 0 ; }/* * Pages hinted via qemu_guest_free_page_hint() are cleared from the dirty * bitmap and will not get migrated, especially also not when the postcopy * destination starts using them and requests migration from the source; the * faulting thread will stall until postcopy migration finishes and * all threads are woken up. Let's not start free page hinting if postcopy * is possible. */ if (migrate_postcopy_ram ()) {return 0 ; }switch (pnd->reason) {case PRECOPY_NOTIFY_BEFORE_BITMAP_SYNC :virtio_balloon_free_page_stop (dev);break ;case PRECOPY_NOTIFY_AFTER_BITMAP_SYNC :if (vdev->vm_running) {virtio_balloon_free_page_start (dev);break ; }/* * Set S_DONE before migrating the vmstate, so the guest will reuse * all hinted pages once running on the destination. Fall through. */ + fallthrough;case PRECOPY_NOTIFY_CLEANUP :/* * Especially, if something goes wrong during precopy or if migration * is canceled, we have to properly communicate S_DONE to the VM. */ virtio_balloon_free_page_done (dev);break ;case PRECOPY_NOTIFY_SETUP :case PRECOPY_NOTIFY_COMPLETE :break ;default :virtio_error (vdev,"%s: %d reason unknown" , __func__, pnd->reason); }return 0 ; }
Signature · 1 line
2.39.2
Re: [RFC PATCH 07/78] hw/virtio/virtio-balloon.c: add fallthrough pseudo-keyword
Quoted 5 lines · Emmanouil Pitsidianakis
In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
Signed-off-by Emmanouil Pitsidianakis <[email protected]>---
Signature · 3 lines
Cheers, David / dhildenb
RFC PATCH 8/78 hw/block: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- hw/block/dataplane/xen-block.c | 4 ++-- hw/block/m25p80.c | 2 +- hw/block/onenand.c | 2 +- hw/block/pflash_cfi01.c | 1 + hw/block/pflash_cfi02.c | 6 ++++-- 5 files changed, 9 insertions(+), 6 deletions(-)
hw/block/dataplane/xen-block.c +2 -2
@@ -144,59 +144,59 @@ static void xen_block_complete_request(XenBlockRequest *request)/* * translate request into iovec + start offset * do sanity checks along the way */ static int xen_block_parse_request (XenBlockRequest *request) {XenBlockDataPlane *dataplane = request->dataplane;size_t len;int i;switch (request->req.operation) {case BLKIF_OP_READ :break ;case BLKIF_OP_FLUSH_DISKCACHE : request->presync =1 ;if (!request->req.nr_segments) {return 0 ; } -/* fall through */ + fallthrough;case BLKIF_OP_WRITE :break ;case BLKIF_OP_DISCARD :return 0 ;default :error_report ("error: unknown operation (%d)" , request->req.operation); goto err; };if (request->req.operation !=BLKIF_OP_READ && !blk_is_writable (dataplane->blk)) {error_report ("error: write req for ro device" ); goto err; } request->start = request->req.sector_number * dataplane->sector_size;for (i =0 ; i < request->req.nr_segments; i++) {if (i ==BLKIF_MAX_SEGMENTS_PER_REQUEST ) {error_report ("error: nr_segments too big" ); goto err; }if (request->req.seg[i].first_sect > request->req.seg[i].last_sect) {error_report ("error: first > last sector" ); goto err; }if (request->req.seg[i].last_sect * dataplane->sector_size >=XEN_PAGE_SIZE ) {error_report ("error: page crossing" ); goto err; } len = (request->req.seg[i].last_sect - request->req.seg[i].first_sect +1 ) * dataplane->sector_size; request->size += len; }if (request->start + request->size >blk_getlength (dataplane->blk)) {error_report ("error: access beyond end of file" ); goto err; }return 0 ;
@@ -257,63 +257,63 @@ static int xen_block_do_aio(XenBlockRequest *request);static void xen_block_complete_aio (void *opaque,int ret) {XenBlockRequest *request = opaque;XenBlockDataPlane *dataplane = request->dataplane;aio_context_acquire (dataplane->ctx);if (ret !=0 ) {error_report ("%s I/O error" , request->req.operation ==BLKIF_OP_READ ?"read" :"write" ); request->aio_errors++; } request->aio_inflight--;if (request->presync) { request->presync =0 ;xen_block_do_aio (request); goto done; }if (request->aio_inflight >0 ) { goto done; }switch (request->req.operation) {case BLKIF_OP_READ :/* in case of failure request->aio_errors is increased */ if (ret ==0 ) {xen_block_copy_request (request); }break ;case BLKIF_OP_WRITE :case BLKIF_OP_FLUSH_DISKCACHE :default :break ; } request->status = request->aio_errors ?BLKIF_RSP_ERROR :BLKIF_RSP_OKAY ;switch (request->req.operation) {case BLKIF_OP_WRITE :case BLKIF_OP_FLUSH_DISKCACHE :if (!request->req.nr_segments) {break ; } -/* fall through */ + fallthrough;case BLKIF_OP_READ :if (request->status ==BLKIF_RSP_OKAY ) {block_acct_done (blk_get_stats (dataplane->blk), &request->acct); }else {block_acct_failed (blk_get_stats (dataplane->blk), &request->acct); }break ;case BLKIF_OP_DISCARD :default :break ; }xen_block_complete_request (request);if (dataplane->more_work) {qemu_bh_schedule (dataplane->bh); }
hw/block/m25p80.c +1 -1
@@ -1117,360 +1117,360 @@ static bool is_valid_aai_cmd(uint32_t cmd)static void decode_new_cmd (Flash *s,uint32_t value) {int i; s->cmd_in_progress = value;trace_m25p80_command_decoded (s, value);if (value !=RESET_MEMORY ) { s->reset_enable = false; }if (get_man (s) ==MAN_SST && s->aai_enable && !is_valid_aai_cmd (value)) {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Invalid cmd within AAI programming sequence" ); }switch (value) {case ERASE_4K :case ERASE4_4K :case ERASE_32K :case ERASE4_32K :case ERASE_SECTOR :case ERASE4_SECTOR :case PP :case PP4 :case DIE_ERASE :case RDID_90 :case RDID_AB : s->needed_bytes =get_addr_length (s); s->pos =0 ; s->len =0 ; s->state =STATE_COLLECTING_DATA ;break ;case READ :case READ4 :if (get_man (s) !=MAN_NUMONYX ||numonyx_mode (s) ==MODE_STD ) { s->needed_bytes =get_addr_length (s); s->pos =0 ; s->len =0 ; s->state =STATE_COLLECTING_DATA ; }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Cannot execute cmd %x in " "DIO or QIO mode\n" , s->cmd_in_progress); }break ;case DPP :if (get_man (s) !=MAN_NUMONYX ||numonyx_mode (s) !=MODE_QIO ) { s->needed_bytes =get_addr_length (s); s->pos =0 ; s->len =0 ; s->state =STATE_COLLECTING_DATA ; }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Cannot execute cmd %x in " "QIO mode\n" , s->cmd_in_progress); }break ;case QPP :case QPP_4 :case PP4_4 :if (get_man (s) !=MAN_NUMONYX ||numonyx_mode (s) !=MODE_DIO ) { s->needed_bytes =get_addr_length (s); s->pos =0 ; s->len =0 ; s->state =STATE_COLLECTING_DATA ; }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Cannot execute cmd %x in " "DIO mode\n" , s->cmd_in_progress); }break ;case FAST_READ :case FAST_READ4 :decode_fast_read_cmd (s);break ;case DOR :case DOR4 :if (get_man (s) !=MAN_NUMONYX ||numonyx_mode (s) !=MODE_QIO ) {decode_fast_read_cmd (s); }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Cannot execute cmd %x in " "QIO mode\n" , s->cmd_in_progress); }break ;case QOR :case QOR4 :if (get_man (s) !=MAN_NUMONYX ||numonyx_mode (s) !=MODE_DIO ) {decode_fast_read_cmd (s); }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Cannot execute cmd %x in " "DIO mode\n" , s->cmd_in_progress); }break ;case DIOR :case DIOR4 :if (get_man (s) !=MAN_NUMONYX ||numonyx_mode (s) !=MODE_QIO ) {decode_dio_read_cmd (s); }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Cannot execute cmd %x in " "QIO mode\n" , s->cmd_in_progress); }break ;case QIOR :case QIOR4 :if (get_man (s) !=MAN_NUMONYX ||numonyx_mode (s) !=MODE_DIO ) {decode_qio_read_cmd (s); }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Cannot execute cmd %x in " "DIO mode\n" , s->cmd_in_progress); }break ;case WRSR :/* * If WP# is low and status_register_write_disabled is high, * status register writes are disabled. * This is also called "hardware protected mode" (HPM). All other * combinations of the two states are called "software protected mode" * (SPM), and status register writes are permitted. */ if ((s->wp_level ==0 && s->status_register_write_disabled) || !s->write_enable) {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Status register write is disabled!\n" );break ; }switch (get_man (s)) {case MAN_SPANSION : s->needed_bytes =2 ; s->state =STATE_COLLECTING_DATA ;break ;case MAN_MACRONIX : s->needed_bytes =2 ; s->state =STATE_COLLECTING_VAR_LEN_DATA ;break ;default : s->needed_bytes =1 ; s->state =STATE_COLLECTING_DATA ; } s->pos =0 ;break ;case WRDI : s->write_enable = false;if (get_man (s) ==MAN_SST ) { s->aai_enable = false; }break ;case WREN : s->write_enable = true;break ;case RDSR : s->data[0 ] = (!!s->write_enable) <<1 ; s->data[0 ] |= (!!s->status_register_write_disabled) <<7 ; s->data[0 ] |= (!!s->block_protect0) <<2 ; s->data[0 ] |= (!!s->block_protect1) <<3 ; s->data[0 ] |= (!!s->block_protect2) <<4 ;if (s->pi->flags &HAS_SR_TB ) { s->data[0 ] |= (!!s->top_bottom_bit) <<5 ; }if (s->pi->flags &HAS_SR_BP3_BIT6 ) { s->data[0 ] |= (!!s->block_protect3) <<6 ; }if (get_man (s) ==MAN_MACRONIX ||get_man (s) ==MAN_ISSI ) { s->data[0 ] |= (!!s->quad_enable) <<6 ; }if (get_man (s) ==MAN_SST ) { s->data[0 ] |= (!!s->aai_enable) <<6 ; } s->pos =0 ; s->len =1 ; s->data_read_loop = true; s->state =STATE_READING_DATA ;break ;case READ_FSR : s->data[0 ] =FSR_FLASH_READY ;if (s->four_bytes_address_mode) { s->data[0 ] |=FSR_4BYTE_ADDR_MODE_ENABLED ; } s->pos =0 ; s->len =1 ; s->data_read_loop = true; s->state =STATE_READING_DATA ;break ;case JEDEC_READ :if (get_man (s) !=MAN_NUMONYX ||numonyx_mode (s) ==MODE_STD ) {trace_m25p80_populated_jedec (s);for (i =0 ; i < s->pi->id_len; i++) { s->data[i] = s->pi->id[i]; }for (; i <SPI_NOR_MAX_ID_LEN ; i++) { s->data[i] =0 ; } s->len =SPI_NOR_MAX_ID_LEN ; s->pos =0 ; s->state =STATE_READING_DATA ; }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Cannot execute JEDEC read " "in DIO or QIO mode\n" ); }break ;case RDCR : s->data[0 ] = s->volatile_cfg &0xFF ; s->data[0 ] |= (!!s->four_bytes_address_mode) <<5 ; s->pos =0 ; s->len =1 ; s->state =STATE_READING_DATA ;break ;case BULK_ERASE_60 :case BULK_ERASE :if (s->write_enable) {trace_m25p80_chip_erase (s);flash_erase (s,0 ,BULK_ERASE ); }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: chip erase with write " "protect!\n" ); }break ;case NOP :break ;case EN_4BYTE_ADDR : s->four_bytes_address_mode = true;break ;case EX_4BYTE_ADDR : s->four_bytes_address_mode = false;break ;case BRRD :case EXTEND_ADDR_READ : s->data[0 ] = s->ear; s->pos =0 ; s->len =1 ; s->state =STATE_READING_DATA ;break ;case BRWR :case EXTEND_ADDR_WRITE :if (s->write_enable) { s->needed_bytes =1 ; s->pos =0 ; s->len =0 ; s->state =STATE_COLLECTING_DATA ; }break ;case RNVCR : s->data[0 ] = s->nonvolatile_cfg &0xFF ; s->data[1 ] = (s->nonvolatile_cfg >>8 ) &0xFF ; s->pos =0 ; s->len =2 ; s->state =STATE_READING_DATA ;break ;case WNVCR :if (s->write_enable &&get_man (s) ==MAN_NUMONYX ) { s->needed_bytes =2 ; s->pos =0 ; s->len =0 ; s->state =STATE_COLLECTING_DATA ; }break ;case RVCR : s->data[0 ] = s->volatile_cfg &0xFF ; s->pos =0 ; s->len =1 ; s->state =STATE_READING_DATA ;break ;case WVCR :if (s->write_enable) { s->needed_bytes =1 ; s->pos =0 ; s->len =0 ; s->state =STATE_COLLECTING_DATA ; }break ;case REVCR : s->data[0 ] = s->enh_volatile_cfg &0xFF ; s->pos =0 ; s->len =1 ; s->state =STATE_READING_DATA ;break ;case WEVCR :if (s->write_enable) { s->needed_bytes =1 ; s->pos =0 ; s->len =0 ; s->state =STATE_COLLECTING_DATA ; }break ;case RESET_ENABLE : s->reset_enable = true;break ;case RESET_MEMORY :if (s->reset_enable) {reset_memory (s); }break ;case RDCR_EQIO :switch (get_man (s)) {case MAN_SPANSION : s->data[0 ] = (!!s->quad_enable) <<1 ; s->pos =0 ; s->len =1 ; s->state =STATE_READING_DATA ;break ;case MAN_MACRONIX : s->quad_enable = true;break ;default :break ; }break ;case RSTQIO : s->quad_enable = false;break ;case AAI_WP :if (get_man (s) ==MAN_SST ) {if (s->write_enable) {if (s->aai_enable) { s->state =STATE_PAGE_PROGRAM ; }else { s->aai_enable = true; s->needed_bytes =get_addr_length (s); s->state =STATE_COLLECTING_DATA ; } }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: AAI_WP with write protect\n" ); } }else {qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Unknown cmd %x\n" , value); }break ;case RDSFDP :if (s->pi->sfdp_read) { s->needed_bytes =get_addr_length (s) +1 ;/* SFDP addr + dummy */ s->pos =0 ; s->len =0 ; s->state =STATE_COLLECTING_DATA ;break ; } -/* Fallthrough */ + fallthrough;default : s->pos =0 ; s->len =1 ; s->state =STATE_READING_DATA ; s->data_read_loop = true; s->data[0 ] =0 ;qemu_log_mask (LOG_GUEST_ERROR ,"M25P80: Unknown cmd %x\n" , value);break ; } }
hw/block/onenand.c +1 -1
@@ -406,202 +406,202 @@ fail:static void onenand_command (OneNANDState *s) {int b;int sec;void *buf;#define SETADDR (block, page) \ sec = (s->addr[page] & 3) + \ ((((s->addr[page] >> 2) & 0x3f) + \ (((s->addr[block] & 0xfff) | \ (s->addr[block] >> 15 ? s->density_mask : 0)) \ << 6)) \ << (PAGE_SHIFT - 9));#define SETBUF_M () \ buf = (s->bufaddr & 8) ? s->data[(s->bufaddr >> 2) & 1][0] : s->boot[0]; \ buf += (s->bufaddr & 3) << 9;#define SETBUF_S () \ buf = (s->bufaddr & 8) ? \ s->data[(s->bufaddr >> 2) & 1][1] : s->boot[1]; \ buf += (s->bufaddr & 3) << 4;switch (s->command) {case 0x00 :/* Load single/multiple sector data unit into buffer */ SETADDR(ONEN_BUF_BLOCK, ONEN_BUF_PAGE) SETBUF_M()if (onenand_load_main (s, sec, s->count, buf)) s->status |=ONEN_ERR_CMD |ONEN_ERR_LOAD ;#if 0 SETBUF_S()if (onenand_load_spare (s, sec, s->count, buf)) s->status |=ONEN_ERR_CMD |ONEN_ERR_LOAD ;#endif /* TODO: if (s->bufaddr & 3) + s->count was > 4 (2k-pages) * or if (s->bufaddr & 1) + s->count was > 2 (1k-pages) * then we need two split the read/write into two chunks. */ s->intstatus |=ONEN_INT |ONEN_INT_LOAD ;break ;case 0x13 :/* Load single/multiple spare sector into buffer */ SETADDR(ONEN_BUF_BLOCK, ONEN_BUF_PAGE) SETBUF_S()if (onenand_load_spare (s, sec, s->count, buf)) s->status |=ONEN_ERR_CMD |ONEN_ERR_LOAD ;/* TODO: if (s->bufaddr & 3) + s->count was > 4 (2k-pages) * or if (s->bufaddr & 1) + s->count was > 2 (1k-pages) * then we need two split the read/write into two chunks. */ s->intstatus |=ONEN_INT |ONEN_INT_LOAD ;break ;case 0x80 :/* Program single/multiple sector data unit from buffer */ SETADDR(ONEN_BUF_BLOCK, ONEN_BUF_PAGE) SETBUF_M()if (onenand_prog_main (s, sec, s->count, buf)) s->status |=ONEN_ERR_CMD |ONEN_ERR_PROG ;#if 0 SETBUF_S()if (onenand_prog_spare (s, sec, s->count, buf)) s->status |=ONEN_ERR_CMD |ONEN_ERR_PROG ;#endif /* TODO: if (s->bufaddr & 3) + s->count was > 4 (2k-pages) * or if (s->bufaddr & 1) + s->count was > 2 (1k-pages) * then we need two split the read/write into two chunks. */ s->intstatus |=ONEN_INT |ONEN_INT_PROG ;break ;case 0x1a :/* Program single/multiple spare area sector from buffer */ SETADDR(ONEN_BUF_BLOCK, ONEN_BUF_PAGE) SETBUF_S()if (onenand_prog_spare (s, sec, s->count, buf)) s->status |=ONEN_ERR_CMD |ONEN_ERR_PROG ;/* TODO: if (s->bufaddr & 3) + s->count was > 4 (2k-pages) * or if (s->bufaddr & 1) + s->count was > 2 (1k-pages) * then we need two split the read/write into two chunks. */ s->intstatus |=ONEN_INT |ONEN_INT_PROG ;break ;case 0x1b :/* Copy-back program */ SETBUF_S() SETADDR(ONEN_BUF_BLOCK, ONEN_BUF_PAGE) if (onenand_load_main(s, sec, s->count, buf)) s->status |= ONEN_ERR_CMD | ONEN_ERR_PROG; SETADDR(ONEN_BUF_DEST_BLOCK, ONEN_BUF_DEST_PAGE)if (onenand_prog_main (s, sec, s->count, buf)) s->status |=ONEN_ERR_CMD |ONEN_ERR_PROG ;/* TODO: spare areas */ s->intstatus |=ONEN_INT |ONEN_INT_PROG ;break ;case 0x23 :/* Unlock NAND array block(s) */ s->intstatus |=ONEN_INT ;/* XXX the previous (?) area should be locked automatically */ for (b = s->unladdr[0 ]; b <= s->unladdr[1 ]; b ++) {if (b >= s->blocks) { s->status |=ONEN_ERR_CMD ;break ; }if (s->blockwp[b] ==ONEN_LOCK_LOCKTIGHTEN )break ; s->wpstatus = s->blockwp[b] =ONEN_LOCK_UNLOCKED ; }break ;case 0x27 :/* Unlock All NAND array blocks */ s->intstatus |=ONEN_INT ;for (b =0 ; b < s->blocks; b ++) {if (s->blockwp[b] ==ONEN_LOCK_LOCKTIGHTEN )break ; s->wpstatus = s->blockwp[b] =ONEN_LOCK_UNLOCKED ; }break ;case 0x2a :/* Lock NAND array block(s) */ s->intstatus |=ONEN_INT ;for (b = s->unladdr[0 ]; b <= s->unladdr[1 ]; b ++) {if (b >= s->blocks) { s->status |=ONEN_ERR_CMD ;break ; }if (s->blockwp[b] ==ONEN_LOCK_LOCKTIGHTEN )break ; s->wpstatus = s->blockwp[b] =ONEN_LOCK_LOCKED ; }break ;case 0x2c :/* Lock-tight NAND array block(s) */ s->intstatus |=ONEN_INT ;for (b = s->unladdr[0 ]; b <= s->unladdr[1 ]; b ++) {if (b >= s->blocks) { s->status |=ONEN_ERR_CMD ;break ; }if (s->blockwp[b] ==ONEN_LOCK_UNLOCKED )continue ; s->wpstatus = s->blockwp[b] =ONEN_LOCK_LOCKTIGHTEN ; }break ;case 0x71 :/* Erase-Verify-Read */ s->intstatus |=ONEN_INT ;break ;case 0x95 :/* Multi-block erase */ qemu_irq_pulse (s->intr); -/* Fall through. */ + fallthrough;case 0x94 :/* Block erase */ sec = ((s->addr[ONEN_BUF_BLOCK ] &0xfff ) | (s->addr[ONEN_BUF_BLOCK ] >>15 ? s->density_mask :0 )) << (BLOCK_SHIFT -9 );if (onenand_erase (s, sec,1 << (BLOCK_SHIFT -9 ))) s->status |=ONEN_ERR_CMD |ONEN_ERR_ERASE ; s->intstatus |=ONEN_INT |ONEN_INT_ERASE ;break ;case 0xb0 :/* Erase suspend */ break ;case 0x30 :/* Erase resume */ s->intstatus |=ONEN_INT |ONEN_INT_ERASE ;break ;case 0xf0 :/* Reset NAND Flash core */ onenand_reset (s,0 );break ;case 0xf3 :/* Reset OneNAND */ onenand_reset (s,0 );break ;case 0x65 :/* OTP Access */ s->intstatus |=ONEN_INT ; s->blk_cur =NULL ; s->current = s->otp; s->secs_cur =1 << (BLOCK_SHIFT -9 ); s->addr[ONEN_BUF_BLOCK ] =0 ; s->otpmode =1 ;break ;default : s->status |=ONEN_ERR_CMD ; s->intstatus |=ONEN_INT ;qemu_log_mask (LOG_GUEST_ERROR ,"unknown OneNAND command %x\n" , s->command); }onenand_intr_update (s); }
hw/block/pflash_cfi01.c +1 -0
@@ -261,123 +261,124 @@ static uint32_t pflash_data_read(PFlashCFI01 *pfl, hwaddr offset,static uint32_t pflash_read (PFlashCFI01 *pfl,hwaddr offset,int width,int be) {hwaddr boff;uint32_t ret; ret =-1 ;switch (pfl->cmd) {default :/* This should never happen : reset state & treat it as a read */ trace_pflash_read_unknown_state (pfl->name, pfl->cmd); pfl->wcycle =0 ;/* * The command 0x00 is not assigned by the CFI open standard, * but QEMU historically uses it for the READ_ARRAY command (0xff). */ pfl->cmd =0x00 ;/* fall through to read code */ + fallthrough;case 0x00 :/* This model reset value for READ_ARRAY (not CFI compliant) */ /* Flash area read */ ret =pflash_data_read (pfl, offset, width, be);break ;case 0x10 :/* Single byte program */ case 0x20 :/* Block erase */ case 0x28 :/* Block erase */ case 0x40 :/* single byte program */ case 0x50 :/* Clear status register */ case 0x60 :/* Block /un)lock */ case 0x70 :/* Status Register */ case 0xe8 :/* Write block */ /* * Status register read. Return status from each device in * bank. */ ret = pfl->status;if (pfl->device_width && width > pfl->device_width) {int shift = pfl->device_width *8 ;while (shift + pfl->device_width *8 <= width *8 ) { ret |= pfl->status << shift; shift += pfl->device_width *8 ; } }else if (!pfl->device_width && width >2 ) {/* * Handle 32 bit flash cases where device width is not * set. (Existing behavior before device width added.) */ ret |= pfl->status <<16 ; }trace_pflash_read_status (pfl->name, ret);break ;case 0x90 :if (!pfl->device_width) {/* Preserve old behavior if device width not specified */ boff = offset &0xFF ;if (pfl->bank_width ==2 ) { boff = boff >>1 ; }else if (pfl->bank_width ==4 ) { boff = boff >>2 ; }switch (boff) {case 0 : ret = pfl->ident0 <<8 | pfl->ident1;trace_pflash_manufacturer_id (pfl->name, ret);break ;case 1 : ret = pfl->ident2 <<8 | pfl->ident3;trace_pflash_device_id (pfl->name, ret);break ;default :trace_pflash_device_info (pfl->name, boff); ret =0 ;break ; } }else {/* * If we have a read larger than the bank_width, combine multiple * manufacturer/device ID queries into a single response. */ int i;for (i =0 ; i < width; i += pfl->bank_width) { ret =deposit32 (ret, i *8 , pfl->bank_width *8 ,pflash_devid_query (pfl, offset + i * pfl->bank_width)); } }break ;case 0x98 :/* Query mode */ if (!pfl->device_width) {/* Preserve old behavior if device width not specified */ boff = offset &0xFF ;if (pfl->bank_width ==2 ) { boff = boff >>1 ; }else if (pfl->bank_width ==4 ) { boff = boff >>2 ; }if (boff <sizeof (pfl->cfi_table)) { ret = pfl->cfi_table[boff]; }else { ret =0 ; } }else {/* * If we have a read larger than the bank_width, combine multiple * CFI queries into a single response. */ int i;for (i =0 ; i < width; i += pfl->bank_width) { ret =deposit32 (ret, i *8 , pfl->bank_width *8 ,pflash_cfi_query (pfl, offset + i * pfl->bank_width)); } }break ; }trace_pflash_io_read (pfl->name, offset, width, ret, pfl->cmd, pfl->wcycle);return ret; }/* update flash content on disk */
hw/block/pflash_cfi02.c +4 -2
@@ -307,87 +307,89 @@ static bool pflash_sector_is_erasing(PFlashCFI02 *pfl, hwaddr offset)static uint64_t pflash_read (void *opaque,hwaddr offset,unsigned int width) {PFlashCFI02 *pfl = opaque;hwaddr boff;uint64_t ret;/* Lazy reset to ROMD mode after a certain amount of read accesses */ if (!pfl->rom_mode && pfl->wcycle ==0 && ++pfl->read_counter >PFLASH_LAZY_ROMD_THRESHOLD ) {pflash_mode_read_array (pfl); } offset &= pfl->chip_len -1 ; boff = offset &0xFF ;if (pfl->width ==2 ) { boff = boff >>1 ; }else if (pfl->width ==4 ) { boff = boff >>2 ; }switch (pfl->cmd) {default :/* This should never happen : reset state & treat it as a read*/ trace_pflash_read_unknown_state (pfl->name, pfl->cmd);pflash_reset_state_machine (pfl);/* fall through to the read code */ + fallthrough;case 0x80 :/* Erase (unlock) */ /* We accept reads during second unlock sequence... */ case 0x00 :if (pflash_erase_suspend_mode (pfl) &&pflash_sector_is_erasing (pfl, offset)) {/* Toggle bit 2, but not 6. */ toggle_dq2 (pfl);/* Status register read */ ret = pfl->status;trace_pflash_read_status (pfl->name, ret);break ; }/* Flash area read */ ret =pflash_data_read (pfl, offset, width);break ;case 0x90 :/* flash ID read */ switch (boff) {case 0x00 :case 0x01 : ret = boff &0x01 ? pfl->ident1 : pfl->ident0;break ;case 0x02 : ret =0x00 ;/* Pretend all sectors are unprotected */ break ;case 0x0E :case 0x0F : ret = boff &0x01 ? pfl->ident3 : pfl->ident2;if (ret != (uint8_t )-1 ) {break ; }/* Fall through to data read. */ + fallthrough;default : ret =pflash_data_read (pfl, offset, width); }trace_pflash_read_done (pfl->name, boff, ret);break ;case 0x10 :/* Chip Erase */ case 0x30 :/* Sector Erase */ /* Toggle bit 2 during erase, but not program. */ toggle_dq2 (pfl); -/* fall through */ + fallthrough;case 0xA0 :/* Program */ /* Toggle bit 6 */ toggle_dq6 (pfl);/* Status register read */ ret = pfl->status;trace_pflash_read_status (pfl->name, ret);break ;case 0x98 :/* CFI query mode */ if (boff <sizeof (pfl->cfi_table)) { ret = pfl->cfi_table[boff]; }else { ret =0 ; }break ; }trace_pflash_io_read (pfl->name, offset, width, ret, pfl->cmd, pfl->wcycle);return ret; }/* update flash content on disk */
@@ -431,277 +433,277 @@ static void pflash_sector_erase(PFlashCFI02 *pfl, hwaddr offset)static void pflash_write (void *opaque,hwaddr offset,uint64_t value,unsigned int width) {PFlashCFI02 *pfl = opaque;hwaddr boff;uint8_t *p;uint8_t cmd;trace_pflash_io_write (pfl->name, offset, width, value, pfl->wcycle); cmd = value;if (pfl->cmd !=0xA0 ) {/* Reset does nothing during chip erase and sector erase. */ if (cmd ==0xF0 && pfl->cmd !=0x10 && pfl->cmd !=0x30 ) {if (pfl->wcycle ==WCYCLE_AUTOSELECT_CFI ) {/* Return to autoselect mode. */ pfl->wcycle =3 ; pfl->cmd =0x90 ;return ; } goto reset_flash; } } offset &= pfl->chip_len -1 ; boff = offset;if (pfl->width ==2 ) { boff = boff >>1 ; }else if (pfl->width ==4 ) { boff = boff >>2 ; }/* Only the least-significant 11 bits are used in most cases. */ boff &=0x7FF ;switch (pfl->wcycle) {case 0 :/* Set the device in I/O access mode if required */ if (pfl->rom_mode) { pfl->rom_mode = false;memory_region_rom_device_set_romd (&pfl->orig_mem, false); } pfl->read_counter =0 ;/* We're in read mode */ check_unlock0:if (boff ==0x55 && cmd ==0x98 ) {/* Enter CFI query mode */ pfl->wcycle =WCYCLE_CFI ; pfl->cmd =0x98 ;return ; }/* Handle erase resume in erase suspend mode, otherwise reset. */ if (cmd ==0x30 ) {/* Erase Resume */ if (pflash_erase_suspend_mode (pfl)) {/* Resume the erase. */ timer_mod (&pfl->timer,qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) + pfl->erase_time_remaining); pfl->erase_time_remaining =0 ; pfl->wcycle =6 ; pfl->cmd =0x30 ;set_dq7 (pfl,0x00 );assert_dq3 (pfl);return ; } goto reset_flash; }/* Ignore erase suspend. */ if (cmd ==0xB0 ) {/* Erase Suspend */ return ; }if (boff != pfl->unlock_addr0 || cmd !=0xAA ) {trace_pflash_unlock0_failed (pfl->name, boff, cmd, pfl->unlock_addr0); goto reset_flash; }trace_pflash_write (pfl->name,"unlock sequence started" );break ;case 1 :/* We started an unlock sequence */ check_unlock1:if (boff != pfl->unlock_addr1 || cmd !=0x55 ) {trace_pflash_unlock1_failed (pfl->name, boff, cmd); goto reset_flash; }trace_pflash_write (pfl->name,"unlock sequence done" );break ;case 2 :/* We finished an unlock sequence */ if (!pfl->bypass && boff != pfl->unlock_addr0) {trace_pflash_write_failed (pfl->name, boff, cmd); goto reset_flash; }switch (cmd) {case 0x20 : pfl->bypass =1 ; goto do_bypass;case 0x80 :/* Erase */ case 0x90 :/* Autoselect */ case 0xA0 :/* Program */ pfl->cmd = cmd;trace_pflash_write_start (pfl->name, cmd);break ;default :trace_pflash_write_unknown (pfl->name, cmd); goto reset_flash; }break ;case 3 :switch (pfl->cmd) {case 0x80 :/* Erase */ /* We need another unlock sequence */ goto check_unlock0;case 0xA0 :/* Program */ if (pflash_erase_suspend_mode (pfl) &&pflash_sector_is_erasing (pfl, offset)) {/* Ignore writes to erasing sectors. */ if (pfl->bypass) { goto do_bypass; } goto reset_flash; }trace_pflash_data_write (pfl->name, offset, width, value,0 );if (!pfl->ro) { p = (uint8_t *)pfl->storage + offset;if (pfl->be) {uint64_t current =ldn_be_p (p, width);stn_be_p (p, width, current & value); }else {uint64_t current =ldn_le_p (p, width);stn_le_p (p, width, current & value); }pflash_update (pfl, offset, width); }/* * While programming, status bit DQ7 should hold the opposite * value from how it was programmed. */ set_dq7 (pfl, ~value);/* Let's pretend write is immediate */ if (pfl->bypass) goto do_bypass; goto reset_flash;case 0x90 :/* Autoselect */ if (pfl->bypass && cmd ==0x00 ) {/* Unlock bypass reset */ goto reset_flash; }/* * We can enter CFI query mode from autoselect mode, but we must * return to autoselect mode after a reset. */ if (boff ==0x55 && cmd ==0x98 ) {/* Enter autoselect CFI query mode */ pfl->wcycle =WCYCLE_AUTOSELECT_CFI ; pfl->cmd =0x98 ;return ; } -/* fall through */ + fallthrough;default :trace_pflash_write_invalid (pfl->name, pfl->cmd); goto reset_flash; }case 4 :switch (pfl->cmd) {case 0xA0 :/* Program */ /* Ignore writes while flash data write is occurring */ /* As we suppose write is immediate, this should never happen */ return ;case 0x80 :/* Erase */ goto check_unlock1;default :/* Should never happen */ trace_pflash_write_invalid_state (pfl->name, pfl->cmd,5 ); goto reset_flash; }break ;case 5 :if (pflash_erase_suspend_mode (pfl)) {/* Erasing is not supported in erase suspend mode. */ goto reset_flash; }switch (cmd) {case 0x10 :/* Chip Erase */ if (boff != pfl->unlock_addr0) {trace_pflash_chip_erase_invalid (pfl->name, offset); goto reset_flash; }/* Chip erase */ trace_pflash_chip_erase_start (pfl->name);if (!pfl->ro) {memset (pfl->storage,0xff , pfl->chip_len);pflash_update (pfl,0 , pfl->chip_len); }set_dq7 (pfl,0x00 );/* Wait the time specified at CFI address 0x22. */ timer_mod (&pfl->timer,qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ) + (1ULL << pfl->cfi_table[0x22 ]) *SCALE_MS );break ;case 0x30 :/* Sector erase */ pflash_sector_erase (pfl, offset);break ;default :trace_pflash_write_invalid_command (pfl->name, cmd); goto reset_flash; } pfl->cmd = cmd;break ;case 6 :switch (pfl->cmd) {case 0x10 :/* Chip Erase */ /* Ignore writes during chip erase */ return ;case 0x30 :/* Sector erase */ if (cmd ==0xB0 ) {/* * If erase suspend happens during the erase timeout (so DQ3 is * 0), then the device suspends erasing immediately. Set the * remaining time to be the total time to erase. Otherwise, * there is a maximum amount of time it can take to enter * suspend mode. Let's ignore that and suspend immediately and * set the remaining time to the actual time remaining on the * timer. */ if ((pfl->status &0x08 ) ==0 ) { pfl->erase_time_remaining =pflash_erase_time (pfl); }else {int64_t delta =timer_expire_time_ns (&pfl->timer) -qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL );/* Make sure we have a positive time remaining. */ pfl->erase_time_remaining = delta <=0 ?1 : delta; }reset_dq3 (pfl);timer_del (&pfl->timer);pflash_reset_state_machine (pfl);return ; }/* * If DQ3 is 0, additional sector erase commands can be * written and anything else (other than an erase suspend) resets * the device. */ if ((pfl->status &0x08 ) ==0 ) {if (cmd ==0x30 ) {pflash_sector_erase (pfl, offset); }else { goto reset_flash; } }/* Ignore writes during the actual erase. */ return ;default :/* Should never happen */ trace_pflash_write_invalid_state (pfl->name, pfl->cmd,6 ); goto reset_flash; }break ;/* Special values for CFI queries */ case WCYCLE_CFI :case WCYCLE_AUTOSELECT_CFI :trace_pflash_write (pfl->name,"invalid write in CFI query mode" ); goto reset_flash;default :/* Should never happen */ trace_pflash_write (pfl->name,"invalid write state (wc 7)" ); goto reset_flash; } pfl->wcycle++;return ;/* Reset flash */ reset_flash: pfl->bypass =0 ;pflash_reset_state_machine (pfl);return ; do_bypass: pfl->wcycle =2 ; pfl->cmd =0 ; }
Signature · 1 line
2.39.2
RFC PATCH 9/78 hw/acpi/aml-build.c: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- hw/acpi/aml-build.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/acpi/aml-build.c +3 -3
@@ -292,56 +292,55 @@ static void build_prepend_package_length(GArray *package, unsigned length, bool incl_self) {uint8_t byte;unsigned length_bytes;if (length +1 < (1 <<PACKAGE_LENGTH_1BYTE_SHIFT )) { length_bytes =1 ; }else if (length +2 < (1 <<PACKAGE_LENGTH_3BYTE_SHIFT )) { length_bytes =2 ; }else if (length +3 < (1 <<PACKAGE_LENGTH_4BYTE_SHIFT )) { length_bytes =3 ; }else { length_bytes =4 ; }/* * NamedField uses PkgLength encoding but it doesn't include length * of PkgLength itself. */ if (incl_self) {/* * PkgLength is the length of the inclusive length of the data * and PkgLength's length itself when used for terms with * explicit length. */ length += length_bytes; }switch (length_bytes) {case 1 : byte = length;build_prepend_byte (package, byte);return ;case 4 : byte = length >>PACKAGE_LENGTH_4BYTE_SHIFT ;build_prepend_byte (package, byte); length &= (1 <<PACKAGE_LENGTH_4BYTE_SHIFT ) -1 ; -/* fall through */ + fallthrough;case 3 : byte = length >>PACKAGE_LENGTH_3BYTE_SHIFT ;build_prepend_byte (package, byte); length &= (1 <<PACKAGE_LENGTH_3BYTE_SHIFT ) -1 ; -/* fall through */ + fallthrough;case 2 : byte = length >>PACKAGE_LENGTH_2BYTE_SHIFT ;build_prepend_byte (package, byte); length &= (1 <<PACKAGE_LENGTH_2BYTE_SHIFT ) -1 ; -/* fall through */ }/* * Most significant two bits of byte zero indicate how many following bytes * are in PkgLength encoding. */ byte = ((length_bytes -1 ) <<PACKAGE_LENGTH_1BYTE_SHIFT ) | length;build_prepend_byte (package, byte); }
@@ -508,37 +507,38 @@ static void build_buffer(GArray *array, uint8_t op)void aml_append (Aml *parent_ctx,Aml *child) {GArray *buf =build_alloc_array ();build_append_array (buf, child->buf);switch (child->block_flags) {case AML_OPCODE :build_append_byte (parent_ctx->buf, child->op);break ;case AML_EXT_PACKAGE :build_extop_package (buf, child->op);break ;case AML_PACKAGE :build_package (buf, child->op);break ;case AML_RES_TEMPLATE :build_append_byte (buf,0x79 );/* EndTag */ /* * checksum operations are treated as succeeded if checksum * field is zero. [ACPI Spec 1.0b, 6.4.2.8 End Tag] */ build_append_byte (buf,0 );/* fall through, to pack resources in buffer */ + fallthrough;case AML_BUFFER :build_buffer (buf, child->op);break ;case AML_NO_OPCODE :break ;default :assert (0 );break ; }build_append_array (parent_ctx->buf, buf);build_free_array (buf); }/* ACPI 1.0b: 16.2.5.1 Namespace Modifier Objects Encoding: DefScope */
Signature · 1 line
2.39.2
RFC PATCH 10/78 hw/ide/atapi.c: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- hw/ide/atapi.c | 1 + 1 file changed, 1 insertion(+)
hw/ide/atapi.c +1 -0
@@ -1189,53 +1189,54 @@ static void cmd_read_disc_information(IDEState *s, uint8_t* buf)static void cmd_read_dvd_structure (IDEState *s,uint8_t * buf) {int max_len;int media = buf[1 ];int format = buf[7 ];int ret; max_len =lduw_be_p (buf +8 );if (format <0xff ) {if (media_is_cd (s)) {ide_atapi_cmd_error (s,ILLEGAL_REQUEST ,ASC_INCOMPATIBLE_FORMAT );return ; }else if (!media_present (s)) {ide_atapi_cmd_error (s,ILLEGAL_REQUEST ,ASC_INV_FIELD_IN_CMD_PACKET );return ; } }memset (buf,0 , max_len >IDE_DMA_BUF_SECTORS *BDRV_SECTOR_SIZE +4 ?IDE_DMA_BUF_SECTORS *BDRV_SECTOR_SIZE +4 : max_len);switch (format) { case 0x00 ... 0x7f:case 0xff :if (media ==0 ) { ret =ide_dvd_read_structure (s, format, buf, buf);if (ret <0 ) {ide_atapi_cmd_error (s,ILLEGAL_REQUEST , -ret); }else {ide_atapi_cmd_reply (s, ret, max_len); }break ; }/* TODO: BD support, fall through for now */ + fallthrough;/* Generic disk structures */ case 0x80 :/* TODO: AACS volume identifier */ case 0x81 :/* TODO: AACS media serial number */ case 0x82 :/* TODO: AACS media identifier */ case 0x83 :/* TODO: AACS media key block */ case 0x90 :/* TODO: List of recognized format layers */ case 0xc0 :/* TODO: Write protection status */ default :ide_atapi_cmd_error (s,ILLEGAL_REQUEST ,ASC_INV_FIELD_IN_CMD_PACKET );break ; } }
Signature · 1 line
2.39.2
Re: [RFC PATCH 10/78] hw/ide/atapi.c: add fallthrough pseudo-keyword
Quoted 44 lines · Emmanouil Pitsidianakis
In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
Signed-off-by Emmanouil Pitsidianakis <[email protected]>--- hw/ide/atapi.c | 1 + 1 file changed, 1 insertion(+)hw/ide/atapi.c +0
-0@@ -1189,53 +1189,54 @@ static void cmd_read_disc_information(IDEState *s, uint8_t* buf)static void cmd_read_dvd_structure (IDEState *s,uint8_t * buf) {int max_len;int media = buf[1 ];int format = buf[7 ];int ret; max_len =lduw_be_p (buf +8 );if (format <0xff ) {if (media_is_cd (s)) {ide_atapi_cmd_error (s,ILLEGAL_REQUEST ,ASC_INCOMPATIBLE_FORMAT );return ; }else if (!media_present (s)) {ide_atapi_cmd_error (s,ILLEGAL_REQUEST ,ASC_INV_FIELD_IN_CMD_PACKET );return ; } }memset (buf,0 , max_len >IDE_DMA_BUF_SECTORS *BDRV_SECTOR_SIZE +4 ?IDE_DMA_BUF_SECTORS *BDRV_SECTOR_SIZE +4 : max_len);switch (format) { case 0x00 ... 0x7f:case 0xff :if (media ==0 ) { ret =ide_dvd_read_structure (s, format, buf, buf);
hw/ide/atapi.c static void cmd_read_disc_information(IDEState *s, uint8_t* buf) · line 1228
Quoted 10 lines
hw/ide/atapi.c +1
-0if (ret <0 ) {ide_atapi_cmd_error (s,ILLEGAL_REQUEST , -ret); }else {ide_atapi_cmd_reply (s, ret, max_len); }break ; }/* TODO: BD support, fall through for now */ + fallthrough;
ACK. For a moment I was wondering if this was something new to gcc, but I guess it's just a macro you made O:-)
Quoted 17 lines
hw/ide/atapi.c +0
-1/* Generic disk structures */ case 0x80 :/* TODO: AACS volume identifier */ case 0x81 :/* TODO: AACS media serial number */ case 0x82 :/* TODO: AACS media identifier */ case 0x83 :/* TODO: AACS media key block */ case 0x90 :/* TODO: List of recognized format layers */ case 0xc0 :/* TODO: Write protection status */ default :ide_atapi_cmd_error (s,ILLEGAL_REQUEST ,ASC_INV_FIELD_IN_CMD_PACKET );break ; } } --2.39.2
RFC PATCH 11/78 hw/timer: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- hw/timer/a9gtimer.c | 8 ++-- hw/timer/aspeed_timer.c | 1 + hw/timer/pxa2xx_timer.c | 94 ++++++++++++++++++++--------------------- hw/timer/renesas_tmr.c | 2 +- hw/timer/sh_timer.c | 8 ++-- 5 files changed, 57 insertions(+), 56 deletions(-)
hw/timer/a9gtimer.c +4 -4
@@ -135,40 +135,40 @@ static void a9_gtimer_update_no_sync(void *opaque)static uint64_t a9_gtimer_read (void *opaque,hwaddr addr,unsigned size) {A9GTimerPerCPU *gtb = (A9GTimerPerCPU *)opaque;A9GTimerState *s = gtb->parent;A9GTimerUpdate update;uint64_t ret =0 ;int shift =0 ;switch (addr) {case R_COUNTER_HI : shift =32 ; -/* fallthrough */ + fallthrough;case R_COUNTER_LO : update =a9_gtimer_get_update (s); ret =extract64 (update.new, shift,32 );break ;case R_CONTROL : ret = s->control | gtb->control;break ;case R_INTERRUPT_STATUS : ret = gtb->status;break ;case R_COMPARATOR_HI : shift =32 ; -/* fallthrough */ + fallthrough;case R_COMPARATOR_LO : ret =extract64 (gtb->compare, shift,32 );break ;case R_AUTO_INCREMENT : ret = gtb->inc;break ;default :qemu_log_mask (LOG_GUEST_ERROR ,"bad a9gtimer register: %x\n" , (unsigned )addr);return 0 ; }DB_PRINT ("addr:%#x data:%#08" PRIx64"\n" , (unsigned )addr, ret);return ret; }
@@ -176,54 +176,54 @@ static uint64_t a9_gtimer_read(void *opaque, hwaddr addr, unsigned size)static void a9_gtimer_write (void *opaque,hwaddr addr,uint64_t value,unsigned size) {A9GTimerPerCPU *gtb = (A9GTimerPerCPU *)opaque;A9GTimerState *s = gtb->parent;int shift =0 ;DB_PRINT ("addr:%#x data:%#08" PRIx64"\n" , (unsigned )addr, value);switch (addr) {case R_COUNTER_HI : shift =32 ; -/* fallthrough */ + fallthrough;case R_COUNTER_LO :/* * Keep it simple - ARM docco explicitly says to disable timer before * modding it, so don't bother trying to do all the difficult on the fly * timer modifications - (if they even work in real hardware??). */ if (s->control &R_CONTROL_TIMER_ENABLE ) {qemu_log_mask (LOG_GUEST_ERROR ,"Cannot mod running ARM gtimer\n" );return ; } s->counter =deposit64 (s->counter, shift,32 , value);return ;case R_CONTROL :a9_gtimer_update (s, (value ^ s->control) &R_CONTROL_NEEDS_SYNC ); gtb->control = value &R_CONTROL_BANKED ; s->control = value & ~R_CONTROL_BANKED ;break ;case R_INTERRUPT_STATUS :a9_gtimer_update (s, false); gtb->status &= ~value;break ;case R_COMPARATOR_HI : shift =32 ; -/* fallthrough */ + fallthrough;case R_COMPARATOR_LO :a9_gtimer_update (s, false); gtb->compare =deposit64 (gtb->compare, shift,32 , value);break ;case R_AUTO_INCREMENT : gtb->inc = value;return ;default :return ; }a9_gtimer_update (s, false); }/* Wrapper functions to implement the "read global timer for * the current CPU" memory regions. */
hw/timer/aspeed_timer.c +1 -0
@@ -266,53 +266,54 @@ static uint64_t aspeed_timer_read(void *opaque, hwaddr offset, unsigned size)static void aspeed_timer_set_value (AspeedTimerCtrlState *s,int timer,int reg,uint32_t value) {AspeedTimer *t;uint32_t old_reload;trace_aspeed_timer_set_value (timer, reg, value); t = &s->timers[timer];switch (reg) {case TIMER_REG_RELOAD : old_reload = t->reload; t->reload =calculate_min_ticks (t, value);/* If the reload value was not previously set, or zero, and * the current value is valid, try to start the timer if it is * enabled. */ if (old_reload || !t->reload) {break ; }/* fall through to re-enable */ + fallthrough;case TIMER_REG_STATUS :if (timer_enabled (t)) {uint64_t now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL );int64_t delta = (int64_t ) value - (int64_t )calculate_ticks (t, now);uint32_t rate =calculate_rate (t);if (delta >=0 ) { t->start +=muldiv64 (delta,NANOSECONDS_PER_SECOND , rate); }else { t->start -=muldiv64 (-delta,NANOSECONDS_PER_SECOND , rate); }aspeed_timer_mod (t); }break ;case TIMER_REG_MATCH_FIRST :case TIMER_REG_MATCH_SECOND : t->match[reg -2 ] = value;if (timer_enabled (t)) {aspeed_timer_mod (t); }break ;default :qemu_log_mask (LOG_UNIMP ,"%s: Programming error: unexpected reg: %d\n" , __func__, reg);break ; } }/* Control register operations are broken out into helpers that can be * explicitly called on aspeed_timer_reset(), but also from * aspeed_timer_ctrl_op(). */
hw/timer/pxa2xx_timer.c +47 -47
284 lines not on this page · raw message
hw/timer/renesas_tmr.c +1 -1
@@ -193,69 +193,69 @@ static uint8_t read_tccr(uint8_t r)static uint64_t tmr_read (void *opaque,hwaddr addr,unsigned size) {RTMRState *tmr = opaque;int ch = addr &1 ;uint64_t ret;if (size ==2 && (ch !=0 || addr ==A_TCR || addr ==A_TCSR )) {qemu_log_mask (LOG_GUEST_ERROR ,"renesas_tmr: Invalid read size 0x%" HWADDR_PRIX "\n" , addr);return UINT64_MAX ; }switch (addr &0x0e ) {case A_TCR : ret =0 ; ret =FIELD_DP8 (ret,TCR ,CCLR ,FIELD_EX8 (tmr->tcr[ch],TCR ,CCLR )); ret =FIELD_DP8 (ret,TCR ,OVIE ,FIELD_EX8 (tmr->tcr[ch],TCR ,OVIE )); ret =FIELD_DP8 (ret,TCR ,CMIEA ,FIELD_EX8 (tmr->tcr[ch],TCR ,CMIEA )); ret =FIELD_DP8 (ret,TCR ,CMIEB ,FIELD_EX8 (tmr->tcr[ch],TCR ,CMIEB ));return ret;case A_TCSR : ret =0 ; ret =FIELD_DP8 (ret,TCSR ,OSA ,FIELD_EX8 (tmr->tcsr[ch],TCSR ,OSA )); ret =FIELD_DP8 (ret,TCSR ,OSB ,FIELD_EX8 (tmr->tcsr[ch],TCSR ,OSB ));switch (ch) {case 0 : ret =FIELD_DP8 (ret,TCSR ,ADTE ,FIELD_EX8 (tmr->tcsr[ch],TCSR ,ADTE ));break ;case 1 :/* CH1 ADTE unimplement always 1 */ ret =FIELD_DP8 (ret,TCSR ,ADTE ,1 );break ; }return ret;case A_TCORA :if (size ==1 ) {return tmr->tcora[ch]; }else if (ch ==0 ) {return concat_reg (tmr->tcora); } -/* fall through */ + fallthrough;case A_TCORB :if (size ==1 ) {return tmr->tcorb[ch]; }else {return concat_reg (tmr->tcorb); }case A_TCNT :return read_tcnt (tmr, size, ch);case A_TCCR :if (size ==1 ) {return read_tccr (tmr->tccr[ch]); }else {return read_tccr (tmr->tccr[0 ]) <<8 |read_tccr (tmr->tccr[1 ]); }default :qemu_log_mask (LOG_UNIMP ,"renesas_tmr: Register 0x%" HWADDR_PRIX " not implemented\n" , addr);break ; }return UINT64_MAX ; }
hw/timer/sh_timer.c +4 -4
@@ -84,120 +84,120 @@ static uint32_t sh_timer_read(void *opaque, hwaddr offset)static void sh_timer_write (void *opaque,hwaddr offset,uint32_t value) {SHTimerState *s = opaque;int freq;switch (offset >>2 ) {case OFFSET_TCOR : s->tcor = value;ptimer_transaction_begin (s->timer);ptimer_set_limit (s->timer, s->tcor,0 );ptimer_transaction_commit (s->timer);break ;case OFFSET_TCNT : s->tcnt = value;ptimer_transaction_begin (s->timer);ptimer_set_count (s->timer, s->tcnt);ptimer_transaction_commit (s->timer);break ;case OFFSET_TCR :ptimer_transaction_begin (s->timer);if (s->enabled) {/* * Pause the timer if it is running. This may cause some inaccuracy * due to rounding, but avoids a whole lot of other messiness */ ptimer_stop (s->timer); } freq = s->freq;/* ??? Need to recalculate expiry time after changing divisor. */ switch (value &TIMER_TCR_TPSC ) {case 0 : freq >>=2 ;break ;case 1 : freq >>=4 ;break ;case 2 : freq >>=6 ;break ;case 3 : freq >>=8 ;break ;case 4 : freq >>=10 ;break ;case 6 :case 7 :if (s->feat &TIMER_FEAT_EXTCLK ) {break ; } -/* fallthrough */ + fallthrough;default :qemu_log_mask (LOG_GUEST_ERROR ,"%s: Reserved TPSC value\n" , __func__); }switch ((value &TIMER_TCR_CKEG ) >>3 ) {case 0 :break ;case 1 :case 2 :case 3 :if (s->feat &TIMER_FEAT_EXTCLK ) {break ; } -/* fallthrough */ + fallthrough;default :qemu_log_mask (LOG_GUEST_ERROR ,"%s: Reserved CKEG value\n" , __func__); }switch ((value &TIMER_TCR_ICPE ) >>6 ) {case 0 :break ;case 2 :case 3 :if (s->feat &TIMER_FEAT_CAPT ) {break ; } -/* fallthrough */ + fallthrough;default :qemu_log_mask (LOG_GUEST_ERROR ,"%s: Reserved ICPE value\n" , __func__); }if ((value &TIMER_TCR_UNF ) ==0 ) { s->int_level =0 ; } value &= ~TIMER_TCR_UNF ;if ((value &TIMER_TCR_ICPF ) && (!(s->feat &TIMER_FEAT_CAPT ))) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: Reserved ICPF value\n" , __func__); } value &= ~TIMER_TCR_ICPF ;/* capture not supported */ if (value &TIMER_TCR_RESERVED ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: Reserved TCR bits set\n" , __func__); } s->tcr = value;ptimer_set_limit (s->timer, s->tcor,0 );ptimer_set_freq (s->timer, freq);if (s->enabled) {/* Restart the timer if still enabled. */ ptimer_run (s->timer,0 ); }ptimer_transaction_commit (s->timer);break ;case OFFSET_TCPR :if (s->feat &TIMER_FEAT_CAPT ) { s->tcpr = value;break ; } -/* fallthrough */ + fallthrough;default :qemu_log_mask (LOG_GUEST_ERROR ,"%s: Bad offset 0x%" HWADDR_PRIx"\n" , __func__, offset); }sh_timer_update (s); }
Signature · 1 line
2.39.2
RFC PATCH 12/78 hw/usb: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- hw/usb/dev-mtp.c | 2 +- hw/usb/dev-wacom.c | 2 +- hw/usb/hcd-ehci.c | 4 +++- hw/usb/hcd-xhci.c | 4 ++-- hw/usb/redirect.c | 4 ++-- hw/usb/tusb6010.c | 2 +- 6 files changed, 10 insertions(+), 8 deletions(-)
hw/usb/dev-mtp.c +1 -1
@@ -1602,76 +1602,76 @@ static int usb_mtp_update_object(MTPObject *parent, char *name)static void usb_mtp_write_data (MTPState *s,uint32_t handle) {MTPData *d = s->data_out;MTPObject *parent =usb_mtp_object_lookup (s, s->dataset.parent_handle);char *path =NULL ;uint64_t rc;mode_t mask =0755 ;int ret =0 ;assert (d !=NULL );switch (d->write_status) {case WRITE_START :if (!parent || !s->write_pending) {usb_mtp_queue_result (s,RES_INVALID_OBJECTINFO , d->trans,0 ,0 ,0 ,0 );return ; }if (s->dataset.filename) { path =g_strdup_printf ("%s/%s" , parent->path, s->dataset.filename);if (s->dataset.format ==FMT_ASSOCIATION ) { ret =g_mkdir (path, mask);if (!ret) {usb_mtp_queue_result (s,RES_OK , d->trans,3 ,QEMU_STORAGE_ID , s->dataset.parent_handle, handle); goto close; } goto done; } d->fd =open (path,O_CREAT |O_WRONLY |O_CLOEXEC |O_NOFOLLOW , mask &0666 );if (d->fd ==-1 ) { ret =1 ; goto done; }/* Return success if initiator sent 0 sized data */ if (!s->dataset.size) { goto done; }if (d->length !=MTP_WRITE_BUF_SZ && !d->pending) { d->write_status =WRITE_END ; } } -/* fall through */ + fallthrough;case WRITE_CONTINUE :case WRITE_END : rc =write_retry (d->fd, d->data, d->data_offset, d->offset - d->data_offset);if (rc != d->data_offset) { ret =1 ; goto done; }if (d->write_status !=WRITE_END ) {g_free (path);return ; }else {/* * Return an incomplete transfer if file size doesn't match * for < 4G file or if lstat fails which will result in an incorrect * file size */ if ((s->dataset.size !=0xFFFFFFFF && d->offset != s->dataset.size) ||usb_mtp_update_object (parent, s->dataset.filename)) {usb_mtp_queue_result (s,RES_INCOMPLETE_TRANSFER , d->trans,0 ,0 ,0 ,0 ); goto close; } } }
hw/usb/dev-wacom.c +1 -1
@@ -371,27 +371,27 @@ static void usb_wacom_handle_control(USBDevice *dev, USBPacket *p,static void usb_wacom_handle_data (USBDevice *dev,USBPacket *p) {USBWacomState *s = (USBWacomState *) dev; g_autofree uint8_t *buf = g_malloc(p->iov.size);int len =0 ;switch (p->pid) {case USB_TOKEN_IN :if (p->ep->nr ==1 ) {if (!(s->changed || s->idle)) { p->status =USB_RET_NAK ;return ; } s->changed =0 ;if (s->mode ==WACOM_MODE_HID ) len =usb_mouse_poll (s, buf, p->iov.size);else if (s->mode ==WACOM_MODE_WACOM ) len =usb_wacom_poll (s, buf, p->iov.size);usb_packet_copy (p, buf, len);break ; } -/* Fall through. */ + fallthrough;case USB_TOKEN_OUT :default : p->status =USB_RET_STALL ; } }
hw/usb/hcd-ehci.c +3 -1
@@ -1402,116 +1402,116 @@ static int ehci_execute(EHCIPacket *p, const char *action)static int ehci_process_itd (EHCIState *ehci,EHCIitd *itd,uint32_t addr) {USBDevice *dev;USBEndpoint *ep;uint32_t i, len, pid, dir, devaddr, endp;uint32_t pg, off, ptr1, ptr2, max, mult; ehci->periodic_sched_active =PERIODIC_ACTIVE ; dir =(itd->bufptr[1 ] &ITD_BUFPTR_DIRECTION ); devaddr =get_field (itd->bufptr[0 ],ITD_BUFPTR_DEVADDR ); endp =get_field (itd->bufptr[0 ],ITD_BUFPTR_EP ); max =get_field (itd->bufptr[1 ],ITD_BUFPTR_MAXPKT ); mult =get_field (itd->bufptr[2 ],ITD_BUFPTR_MULT );for (i =0 ; i <8 ; i++) {if (itd->transact[i] &ITD_XACT_ACTIVE ) { pg =get_field (itd->transact[i],ITD_XACT_PGSEL ); off = itd->transact[i] &ITD_XACT_OFFSET_MASK ; len =get_field (itd->transact[i],ITD_XACT_LENGTH );if (len > max * mult) { len = max * mult; }if (len >BUFF_SIZE || pg >6 ) {return -1 ; } ptr1 = (itd->bufptr[pg] &ITD_BUFPTR_MASK );qemu_sglist_init (&ehci->isgl, ehci->device,2 , ehci->as);if (off + len >4096 ) {/* transfer crosses page border */ if (pg ==6 ) {qemu_sglist_destroy (&ehci->isgl);return -1 ;/* avoid page pg + 1 */ } ptr2 = (itd->bufptr[pg +1 ] &ITD_BUFPTR_MASK );uint32_t len2 = off + len -4096 ;uint32_t len1 = len - len2;qemu_sglist_add (&ehci->isgl, ptr1 + off, len1);qemu_sglist_add (&ehci->isgl, ptr2, len2); }else {qemu_sglist_add (&ehci->isgl, ptr1 + off, len); } dev =ehci_find_device (ehci, devaddr);if (dev ==NULL ) {ehci_trace_guest_bug (ehci,"no device found" ); ehci->ipacket.status =USB_RET_NODEV ; ehci->ipacket.actual_length =0 ; }else { pid = dir ?USB_TOKEN_IN :USB_TOKEN_OUT ; ep =usb_ep_get (dev, pid, endp);if (ep && ep->type ==USB_ENDPOINT_XFER_ISOC ) {usb_packet_setup (&ehci->ipacket, pid, ep,0 , addr, false, (itd->transact[i] &ITD_XACT_IOC ) !=0 );if (usb_packet_map (&ehci->ipacket, &ehci->isgl)) {qemu_sglist_destroy (&ehci->isgl);return -1 ; }usb_handle_packet (dev, &ehci->ipacket);usb_packet_unmap (&ehci->ipacket, &ehci->isgl); }else {DPRINTF ("ISOCH: attempt to address non-iso endpoint\n" ); ehci->ipacket.status =USB_RET_NAK ; ehci->ipacket.actual_length =0 ; } }qemu_sglist_destroy (&ehci->isgl);switch (ehci->ipacket.status) {case USB_RET_SUCCESS :break ;default :fprintf (stderr,"Unexpected iso usb result: %d\n" , ehci->ipacket.status); -/* Fall through */ + fallthrough;case USB_RET_IOERROR :case USB_RET_NODEV :/* 3.3.2: XACTERR is only allowed on IN transactions */ if (dir) { itd->transact[i] |=ITD_XACT_XACTERR ;ehci_raise_irq (ehci,USBSTS_ERRINT ); }break ;case USB_RET_BABBLE : itd->transact[i] |=ITD_XACT_BABBLE ;ehci_raise_irq (ehci,USBSTS_ERRINT );break ;case USB_RET_NAK :/* no data for us, so do a zero-length transfer */ ehci->ipacket.actual_length =0 ;break ; }if (!dir) {set_field (&itd->transact[i], len - ehci->ipacket.actual_length,ITD_XACT_LENGTH );/* OUT */ }else {set_field (&itd->transact[i], ehci->ipacket.actual_length,ITD_XACT_LENGTH );/* IN */ }if (itd->transact[i] &ITD_XACT_IOC ) {ehci_raise_irq (ehci,USBSTS_INT ); } itd->transact[i] &= ~ITD_XACT_ACTIVE ; } }return 0 ; }/* This state is the entry point for asynchronous schedule * processing. Entry here constitutes a EHCI start event state (4.8.5) */
@@ -2132,54 +2132,55 @@ static void ehci_advance_state(EHCIState *ehci, int async)static void ehci_advance_async_state (EHCIState *ehci) {const int async =1 ;switch (ehci_get_state (ehci, async)) {case EST_INACTIVE :if (!ehci_async_enabled (ehci)) {break ; }ehci_set_state (ehci, async,EST_ACTIVE );// No break, fall through to ACTIVE + fallthrough;case EST_ACTIVE :if (!ehci_async_enabled (ehci)) {ehci_queues_rip_all (ehci, async);ehci_set_state (ehci, async,EST_INACTIVE );break ; }/* make sure guest has acknowledged the doorbell interrupt */ /* TO-DO: is this really needed? */ if (ehci->usbsts &USBSTS_IAA ) {DPRINTF ("IAA status bit still set.\n" );break ; }/* check that address register has been set */ if (ehci->asynclistaddr ==0 ) {break ; }ehci_set_state (ehci, async,EST_WAITLISTHEAD );ehci_advance_state (ehci, async);/* If the doorbell is set, the guest wants to make a change to the * schedule. The host controller needs to release cached data. * (section 4.8.2) */ if (ehci->usbcmd &USBCMD_IAAD ) {/* Remove all unseen qhs from the async qhs queue */ ehci_queues_rip_unseen (ehci, async);trace_usb_ehci_doorbell_ack (); ehci->usbcmd &= ~USBCMD_IAAD ;ehci_raise_irq (ehci,USBSTS_IAA ); }break ;default :/* this should only be due to a developer mistake */ fprintf (stderr,"ehci: Bad asynchronous state %d. " "Resetting to active\n" , ehci->astate);g_assert_not_reached (); } }
@@ -2187,49 +2188,50 @@ static void ehci_advance_async_state(EHCIState *ehci)static void ehci_advance_periodic_state (EHCIState *ehci) {uint32_t entry;uint32_t list;const int async =0 ;// 4.6 switch (ehci_get_state (ehci, async)) {case EST_INACTIVE :if (!(ehci->frindex &7 ) &&ehci_periodic_enabled (ehci)) {ehci_set_state (ehci, async,EST_ACTIVE );// No break, fall through to ACTIVE + fallthrough; }else break ;case EST_ACTIVE :if (!(ehci->frindex &7 ) && !ehci_periodic_enabled (ehci)) {ehci_queues_rip_all (ehci, async);ehci_set_state (ehci, async,EST_INACTIVE );break ; } list = ehci->periodiclistbase &0xfffff000 ;/* check that register has been set */ if (list ==0 ) {break ; } list |= ((ehci->frindex &0x1ff8 ) >>1 );if (get_dwords (ehci, list, &entry,1 ) <0 ) {break ; }DPRINTF ("PERIODIC state adv fr=%d. [%08X] -> %08X\n" , ehci->frindex /8 , list, entry);ehci_set_fetch_addr (ehci, async,entry);ehci_set_state (ehci, async,EST_FETCHENTRY );ehci_advance_state (ehci, async);ehci_queues_rip_unused (ehci, async);break ;default :/* this should only be due to a developer mistake */ fprintf (stderr,"ehci: Bad periodic state %d. " "Resetting to active\n" , ehci->pstate);g_assert_not_reached (); } }
hw/usb/hcd-xhci.c +2 -2
@@ -1438,41 +1438,41 @@ static TRBCCode xhci_set_ep_dequeue(XHCIState *xhci, unsigned int slotid,static int xhci_xfer_create_sgl (XHCITransfer *xfer,int in_xfer) {XHCIState *xhci = xfer->epctx->xhci;int i; xfer->int_req = false;qemu_sglist_init (&xfer->sgl,DEVICE (xhci), xfer->trb_count, xhci->as);for (i =0 ; i < xfer->trb_count; i++) {XHCITRB *trb = &xfer->trbs[i];dma_addr_t addr;unsigned int chunk =0 ;if (trb->control &TRB_TR_IOC ) { xfer->int_req = true; }switch (TRB_TYPE (*trb)) {case TR_DATA :if ((!(trb->control &TRB_TR_DIR )) != (!in_xfer)) {DPRINTF ("xhci: data direction mismatch for TR_DATA\n" ); goto err; } -/* fallthrough */ + fallthrough;case TR_NORMAL :case TR_ISOCH : addr =xhci_mask64 (trb->parameter); chunk = trb->status &0x1ffff ;if (trb->control &TRB_TR_IDT ) {if (chunk >8 || in_xfer) {DPRINTF ("xhci: invalid immediate data TRB\n" ); goto err; }qemu_sglist_add (&xfer->sgl, trb->addr, chunk); }else {qemu_sglist_add (&xfer->sgl, addr, chunk); }break ; } }return 0 ;
@@ -2666,28 +2666,28 @@ static void xhci_port_update(XHCIPort *port, int is_detach)static void xhci_port_reset (XHCIPort *port,bool warm_reset) {trace_usb_xhci_port_reset (port->portnr, warm_reset);if (!xhci_port_have_device (port)) {return ; }usb_device_reset (port->uport->dev);switch (port->uport->dev->speed) {case USB_SPEED_SUPER :if (warm_reset) { port->portsc |=PORTSC_WRC ; } -/* fall through */ + fallthrough;case USB_SPEED_LOW :case USB_SPEED_FULL :case USB_SPEED_HIGH :set_field (&port->portsc,PLS_U0 ,PORTSC_PLS );trace_usb_xhci_port_link (port->portnr,PLS_U0 ); port->portsc |=PORTSC_PED ;break ; } port->portsc &= ~PORTSC_PR ;xhci_port_notify (port,PORTSC_PRC ); }
hw/usb/redirect.c +2 -2
@@ -1790,67 +1790,67 @@ static void usbredir_setup_usb_eps(USBRedirDevice *dev)static void usbredir_ep_info (void *priv,struct usb_redir_ep_info_header *ep_info) {USBRedirDevice *dev = priv;int i;assert (dev !=NULL );for (i =0 ; i <MAX_ENDPOINTS ; i++) { dev->endpoint[i].type = ep_info->type[i]; dev->endpoint[i].interval = ep_info->interval[i]; dev->endpoint[i].interface = ep_info->interface[i];if (usbredirparser_peer_has_cap (dev->parser, usb_redir_cap_ep_info_max_packet_size)) { dev->endpoint[i].max_packet_size = ep_info->max_packet_size[i]; }#if USBREDIR_VERSION >=0x000700 if (usbredirparser_peer_has_cap (dev->parser, usb_redir_cap_bulk_streams)) { dev->endpoint[i].max_streams = ep_info->max_streams[i]; }#endif switch (dev->endpoint[i].type) {case usb_redir_type_invalid:break ;case usb_redir_type_iso:usbredir_mark_speed_incompatible (dev,USB_SPEED_FULL );usbredir_mark_speed_incompatible (dev,USB_SPEED_HIGH ); -/* Fall through */ + fallthrough;case usb_redir_type_interrupt:if (!usbredirparser_peer_has_cap (dev->parser, usb_redir_cap_ep_info_max_packet_size) || ep_info->max_packet_size[i] >64 ) {usbredir_mark_speed_incompatible (dev,USB_SPEED_FULL ); }if (!usbredirparser_peer_has_cap (dev->parser, usb_redir_cap_ep_info_max_packet_size) || ep_info->max_packet_size[i] >1024 ) {usbredir_mark_speed_incompatible (dev,USB_SPEED_HIGH ); }if (dev->endpoint[i].interval ==0 ) {ERROR ("Received 0 interval for isoc or irq endpoint\n" );usbredir_reject_device (dev);return ; } -/* Fall through */ + fallthrough;case usb_redir_type_control:case usb_redir_type_bulk:DPRINTF ("ep: %02X type: %d interface: %d\n" ,I2EP (i), dev->endpoint[i].type, dev->endpoint[i].interface);break ;default :ERROR ("Received invalid endpoint type\n" );usbredir_reject_device (dev);return ; } }/* The new ep info may have caused a speed incompatibility, recheck */ if (dev->dev.attached && !(dev->dev.port->speedmask & dev->dev.speedmask)) {ERROR ("Device no longer matches speed after endpoint info change, " "disconnecting!\n" );usbredir_reject_device (dev);return ; }usbredir_setup_usb_eps (dev);usbredir_check_bulk_receiving (dev); }
hw/usb/tusb6010.c +1 -1
@@ -706,48 +706,48 @@ static void tusb_power_tick(void *opaque)static void tusb_musb_core_intr (void *opaque,int source,int level) {TUSBState *s = (TUSBState *) opaque;uint16_t otg_status = s->otg_status;switch (source) {case musb_set_vbus:if (level) otg_status |=TUSB_DEV_OTG_STAT_VBUS_VALID ;else otg_status &= ~TUSB_DEV_OTG_STAT_VBUS_VALID ;/* XXX: only if TUSB_PHY_OTG_CTRL_OTG_VBUS_DET_EN set? */ /* XXX: only if TUSB_PRCM_MNGMT_OTG_VBUS_DET_EN set? */ if (s->otg_status != otg_status) { s->otg_status = otg_status; s->intr |=TUSB_INT_SRC_VBUS_SENSE_CHNG ;tusb_intr_update (s); }break ;case musb_set_session:/* XXX: only if TUSB_PHY_OTG_CTRL_OTG_SESS_END_EN set? */ /* XXX: only if TUSB_PRCM_MNGMT_OTG_SESS_END_EN set? */ if (level) { s->otg_status |=TUSB_DEV_OTG_STAT_SESS_VALID ; s->otg_status &= ~TUSB_DEV_OTG_STAT_SESS_END ; }else { s->otg_status &= ~TUSB_DEV_OTG_STAT_SESS_VALID ; s->otg_status |=TUSB_DEV_OTG_STAT_SESS_END ; }/* XXX: some IRQ or anything? */ break ;case musb_irq_tx:case musb_irq_rx: s->usbip_intr =musb_core_intr_get (s->musb); -/* Fall through. */ + fallthrough;default :if (level) s->intr |=1 << source;else s->intr &= ~(1 << source);tusb_intr_update (s);break ; } }
Signature · 1 line
2.39.2
RFC PATCH 13/78 hw/adc: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- hw/adc/aspeed_adc.c | 12 ++++++------ hw/adc/zynq-xadc.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
hw/adc/aspeed_adc.c +6 -6
@@ -107,59 +107,59 @@ static uint32_t read_channel_sample(AspeedADCEngineState *s, int reg)static uint64_t aspeed_adc_engine_read (void *opaque,hwaddr addr,unsigned int size) {AspeedADCEngineState *s =ASPEED_ADC_ENGINE (opaque);int reg =TO_REG (addr);uint32_t value =0 ;switch (reg) { case BOUNDS_CHANNEL_8 ... BOUNDS_CHANNEL_15:if (s->nr_channels <=8 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: engine[%u]: " "bounds register %u invalid, only 0...7 valid\n" , __func__, s->engine_id, reg -BOUNDS_CHANNEL_0 );break ; } -/* fallthrough */ + fallthrough; case HYSTERESIS_CHANNEL_8 ... HYSTERESIS_CHANNEL_15:if (s->nr_channels <=8 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: engine[%u]: " "hysteresis register %u invalid, only 0...7 valid\n" , __func__, s->engine_id, reg -HYSTERESIS_CHANNEL_0 );break ; } -/* fallthrough */ + fallthrough; case BOUNDS_CHANNEL_0 ... BOUNDS_CHANNEL_7: case HYSTERESIS_CHANNEL_0 ... HYSTERESIS_CHANNEL_7:case ENGINE_CONTROL :case INTERRUPT_CONTROL :case VGA_DETECT_CONTROL :case CLOCK_CONTROL :case INTERRUPT_SOURCE :case COMPENSATING_AND_TRIMMING : value = s->regs[reg];break ; case DATA_CHANNEL_9_AND_8 ... DATA_CHANNEL_15_AND_14:if (s->nr_channels <=8 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: engine[%u]: " "data register %u invalid, only 0...3 valid\n" , __func__, s->engine_id, reg -DATA_CHANNEL_1_AND_0 );break ; } -/* fallthrough */ + fallthrough; case DATA_CHANNEL_1_AND_0 ... DATA_CHANNEL_7_AND_6: value =read_channel_sample (s, reg);/* Allow 16-bit reads of the data registers */ if (addr &0x2 ) {assert (size ==2 ); value >>=16 ; }break ;default :qemu_log_mask (LOG_UNIMP ,"%s: engine[%u]: 0x%" HWADDR_PRIx"\n" , __func__, s->engine_id, addr);break ; }trace_aspeed_adc_engine_read (s->engine_id, addr, value);return value; }
@@ -167,69 +167,69 @@ static uint64_t aspeed_adc_engine_read(void *opaque, hwaddr addr,static void aspeed_adc_engine_write (void *opaque,hwaddr addr,uint64_t value,unsigned int size) {AspeedADCEngineState *s =ASPEED_ADC_ENGINE (opaque);int reg =TO_REG (addr);uint32_t init =0 ;trace_aspeed_adc_engine_write (s->engine_id, addr, value);switch (reg) {case ENGINE_CONTROL : init = !!(value &ASPEED_ADC_ENGINE_EN ); init *=ASPEED_ADC_ENGINE_INIT ; value &= ~ASPEED_ADC_ENGINE_INIT ; value |= init; value &= ~ASPEED_ADC_ENGINE_AUTO_COMP ;break ;case INTERRUPT_CONTROL :case VGA_DETECT_CONTROL :case CLOCK_CONTROL :break ; case DATA_CHANNEL_9_AND_8 ... DATA_CHANNEL_15_AND_14:if (s->nr_channels <=8 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: engine[%u]: " "data register %u invalid, only 0...3 valid\n" , __func__, s->engine_id, reg -DATA_CHANNEL_1_AND_0 );return ; } -/* fallthrough */ + fallthrough; case BOUNDS_CHANNEL_8 ... BOUNDS_CHANNEL_15:if (s->nr_channels <=8 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: engine[%u]: " "bounds register %u invalid, only 0...7 valid\n" , __func__, s->engine_id, reg -BOUNDS_CHANNEL_0 );return ; } -/* fallthrough */ + fallthrough; case DATA_CHANNEL_1_AND_0 ... DATA_CHANNEL_7_AND_6: case BOUNDS_CHANNEL_0 ... BOUNDS_CHANNEL_7: value &=ASPEED_ADC_LH_MASK ;break ; case HYSTERESIS_CHANNEL_8 ... HYSTERESIS_CHANNEL_15:if (s->nr_channels <=8 ) {qemu_log_mask (LOG_GUEST_ERROR ,"%s: engine[%u]: " "hysteresis register %u invalid, only 0...7 valid\n" , __func__, s->engine_id, reg -HYSTERESIS_CHANNEL_0 );return ; } -/* fallthrough */ + fallthrough; case HYSTERESIS_CHANNEL_0 ... HYSTERESIS_CHANNEL_7: value &= (ASPEED_ADC_HYST_EN |ASPEED_ADC_LH_MASK );break ;case INTERRUPT_SOURCE : value &=0xffff ;break ;case COMPENSATING_AND_TRIMMING : value &=0xf ;break ;default :qemu_log_mask (LOG_UNIMP ,"%s: engine[%u]: " "0x%" HWADDR_PRIx" 0x%" PRIx64"\n" , __func__, s->engine_id, addr, value);break ; } s->regs[reg] = value; }
hw/adc/zynq-xadc.c +1 -1
@@ -189,61 +189,61 @@ static uint64_t zynq_xadc_read(void *opaque, hwaddr offset, unsigned size)static void zynq_xadc_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) {ZynqXADCState *s = (ZynqXADCState *)opaque;int reg = offset /4 ;int xadc_reg;int xadc_cmd;int xadc_data;if (!zynq_xadc_check_offset (reg, false)) {qemu_log_mask (LOG_GUEST_ERROR ,"zynq_xadc: Invalid write access " "to addr %" HWADDR_PRIx"\n" , offset);return ; }switch (reg) {case CFG : s->regs[CFG ] = val;break ;case INT_STS : s->regs[INT_STS ] &= ~val;break ;case INT_MASK : s->regs[INT_MASK ] = val &INT_ALL ;break ;case CMDFIFO : xadc_cmd =extract32 (val,26 ,4 ); xadc_reg =extract32 (val,16 ,10 ); xadc_data =extract32 (val,0 ,16 );if (s->regs[MCTL ] &MCTL_RESET ) {qemu_log_mask (LOG_GUEST_ERROR ,"zynq_xadc: Sending command " "while comm channel held in reset: %" PRIx32"\n" , (uint32_t ) val);break ; }if (xadc_reg >=ZYNQ_XADC_NUM_ADC_REGS && xadc_cmd !=CMD_NOP ) {qemu_log_mask (LOG_GUEST_ERROR ,"read/write op to invalid xadc " "reg 0x%x\n" , xadc_reg);break ; }switch (xadc_cmd) {case CMD_READ :xadc_push_dfifo (s, s->xadc_regs[xadc_reg]);break ;case CMD_WRITE : s->xadc_regs[xadc_reg] = xadc_data; -/* fallthrough */ + fallthrough;case CMD_NOP :xadc_push_dfifo (s,0 );break ; }break ;case MCTL : s->regs[MCTL ] = val &0x00fffeff ;break ; }zynq_xadc_update_ints (s); }
Signature · 1 line
2.39.2
Re: [RFC PATCH 13/78] hw/adc: add fallthrough pseudo-keyword
Quoted 8 lines · Emmanouil Pitsidianakis
In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
Signed-off-by Emmanouil Pitsidianakis <[email protected]>--- hw/adc/aspeed_adc.c | 12 ++++++------ hw/adc/zynq-xadc.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
For aspeed,
Thanks,
C.
RFC PATCH 14/78 util/error-report.c: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- util/error-report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
util/error-report.c +1 -1
@@ -353,36 +353,36 @@ static char *qemu_glog_domains;static void qemu_log_func (const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,gpointer user_data) {switch (log_level &G_LOG_LEVEL_MASK ) {case G_LOG_LEVEL_DEBUG :case G_LOG_LEVEL_INFO :/* * Use same G_MESSAGES_DEBUG logic as glib to enable/disable debug * messages */ if (qemu_glog_domains ==NULL ) {break ; }if (strcmp (qemu_glog_domains,"all" ) !=0 && (log_domain ==NULL || !strstr (qemu_glog_domains, log_domain))) {break ; } -/* Fall through */ + fallthrough;case G_LOG_LEVEL_MESSAGE :info_report ("%s%s%s" , log_domain ?:"" , log_domain ?": " :"" , message);break ;case G_LOG_LEVEL_WARNING :warn_report ("%s%s%s" , log_domain ?:"" , log_domain ?": " :"" , message);break ;case G_LOG_LEVEL_CRITICAL :case G_LOG_LEVEL_ERROR :error_report ("%s%s%s" , log_domain ?:"" , log_domain ?": " :"" , message);break ; } }
Signature · 1 line
2.39.2
RFC PATCH 15/78 accel/tcg: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- accel/tcg/cputlb.c | 4 ++-- accel/tcg/ldst_atomicity.c.inc | 2 +- accel/tcg/plugin-gen.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
accel/tcg/cputlb.c +2 -2
@@ -2209,53 +2209,53 @@ static Int128 do_ld_whole_be16(CPUState *cpu, uintptr_t ra,/* * Wrapper for the above. */ static uint64_t do_ld_beN (CPUState *cpu,MMULookupPageData *p,uint64_t ret_be,int mmu_idx,MMUAccessType type,MemOp mop,uintptr_t ra) {MemOp atom;unsigned tmp, half_size;if (unlikely (p->flags &TLB_MMIO )) {return do_ld_mmio_beN (cpu, p->full, ret_be, p->addr, p->size, mmu_idx, type, ra); }/* * It is a given that we cross a page and therefore there is no * atomicity for the load as a whole, but subobjects may need attention. */ atom = mop &MO_ATOM_MASK ;switch (atom) {case MO_ATOM_SUBALIGN :return do_ld_parts_beN (p, ret_be);case MO_ATOM_IFALIGN_PAIR :case MO_ATOM_WITHIN16_PAIR : tmp = mop &MO_SIZE ; tmp = tmp ? tmp -1 :0 ; half_size =1 << tmp;if (atom ==MO_ATOM_IFALIGN_PAIR ? p->size == half_size : p->size >= half_size) {if (!HAVE_al8_fast && p->size <4 ) {return do_ld_whole_be4 (p, ret_be); }else {return do_ld_whole_be8 (cpu, ra, p, ret_be); } } -/* fall through */ + fallthrough;case MO_ATOM_IFALIGN :case MO_ATOM_WITHIN16 :case MO_ATOM_NONE :return do_ld_bytes_beN (p, ret_be);default :g_assert_not_reached (); } }/* * Wrapper for the above, for 8 < size < 16. */
@@ -2625,57 +2625,57 @@ static uint64_t do_st16_mmio_leN(CPUState *cpu, CPUTLBEntryFull *full,/* * Wrapper for the above. */ static uint64_t do_st_leN (CPUState *cpu,MMULookupPageData *p,uint64_t val_le,int mmu_idx,MemOp mop,uintptr_t ra) {MemOp atom;unsigned tmp, half_size;if (unlikely (p->flags &TLB_MMIO )) {return do_st_mmio_leN (cpu, p->full, val_le, p->addr, p->size, mmu_idx, ra); }else if (unlikely (p->flags &TLB_DISCARD_WRITE )) {return val_le >> (p->size *8 ); }/* * It is a given that we cross a page and therefore there is no atomicity * for the store as a whole, but subobjects may need attention. */ atom = mop &MO_ATOM_MASK ;switch (atom) {case MO_ATOM_SUBALIGN :return store_parts_leN (p->haddr, p->size, val_le);case MO_ATOM_IFALIGN_PAIR :case MO_ATOM_WITHIN16_PAIR : tmp = mop &MO_SIZE ; tmp = tmp ? tmp -1 :0 ; half_size =1 << tmp;if (atom ==MO_ATOM_IFALIGN_PAIR ? p->size == half_size : p->size >= half_size) {if (!HAVE_al8_fast && p->size <=4 ) {return store_whole_le4 (p->haddr, p->size, val_le); }else if (HAVE_al8) {return store_whole_le8 (p->haddr, p->size, val_le); }else {cpu_loop_exit_atomic (cpu, ra); } } -/* fall through */ + fallthrough;case MO_ATOM_IFALIGN :case MO_ATOM_WITHIN16 :case MO_ATOM_NONE :return store_bytes_leN (p->haddr, p->size, val_le);default :g_assert_not_reached (); } }/* * Wrapper for the above, for 8 < size < 16. */
accel/tcg/ldst_atomicity.c.inc +1 -1
@@ -22,86 +22,86 @@ /** * required_atomicity: * * Return the lg2 bytes of atomicity required by @memop for @p. * If the operation must be split into two operations to be * examined separately for atomicity, return -lg2. */ static int required_atomicity(CPUState *cpu, uintptr_t p, MemOp memop) { MemOp atom = memop & MO_ATOM_MASK; MemOp size = memop & MO_SIZE; MemOp half = size ? size - 1 : 0; unsigned tmp; int atmax; switch (atom) { case MO_ATOM_NONE: atmax = MO_8; break; case MO_ATOM_IFALIGN_PAIR: size = half; - /* fall through */ + fallthrough; case MO_ATOM_IFALIGN: tmp = (1 << size) - 1; atmax = p & tmp ? MO_8 : size; break; case MO_ATOM_WITHIN16: tmp = p & 15; atmax = (tmp + (1 << size) <= 16 ? size : MO_8); break; case MO_ATOM_WITHIN16_PAIR: tmp = p & 15; if (tmp + (1 << size) <= 16) { atmax = size; } else if (tmp + (1 << half) == 16) { /* * The pair exactly straddles the boundary. * Both halves are naturally aligned and atomic. */ atmax = half; } else { /* * One of the pair crosses the boundary, and is non-atomic. * The other of the pair does not cross, and is atomic. */ atmax = -half; } break; case MO_ATOM_SUBALIGN: /* * Examine the alignment of p to determine if there are subobjects * that must be aligned. Note that we only really need ctz4() -- * any more sigificant bits are discarded by the immediately * following comparison. */ tmp = ctz32(p); atmax = MIN(size, tmp); break; default: g_assert_not_reached(); } /* * Here we have the architectural atomicity of the operation. * However, when executing in a serial context, we need no extra * host atomicity in order to avoid racing. This reduction * avoids looping with cpu_loop_exit_atomic. */ if (cpu_in_serial_context(cpu)) { return MO_8; } return atmax; } /** * load_atomic2: * @pv: host address * * Atomically load 2 aligned bytes from @pv. */
accel/tcg/plugin-gen.c +1 -1
@@ -179,23 +179,23 @@ static void gen_wrapped(enum plugin_gen_from from,static void plugin_gen_empty_callback (enum plugin_gen_from from) {switch (from) {case PLUGIN_GEN_AFTER_INSN :gen_wrapped (from,PLUGIN_GEN_DISABLE_MEM_HELPER , gen_empty_mem_helper);break ;case PLUGIN_GEN_FROM_INSN :/* * Note: plugin_gen_inject() relies on ENABLE_MEM_HELPER being * the first callback of an instruction */ gen_wrapped (from,PLUGIN_GEN_ENABLE_MEM_HELPER , gen_empty_mem_helper); -/* fall through */ + fallthrough;case PLUGIN_GEN_FROM_TB :gen_wrapped (from,PLUGIN_GEN_CB_UDATA , gen_empty_udata_cb);gen_wrapped (from,PLUGIN_GEN_CB_INLINE , gen_empty_inline_cb);break ;default :g_assert_not_reached (); } }
Signature · 1 line
2.39.2
RFC PATCH 16/78 audio: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- audio/audio.c | 16 ++++++++-------- audio/jackaudio.c | 4 ++-- audio/pwaudio.c | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-)
audio/audio.c +8 -8
@@ -245,39 +245,39 @@ static int audio_validate_settings (struct audsettings *as)static int audio_pcm_info_eq (struct audio_pcm_info *info,struct audsettings *as) {int bits =8 ;bool is_signed = false, is_float = false;switch (as->fmt) {case AUDIO_FORMAT_S8 : is_signed = true; -/* fall through */ + fallthrough;case AUDIO_FORMAT_U8 :break ;case AUDIO_FORMAT_S16 : is_signed = true; -/* fall through */ + fallthrough;case AUDIO_FORMAT_U16 : bits =16 ;break ;case AUDIO_FORMAT_F32 : is_float = true; -/* fall through */ + fallthrough;case AUDIO_FORMAT_S32 : is_signed = true; -/* fall through */ + fallthrough;case AUDIO_FORMAT_U32 : bits =32 ;break ;default :abort (); }return info->freq == as->freq && info->nchannels == as->nchannels && info->is_signed == is_signed && info->is_float == is_float && info->bits == bits && info->swap_endianness == (as->endianness !=AUDIO_HOST_ENDIANNESS ); }
@@ -285,45 +285,45 @@ static int audio_pcm_info_eq (struct audio_pcm_info *info, struct audsettings *avoid audio_pcm_init_info (struct audio_pcm_info *info,struct audsettings *as) {int bits =8 , mul;bool is_signed = false, is_float = false;switch (as->fmt) {case AUDIO_FORMAT_S8 : is_signed = true; -/* fall through */ + fallthrough;case AUDIO_FORMAT_U8 : mul =1 ;break ;case AUDIO_FORMAT_S16 : is_signed = true; -/* fall through */ + fallthrough;case AUDIO_FORMAT_U16 : bits =16 ; mul =2 ;break ;case AUDIO_FORMAT_F32 : is_float = true; -/* fall through */ + fallthrough;case AUDIO_FORMAT_S32 : is_signed = true; -/* fall through */ + fallthrough;case AUDIO_FORMAT_U32 : bits =32 ; mul =4 ;break ;default :abort (); } info->freq = as->freq; info->bits = bits; info->is_signed = is_signed; info->is_float = is_float; info->nchannels = as->nchannels; info->bytes_per_frame = as->nchannels * mul; info->bytes_per_second = info->freq * info->bytes_per_frame; info->swap_endianness = (as->endianness !=AUDIO_HOST_ENDIANNESS ); }
audio/jackaudio.c +2 -2
@@ -574,22 +574,22 @@ static int qjack_init_in(HWVoiceIn *hw, struct audsettings *as,static void qjack_client_fini_locked (QJackClient *c) {switch (c->state) {case QJACK_STATE_RUNNING :jack_deactivate (c->client); -/* fallthrough */ + fallthrough;case QJACK_STATE_SHUTDOWN :jack_client_close (c->client); c->client =NULL ;qjack_buffer_free (&c->fifo);g_free (c->port);g_free (c->process_buffers); c->state =QJACK_STATE_DISCONNECTED ; -/* fallthrough */ + fallthrough;case QJACK_STATE_DISCONNECTED :break ; } }
audio/pwaudio.c +2 -2
@@ -487,31 +487,31 @@ static void qpw_set_position(uint32_t channels, uint32_t position[SPA_AUDIO_MAX_CHANNELS]) { memcpy(position, (uint32_t[SPA_AUDIO_MAX_CHANNELS]) { SPA_AUDIO_CHANNEL_UNKNOWN, }, sizeof(uint32_t) * SPA_AUDIO_MAX_CHANNELS);/* * TODO: This currently expects the only frontend supporting more than 2 * channels is the usb-audio. We will need some means to set channel * order when a new frontend gains multi-channel support. */ switch (channels) {case 8 : position[6 ] =SPA_AUDIO_CHANNEL_SL ; position[7 ] =SPA_AUDIO_CHANNEL_SR ; -/* fallthrough */ + fallthrough;case 6 : position[2 ] =SPA_AUDIO_CHANNEL_FC ; position[3 ] =SPA_AUDIO_CHANNEL_LFE ; position[4 ] =SPA_AUDIO_CHANNEL_RL ; position[5 ] =SPA_AUDIO_CHANNEL_RR ; -/* fallthrough */ + fallthrough;case 2 : position[0 ] =SPA_AUDIO_CHANNEL_FL ; position[1 ] =SPA_AUDIO_CHANNEL_FR ;break ;case 1 : position[0 ] =SPA_AUDIO_CHANNEL_MONO ;break ;default :dolog ("Internal error: unsupported channel count %d\n" , channels); } }
Signature · 1 line
2.39.2
RFC PATCH 17/78 ui/sdl2.c: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- ui/sdl2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ui/sdl2.c +1 -1
@@ -576,78 +576,78 @@ static void handle_mousewheel(SDL_Event *ev)static void handle_windowevent (SDL_Event *ev) {struct sdl2_console *scon =get_scon_from_window (ev->window.windowID);bool allow_close = true;if (!scon) {return ; }switch (ev->window.event) {case SDL_WINDOWEVENT_RESIZED : {QemuUIInfo info;memset (&info,0 ,sizeof (info)); info.width = ev->window.data1; info.height = ev->window.data2;dpy_set_ui_info (scon->dcl.con, &info, true); }sdl2_redraw (scon);break ;case SDL_WINDOWEVENT_EXPOSED :sdl2_redraw (scon);break ;case SDL_WINDOWEVENT_FOCUS_GAINED :win32_kbd_set_grab (gui_grab);if (qemu_console_is_graphic (scon->dcl.con)) {win32_kbd_set_window (sdl2_win32_get_hwnd (scon)); } -/* fall through */ + fallthrough;case SDL_WINDOWEVENT_ENTER :if (!gui_grab && (qemu_input_is_absolute (scon->dcl.con) || absolute_enabled)) {absolute_mouse_grab (scon); }/* If a new console window opened using a hotkey receives the * focus, SDL sends another KEYDOWN event to the new window, * closing the console window immediately after. * * Work around this by ignoring further hotkey events until a * key is released. */ scon->ignore_hotkeys =get_mod_state ();break ;case SDL_WINDOWEVENT_FOCUS_LOST :if (qemu_console_is_graphic (scon->dcl.con)) {win32_kbd_set_window (NULL ); }if (gui_grab && !gui_fullscreen) {sdl_grab_end (scon); }break ;case SDL_WINDOWEVENT_RESTORED :update_displaychangelistener (&scon->dcl,GUI_REFRESH_INTERVAL_DEFAULT );break ;case SDL_WINDOWEVENT_MINIMIZED :update_displaychangelistener (&scon->dcl,500 );break ;case SDL_WINDOWEVENT_CLOSE :if (qemu_console_is_graphic (scon->dcl.con)) {if (scon->opts->has_window_close && !scon->opts->window_close) { allow_close = false; }if (allow_close) { shutdown_action =SHUTDOWN_ACTION_POWEROFF ;qemu_system_shutdown_request (SHUTDOWN_CAUSE_HOST_UI ); } }else {SDL_HideWindow (scon->real_window); scon->hidden = true; }break ;case SDL_WINDOWEVENT_SHOWN : scon->hidden = false;break ;case SDL_WINDOWEVENT_HIDDEN : scon->hidden = true;break ; } }
Signature · 1 line
2.39.2
RFC PATCH 18/78 ui/win32-kbd-hook.c: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- ui/win32-kbd-hook.c | 7 ------- 1 file changed, 7 deletions(-)
ui/win32-kbd-hook.c +0 -7
@@ -18,59 +18,52 @@ static DWORD win32_grab; static LRESULT CALLBACK keyboard_hook_cb(int code, WPARAM wparam, LPARAM lparam) {if (win32_window && code ==HC_ACTION && win32_window ==GetFocus ()) {KBDLLHOOKSTRUCT *hooked = (KBDLLHOOKSTRUCT *)lparam;if (wparam !=WM_KEYUP ) {DWORD dwmsg = (hooked->flags <<24 ) | ((hooked->scanCode &0xff ) <<16 ) |1 ;switch (hooked->vkCode) {case VK_CAPITAL : -/* fall through */ case VK_SCROLL : -/* fall through */ case VK_NUMLOCK : -/* fall through */ case VK_LSHIFT : -/* fall through */ case VK_RSHIFT : -/* fall through */ case VK_RCONTROL : -/* fall through */ case VK_LMENU : -/* fall through */ case VK_RMENU :break ;case VK_LCONTROL :/* * When pressing AltGr, an extra VK_LCONTROL with a special * scancode with bit 9 set is sent. Let's ignore the extra * VK_LCONTROL, as that will make AltGr misbehave. */ if (hooked->scanCode &0x200 ) {return 1 ; }break ;default :if (win32_grab) {SendMessage (win32_window, wparam, hooked->vkCode, dwmsg);return 1 ; }break ; } }else {switch (hooked->vkCode) {case VK_LCONTROL :if (hooked->scanCode &0x200 ) {return 1 ; }break ; } } }return CallNextHookEx (NULL , code, wparam, lparam); }
Signature · 1 line
2.39.2
RFC PATCH 19/78 target/hppa: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- target/hppa/translate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
target/hppa/translate.c +5 -5
@@ -480,14 +480,14 @@ static DisasCond cond_make(TCGCond c, TCGv_reg a0, TCGv_reg a1)static void cond_free (DisasCond *cond) {switch (cond->c) {default : cond->a0 =NULL ; cond->a1 =NULL ; -/* fallthru */ + fallthrough;case TCG_COND_ALWAYS : cond->c =TCG_COND_NEVER ;break ;case TCG_COND_NEVER :break ; } }
@@ -3831,65 +3831,65 @@ static bool trans_fcmp_d(DisasContext *ctx, arg_fclass2 *a)static bool trans_ftest (DisasContext *ctx,arg_ftest *a) {TCGv_reg t;nullify_over (ctx); t =get_temp (ctx);tcg_gen_ld32u_reg (t, tcg_env, offsetof(CPUHPPAState , fr0_shadow));if (a->y ==1 ) {int mask;bool inv = false;switch (a->c) {case 0 :/* simple */ tcg_gen_andi_reg (t, t,0x4000000 ); ctx->null_cond =cond_make_0 (TCG_COND_NE , t); goto done;case 2 :/* rej */ inv = true; -/* fallthru */ + fallthrough;case 1 :/* acc */ mask =0x43ff800 ;break ;case 6 :/* rej8 */ inv = true; -/* fallthru */ + fallthrough;case 5 :/* acc8 */ mask =0x43f8000 ;break ;case 9 :/* acc6 */ mask =0x43e0000 ;break ;case 13 :/* acc4 */ mask =0x4380000 ;break ;case 17 :/* acc2 */ mask =0x4200000 ;break ;default :gen_illegal (ctx);return true; }if (inv) {TCGv_reg c =load_const (ctx, mask);tcg_gen_or_reg (t, t, c); ctx->null_cond =cond_make (TCG_COND_EQ , t, c); }else {tcg_gen_andi_reg (t, t, mask); ctx->null_cond =cond_make_0 (TCG_COND_EQ , t); } }else {unsigned cbit = (a->y ^1 ) -1 ;tcg_gen_extract_reg (t, t,21 - cbit,1 ); ctx->null_cond =cond_make_0 (TCG_COND_NE , t); } done:return nullify_end (ctx); }/* * Float class 2 */
@@ -4219,28 +4219,28 @@ static void hppa_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)static void hppa_tr_tb_stop (DisasContextBase *dcbase,CPUState *cs) {DisasContext *ctx =container_of (dcbase, DisasContext, base);DisasJumpType is_jmp = ctx->base.is_jmp;switch (is_jmp) {case DISAS_NORETURN :break ;case DISAS_TOO_MANY :case DISAS_IAQ_N_STALE :case DISAS_IAQ_N_STALE_EXIT :copy_iaoq_entry (cpu_iaoq_f, ctx->iaoq_f, cpu_iaoq_f);copy_iaoq_entry (cpu_iaoq_b, ctx->iaoq_b, cpu_iaoq_b);nullify_save (ctx); -/* FALLTHRU */ + fallthrough;case DISAS_IAQ_N_UPDATED :if (is_jmp !=DISAS_IAQ_N_STALE_EXIT ) {tcg_gen_lookup_and_goto_ptr ();break ; } -/* FALLTHRU */ + fallthrough;case DISAS_EXIT :tcg_gen_exit_tb (NULL ,0 );break ;default :g_assert_not_reached (); } }
Signature · 1 line
2.39.2
RFC PATCH 20/78 target/mips: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- target/mips/sysemu/physaddr.c | 2 +- target/mips/tcg/micromips_translate.c.inc | 4 +- target/mips/tcg/mips16e_translate.c.inc | 30 ++++----- target/mips/tcg/mxu_translate.c | 8 +-- target/mips/tcg/nanomips_translate.c.inc | 4 +- target/mips/tcg/op_helper.c | 2 +- target/mips/tcg/translate.c | 79 ++++++++++++----------- 7 files changed, 66 insertions(+), 63 deletions(-)
target/mips/sysemu/physaddr.c +1 -1
@@ -24,52 +24,52 @@static int is_seg_am_mapped (unsigned int am,bool eu,int mmu_idx) {/* * Interpret access control mode and mmu_idx. * AdE? TLB? * AM K S U E K S U E * UK 0 0 1 1 0 0 - - 0 * MK 1 0 1 1 0 1 - - !eu * MSK 2 0 0 1 0 1 1 - !eu * MUSK 3 0 0 0 0 1 1 1 !eu * MUSUK 4 0 0 0 0 0 1 1 0 * USK 5 0 0 1 0 0 0 - 0 * - 6 - - - - - - - - * UUSK 7 0 0 0 0 0 0 0 0 */ int32_t adetlb_mask;switch (mmu_idx) {case 3 :/* ERL */ /* If EU is set, always unmapped */ if (eu) {return 0 ; } -/* fall through */ + fallthrough;case MIPS_HFLAG_KM :/* Never AdE, TLB mapped if AM={1,2,3} */ adetlb_mask =0x70000000 ; goto check_tlb;case MIPS_HFLAG_SM :/* AdE if AM={0,1}, TLB mapped if AM={2,3,4} */ adetlb_mask =0xc0380000 ; goto check_ade;case MIPS_HFLAG_UM :/* AdE if AM={0,1,2,5}, TLB mapped if AM={3,4} */ adetlb_mask =0xe4180000 ;/* fall through */ check_ade:/* does this AM cause AdE in current execution mode */ if ((adetlb_mask << am) <0 ) {return TLBRET_BADADDR ; } adetlb_mask <<=8 ;/* fall through */ check_tlb:/* is this AM mapped in current execution mode */ return ((adetlb_mask << am) <0 );default :g_assert_not_reached (); }; }
target/mips/tcg/micromips_translate.c.inc +2 -2
@@ -1621,1353 +1621,1353 @@ static void gen_pool32fxf(DisasContext *ctx, int rt, int rs) static void decode_micromips32_opc(CPUMIPSState *env, DisasContext *ctx) { int32_t offset; uint16_t insn; int rt, rs, rd, rr; int16_t imm; uint32_t op, minor, minor2, mips32_op; uint32_t cond, fmt, cc; insn = translator_lduw(env, &ctx->base, ctx->base.pc_next + 2); ctx->opcode = (ctx->opcode << 16) | insn; rt = (ctx->opcode >> 21) & 0x1f; rs = (ctx->opcode >> 16) & 0x1f; rd = (ctx->opcode >> 11) & 0x1f; rr = (ctx->opcode >> 6) & 0x1f; imm = (int16_t) ctx->opcode; op = (ctx->opcode >> 26) & 0x3f; switch (op) { case POOL32A: minor = ctx->opcode & 0x3f; switch (minor) { case 0x00: minor = (ctx->opcode >> 6) & 0xf; switch (minor) { case SLL32: mips32_op = OPC_SLL; goto do_shifti; case SRA: mips32_op = OPC_SRA; goto do_shifti; case SRL32: mips32_op = OPC_SRL; goto do_shifti; case ROTR: mips32_op = OPC_ROTR; do_shifti: gen_shift_imm(ctx, mips32_op, rt, rs, rd); break; case SELEQZ: check_insn(ctx, ISA_MIPS_R6); gen_cond_move(ctx, OPC_SELEQZ, rd, rs, rt); break; case SELNEZ: check_insn(ctx, ISA_MIPS_R6); gen_cond_move(ctx, OPC_SELNEZ, rd, rs, rt); break; case R6_RDHWR: check_insn(ctx, ISA_MIPS_R6); gen_rdhwr(ctx, rt, rs, extract32(ctx->opcode, 11, 3)); break; default: goto pool32a_invalid; } break; case 0x10: minor = (ctx->opcode >> 6) & 0xf; switch (minor) { /* Arithmetic */ case ADD: mips32_op = OPC_ADD; goto do_arith; case ADDU32: mips32_op = OPC_ADDU; goto do_arith; case SUB: mips32_op = OPC_SUB; goto do_arith; case SUBU32: mips32_op = OPC_SUBU; goto do_arith; case MUL: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_MUL; do_arith: gen_arith(ctx, mips32_op, rd, rs, rt); break; /* Shifts */ case SLLV: mips32_op = OPC_SLLV; goto do_shift; case SRLV: mips32_op = OPC_SRLV; goto do_shift; case SRAV: mips32_op = OPC_SRAV; goto do_shift; case ROTRV: mips32_op = OPC_ROTRV; do_shift: gen_shift(ctx, mips32_op, rd, rs, rt); break; /* Logical operations */ case AND: mips32_op = OPC_AND; goto do_logic; case OR32: mips32_op = OPC_OR; goto do_logic; case NOR: mips32_op = OPC_NOR; goto do_logic; case XOR32: mips32_op = OPC_XOR; do_logic: gen_logic(ctx, mips32_op, rd, rs, rt); break; /* Set less than */ case SLT: mips32_op = OPC_SLT; goto do_slt; case SLTU: mips32_op = OPC_SLTU; do_slt: gen_slt(ctx, mips32_op, rd, rs, rt); break; default: goto pool32a_invalid; } break; case 0x18: minor = (ctx->opcode >> 6) & 0xf; switch (minor) { /* Conditional moves */ case MOVN: /* MUL */ if (ctx->insn_flags & ISA_MIPS_R6) { /* MUL */ gen_r6_muldiv(ctx, R6_OPC_MUL, rd, rs, rt); } else { /* MOVN */ gen_cond_move(ctx, OPC_MOVN, rd, rs, rt); } break; case MOVZ: /* MUH */ if (ctx->insn_flags & ISA_MIPS_R6) { /* MUH */ gen_r6_muldiv(ctx, R6_OPC_MUH, rd, rs, rt); } else { /* MOVZ */ gen_cond_move(ctx, OPC_MOVZ, rd, rs, rt); } break; case MULU: check_insn(ctx, ISA_MIPS_R6); gen_r6_muldiv(ctx, R6_OPC_MULU, rd, rs, rt); break; case MUHU: check_insn(ctx, ISA_MIPS_R6); gen_r6_muldiv(ctx, R6_OPC_MUHU, rd, rs, rt); break; case LWXS: /* DIV */ if (ctx->insn_flags & ISA_MIPS_R6) { /* DIV */ gen_r6_muldiv(ctx, R6_OPC_DIV, rd, rs, rt); } else { /* LWXS */ gen_ldxs(ctx, rs, rt, rd); } break; case MOD: check_insn(ctx, ISA_MIPS_R6); gen_r6_muldiv(ctx, R6_OPC_MOD, rd, rs, rt); break; case R6_DIVU: check_insn(ctx, ISA_MIPS_R6); gen_r6_muldiv(ctx, R6_OPC_DIVU, rd, rs, rt); break; case MODU: check_insn(ctx, ISA_MIPS_R6); gen_r6_muldiv(ctx, R6_OPC_MODU, rd, rs, rt); break; default: goto pool32a_invalid; } break; case INS: gen_bitops(ctx, OPC_INS, rt, rs, rr, rd); return; case LSA: check_insn(ctx, ISA_MIPS_R6); gen_lsa(ctx, rd, rt, rs, extract32(ctx->opcode, 9, 2)); break; case ALIGN: check_insn(ctx, ISA_MIPS_R6); gen_align(ctx, 32, rd, rs, rt, extract32(ctx->opcode, 9, 2)); break; case EXT: gen_bitops(ctx, OPC_EXT, rt, rs, rr, rd); return; case POOL32AXF: gen_pool32axf(env, ctx, rt, rs); break; case BREAK32: generate_exception_break(ctx, extract32(ctx->opcode, 6, 20)); break; case SIGRIE: check_insn(ctx, ISA_MIPS_R6); gen_reserved_instruction(ctx); break; default: pool32a_invalid: MIPS_INVAL("pool32a"); gen_reserved_instruction(ctx); break; } break; case POOL32B: minor = (ctx->opcode >> 12) & 0xf; switch (minor) { case CACHE: check_cp0_enabled(ctx); if (ctx->hflags & MIPS_HFLAG_ITC_CACHE) { gen_cache_operation(ctx, rt, rs, imm); } break; case LWC2: case SWC2: /* COP2: Not implemented. */ generate_exception_err(ctx, EXCP_CpU, 2); break; #ifdef TARGET_MIPS64 case LDP: case SDP: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); #endif - /* fall through */ + fallthrough; case LWP: case SWP: gen_ldst_pair(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12)); break; #ifdef TARGET_MIPS64 case LDM: case SDM: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); #endif - /* fall through */ + fallthrough; case LWM32: case SWM32: gen_ldst_multiple(ctx, minor, rt, rs, SIMM(ctx->opcode, 0, 12)); break; default: MIPS_INVAL("pool32b"); gen_reserved_instruction(ctx); break; } break; case POOL32F: if (ctx->CP0_Config1 & (1 << CP0C1_FP)) { minor = ctx->opcode & 0x3f; check_cp1_enabled(ctx); switch (minor) { case ALNV_PS: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_ALNV_PS; goto do_madd; case MADD_S: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_MADD_S; goto do_madd; case MADD_D: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_MADD_D; goto do_madd; case MADD_PS: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_MADD_PS; goto do_madd; case MSUB_S: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_MSUB_S; goto do_madd; case MSUB_D: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_MSUB_D; goto do_madd; case MSUB_PS: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_MSUB_PS; goto do_madd; case NMADD_S: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_NMADD_S; goto do_madd; case NMADD_D: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_NMADD_D; goto do_madd; case NMADD_PS: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_NMADD_PS; goto do_madd; case NMSUB_S: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_NMSUB_S; goto do_madd; case NMSUB_D: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_NMSUB_D; goto do_madd; case NMSUB_PS: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_NMSUB_PS; do_madd: gen_flt3_arith(ctx, mips32_op, rd, rr, rs, rt); break; case CABS_COND_FMT: check_insn_opc_removed(ctx, ISA_MIPS_R6); cond = (ctx->opcode >> 6) & 0xf; cc = (ctx->opcode >> 13) & 0x7; fmt = (ctx->opcode >> 10) & 0x3; switch (fmt) { case 0x0: gen_cmpabs_s(ctx, cond, rt, rs, cc); break; case 0x1: gen_cmpabs_d(ctx, cond, rt, rs, cc); break; case 0x2: gen_cmpabs_ps(ctx, cond, rt, rs, cc); break; default: goto pool32f_invalid; } break; case C_COND_FMT: check_insn_opc_removed(ctx, ISA_MIPS_R6); cond = (ctx->opcode >> 6) & 0xf; cc = (ctx->opcode >> 13) & 0x7; fmt = (ctx->opcode >> 10) & 0x3; switch (fmt) { case 0x0: gen_cmp_s(ctx, cond, rt, rs, cc); break; case 0x1: gen_cmp_d(ctx, cond, rt, rs, cc); break; case 0x2: gen_cmp_ps(ctx, cond, rt, rs, cc); break; default: goto pool32f_invalid; } break; case CMP_CONDN_S: check_insn(ctx, ISA_MIPS_R6); gen_r6_cmp_s(ctx, (ctx->opcode >> 6) & 0x1f, rt, rs, rd); break; case CMP_CONDN_D: check_insn(ctx, ISA_MIPS_R6); gen_r6_cmp_d(ctx, (ctx->opcode >> 6) & 0x1f, rt, rs, rd); break; case POOL32FXF: gen_pool32fxf(ctx, rt, rs); break; case 0x00: /* PLL foo */ switch ((ctx->opcode >> 6) & 0x7) { case PLL_PS: mips32_op = OPC_PLL_PS; goto do_ps; case PLU_PS: mips32_op = OPC_PLU_PS; goto do_ps; case PUL_PS: mips32_op = OPC_PUL_PS; goto do_ps; case PUU_PS: mips32_op = OPC_PUU_PS; goto do_ps; case CVT_PS_S: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_CVT_PS_S; do_ps: gen_farith(ctx, mips32_op, rt, rs, rd, 0); break; default: goto pool32f_invalid; } break; case MIN_FMT: check_insn(ctx, ISA_MIPS_R6); switch ((ctx->opcode >> 9) & 0x3) { case FMT_SDPS_S: gen_farith(ctx, OPC_MIN_S, rt, rs, rd, 0); break; case FMT_SDPS_D: gen_farith(ctx, OPC_MIN_D, rt, rs, rd, 0); break; default: goto pool32f_invalid; } break; case 0x08: /* [LS][WDU]XC1 */ switch ((ctx->opcode >> 6) & 0x7) { case LWXC1: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_LWXC1; goto do_ldst_cp1; case SWXC1: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_SWXC1; goto do_ldst_cp1; case LDXC1: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_LDXC1; goto do_ldst_cp1; case SDXC1: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_SDXC1; goto do_ldst_cp1; case LUXC1: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_LUXC1; goto do_ldst_cp1; case SUXC1: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_SUXC1; do_ldst_cp1: gen_flt3_ldst(ctx, mips32_op, rd, rd, rt, rs); break; default: goto pool32f_invalid; } break; case MAX_FMT: check_insn(ctx, ISA_MIPS_R6); switch ((ctx->opcode >> 9) & 0x3) { case FMT_SDPS_S: gen_farith(ctx, OPC_MAX_S, rt, rs, rd, 0); break; case FMT_SDPS_D: gen_farith(ctx, OPC_MAX_D, rt, rs, rd, 0); break; default: goto pool32f_invalid; } break; case 0x18: /* 3D insns */ check_insn_opc_removed(ctx, ISA_MIPS_R6); fmt = (ctx->opcode >> 9) & 0x3; switch ((ctx->opcode >> 6) & 0x7) { case RSQRT2_FMT: switch (fmt) { case FMT_SDPS_S: mips32_op = OPC_RSQRT2_S; goto do_3d; case FMT_SDPS_D: mips32_op = OPC_RSQRT2_D; goto do_3d; case FMT_SDPS_PS: mips32_op = OPC_RSQRT2_PS; goto do_3d; default: goto pool32f_invalid; } break; case RECIP2_FMT: switch (fmt) { case FMT_SDPS_S: mips32_op = OPC_RECIP2_S; goto do_3d; case FMT_SDPS_D: mips32_op = OPC_RECIP2_D; goto do_3d; case FMT_SDPS_PS: mips32_op = OPC_RECIP2_PS; goto do_3d; default: goto pool32f_invalid; } break; case ADDR_PS: mips32_op = OPC_ADDR_PS; goto do_3d; case MULR_PS: mips32_op = OPC_MULR_PS; do_3d: gen_farith(ctx, mips32_op, rt, rs, rd, 0); break; default: goto pool32f_invalid; } break; case 0x20: /* MOV[FT].fmt, PREFX, RINT.fmt, CLASS.fmt*/ cc = (ctx->opcode >> 13) & 0x7; fmt = (ctx->opcode >> 9) & 0x3; switch ((ctx->opcode >> 6) & 0x7) { case MOVF_FMT: /* RINT_FMT */ if (ctx->insn_flags & ISA_MIPS_R6) { /* RINT_FMT */ switch (fmt) { case FMT_SDPS_S: gen_farith(ctx, OPC_RINT_S, 0, rt, rs, 0); break; case FMT_SDPS_D: gen_farith(ctx, OPC_RINT_D, 0, rt, rs, 0); break; default: goto pool32f_invalid; } } else { /* MOVF_FMT */ switch (fmt) { case FMT_SDPS_S: gen_movcf_s(ctx, rs, rt, cc, 0); break; case FMT_SDPS_D: gen_movcf_d(ctx, rs, rt, cc, 0); break; case FMT_SDPS_PS: check_ps(ctx); gen_movcf_ps(ctx, rs, rt, cc, 0); break; default: goto pool32f_invalid; } } break; case MOVT_FMT: /* CLASS_FMT */ if (ctx->insn_flags & ISA_MIPS_R6) { /* CLASS_FMT */ switch (fmt) { case FMT_SDPS_S: gen_farith(ctx, OPC_CLASS_S, 0, rt, rs, 0); break; case FMT_SDPS_D: gen_farith(ctx, OPC_CLASS_D, 0, rt, rs, 0); break; default: goto pool32f_invalid; } } else { /* MOVT_FMT */ switch (fmt) { case FMT_SDPS_S: gen_movcf_s(ctx, rs, rt, cc, 1); break; case FMT_SDPS_D: gen_movcf_d(ctx, rs, rt, cc, 1); break; case FMT_SDPS_PS: check_ps(ctx); gen_movcf_ps(ctx, rs, rt, cc, 1); break; default: goto pool32f_invalid; } } break; case PREFX: check_insn_opc_removed(ctx, ISA_MIPS_R6); break; default: goto pool32f_invalid; } break; #define FINSN_3ARG_SDPS(prfx) \ switch ((ctx->opcode >> 8) & 0x3) { \ case FMT_SDPS_S: \ mips32_op = OPC_##prfx##_S; \ goto do_fpop; \ case FMT_SDPS_D: \ mips32_op = OPC_##prfx##_D; \ goto do_fpop; \ case FMT_SDPS_PS: \ check_ps(ctx); \ mips32_op = OPC_##prfx##_PS; \ goto do_fpop; \ default: \ goto pool32f_invalid; \ } case MINA_FMT: check_insn(ctx, ISA_MIPS_R6); switch ((ctx->opcode >> 9) & 0x3) { case FMT_SDPS_S: gen_farith(ctx, OPC_MINA_S, rt, rs, rd, 0); break; case FMT_SDPS_D: gen_farith(ctx, OPC_MINA_D, rt, rs, rd, 0); break; default: goto pool32f_invalid; } break; case MAXA_FMT: check_insn(ctx, ISA_MIPS_R6); switch ((ctx->opcode >> 9) & 0x3) { case FMT_SDPS_S: gen_farith(ctx, OPC_MAXA_S, rt, rs, rd, 0); break; case FMT_SDPS_D: gen_farith(ctx, OPC_MAXA_D, rt, rs, rd, 0); break; default: goto pool32f_invalid; } break; case 0x30: /* regular FP ops */ switch ((ctx->opcode >> 6) & 0x3) { case ADD_FMT: FINSN_3ARG_SDPS(ADD); break; case SUB_FMT: FINSN_3ARG_SDPS(SUB); break; case MUL_FMT: FINSN_3ARG_SDPS(MUL); break; case DIV_FMT: fmt = (ctx->opcode >> 8) & 0x3; if (fmt == 1) { mips32_op = OPC_DIV_D; } else if (fmt == 0) { mips32_op = OPC_DIV_S; } else { goto pool32f_invalid; } goto do_fpop; default: goto pool32f_invalid; } break; case 0x38: /* cmovs */ switch ((ctx->opcode >> 6) & 0x7) { case MOVN_FMT: /* SELEQZ_FMT */ if (ctx->insn_flags & ISA_MIPS_R6) { /* SELEQZ_FMT */ switch ((ctx->opcode >> 9) & 0x3) { case FMT_SDPS_S: gen_sel_s(ctx, OPC_SELEQZ_S, rd, rt, rs); break; case FMT_SDPS_D: gen_sel_d(ctx, OPC_SELEQZ_D, rd, rt, rs); break; default: goto pool32f_invalid; } } else { /* MOVN_FMT */ FINSN_3ARG_SDPS(MOVN); } break; case MOVN_FMT_04: check_insn_opc_removed(ctx, ISA_MIPS_R6); FINSN_3ARG_SDPS(MOVN); break; case MOVZ_FMT: /* SELNEZ_FMT */ if (ctx->insn_flags & ISA_MIPS_R6) { /* SELNEZ_FMT */ switch ((ctx->opcode >> 9) & 0x3) { case FMT_SDPS_S: gen_sel_s(ctx, OPC_SELNEZ_S, rd, rt, rs); break; case FMT_SDPS_D: gen_sel_d(ctx, OPC_SELNEZ_D, rd, rt, rs); break; default: goto pool32f_invalid; } } else { /* MOVZ_FMT */ FINSN_3ARG_SDPS(MOVZ); } break; case MOVZ_FMT_05: check_insn_opc_removed(ctx, ISA_MIPS_R6); FINSN_3ARG_SDPS(MOVZ); break; case SEL_FMT: check_insn(ctx, ISA_MIPS_R6); switch ((ctx->opcode >> 9) & 0x3) { case FMT_SDPS_S: gen_sel_s(ctx, OPC_SEL_S, rd, rt, rs); break; case FMT_SDPS_D: gen_sel_d(ctx, OPC_SEL_D, rd, rt, rs); break; default: goto pool32f_invalid; } break; case MADDF_FMT: check_insn(ctx, ISA_MIPS_R6); switch ((ctx->opcode >> 9) & 0x3) { case FMT_SDPS_S: mips32_op = OPC_MADDF_S; goto do_fpop; case FMT_SDPS_D: mips32_op = OPC_MADDF_D; goto do_fpop; default: goto pool32f_invalid; } break; case MSUBF_FMT: check_insn(ctx, ISA_MIPS_R6); switch ((ctx->opcode >> 9) & 0x3) { case FMT_SDPS_S: mips32_op = OPC_MSUBF_S; goto do_fpop; case FMT_SDPS_D: mips32_op = OPC_MSUBF_D; goto do_fpop; default: goto pool32f_invalid; } break; default: goto pool32f_invalid; } break; do_fpop: gen_farith(ctx, mips32_op, rt, rs, rd, 0); break; default: pool32f_invalid: MIPS_INVAL("pool32f"); gen_reserved_instruction(ctx); break; } } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; case POOL32I: minor = (ctx->opcode >> 21) & 0x1f; switch (minor) { case BLTZ: check_insn_opc_removed(ctx, ISA_MIPS_R6); gen_compute_branch(ctx, OPC_BLTZ, 4, rs, -1, imm << 1, 4); break; case BLTZAL: check_insn_opc_removed(ctx, ISA_MIPS_R6); gen_compute_branch(ctx, OPC_BLTZAL, 4, rs, -1, imm << 1, 4); ctx->hflags |= MIPS_HFLAG_BDS_STRICT; break; case BLTZALS: check_insn_opc_removed(ctx, ISA_MIPS_R6); gen_compute_branch(ctx, OPC_BLTZAL, 4, rs, -1, imm << 1, 2); ctx->hflags |= MIPS_HFLAG_BDS_STRICT; break; case BGEZ: check_insn_opc_removed(ctx, ISA_MIPS_R6); gen_compute_branch(ctx, OPC_BGEZ, 4, rs, -1, imm << 1, 4); break; case BGEZAL: check_insn_opc_removed(ctx, ISA_MIPS_R6); gen_compute_branch(ctx, OPC_BGEZAL, 4, rs, -1, imm << 1, 4); ctx->hflags |= MIPS_HFLAG_BDS_STRICT; break; case BGEZALS: check_insn_opc_removed(ctx, ISA_MIPS_R6); gen_compute_branch(ctx, OPC_BGEZAL, 4, rs, -1, imm << 1, 2); ctx->hflags |= MIPS_HFLAG_BDS_STRICT; break; case BLEZ: check_insn_opc_removed(ctx, ISA_MIPS_R6); gen_compute_branch(ctx, OPC_BLEZ, 4, rs, -1, imm << 1, 4); break; case BGTZ: check_insn_opc_removed(ctx, ISA_MIPS_R6); gen_compute_branch(ctx, OPC_BGTZ, 4, rs, -1, imm << 1, 4); break; /* Traps */ case TLTI: /* BC1EQZC */ if (ctx->insn_flags & ISA_MIPS_R6) { /* BC1EQZC */ check_cp1_enabled(ctx); gen_compute_branch1_r6(ctx, OPC_BC1EQZ, rs, imm << 1, 0); } else { /* TLTI */ mips32_op = OPC_TLTI; goto do_trapi; } break; case TGEI: /* BC1NEZC */ if (ctx->insn_flags & ISA_MIPS_R6) { /* BC1NEZC */ check_cp1_enabled(ctx); gen_compute_branch1_r6(ctx, OPC_BC1NEZ, rs, imm << 1, 0); } else { /* TGEI */ mips32_op = OPC_TGEI; goto do_trapi; } break; case TLTIU: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_TLTIU; goto do_trapi; case TGEIU: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_TGEIU; goto do_trapi; case TNEI: /* SYNCI */ if (ctx->insn_flags & ISA_MIPS_R6) { /* SYNCI */ /* * Break the TB to be able to sync copied instructions * immediately. */ ctx->base.is_jmp = DISAS_STOP; } else { /* TNEI */ mips32_op = OPC_TNEI; goto do_trapi; } break; case TEQI: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_TEQI; do_trapi: gen_trap(ctx, mips32_op, rs, -1, imm, 0); break; case BNEZC: case BEQZC: check_insn_opc_removed(ctx, ISA_MIPS_R6); gen_compute_branch(ctx, minor == BNEZC ? OPC_BNE : OPC_BEQ, 4, rs, 0, imm << 1, 0); /* * Compact branches don't have a delay slot, so just let * the normal delay slot handling take us to the branch * target. */ break; case LUI: check_insn_opc_removed(ctx, ISA_MIPS_R6); gen_logic_imm(ctx, OPC_LUI, rs, 0, imm); break; case SYNCI: check_insn_opc_removed(ctx, ISA_MIPS_R6); /* * Break the TB to be able to sync copied instructions * immediately. */ ctx->base.is_jmp = DISAS_STOP; break; case BC2F: case BC2T: check_insn_opc_removed(ctx, ISA_MIPS_R6); /* COP2: Not implemented. */ generate_exception_err(ctx, EXCP_CpU, 2); break; case BC1F: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = (ctx->opcode & (1 << 16)) ? OPC_BC1FANY2 : OPC_BC1F; goto do_cp1branch; case BC1T: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = (ctx->opcode & (1 << 16)) ? OPC_BC1TANY2 : OPC_BC1T; goto do_cp1branch; case BC1ANY4F: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_BC1FANY4; goto do_cp1mips3d; case BC1ANY4T: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_BC1TANY4; do_cp1mips3d: check_cop1x(ctx); check_insn(ctx, ASE_MIPS3D); /* Fall through */ do_cp1branch: if (env->CP0_Config1 & (1 << CP0C1_FP)) { check_cp1_enabled(ctx); gen_compute_branch1(ctx, mips32_op, (ctx->opcode >> 18) & 0x7, imm << 1); } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; default: MIPS_INVAL("pool32i"); gen_reserved_instruction(ctx); break; } break; case POOL32C: minor = (ctx->opcode >> 12) & 0xf; offset = sextract32(ctx->opcode, 0, (ctx->insn_flags & ISA_MIPS_R6) ? 9 : 12); switch (minor) { case LWL: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_LWL; goto do_ld_lr; case SWL: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_SWL; goto do_st_lr; case LWR: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_LWR; goto do_ld_lr; case SWR: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_SWR; goto do_st_lr; #if defined(TARGET_MIPS64) case LDL: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_LDL; goto do_ld_lr; case SDL: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_SDL; goto do_st_lr; case LDR: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_LDR; goto do_ld_lr; case SDR: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_SDR; goto do_st_lr; case LWU: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); mips32_op = OPC_LWU; goto do_ld_lr; case LLD: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); mips32_op = OPC_LLD; goto do_ld_lr; #endif case LL: mips32_op = OPC_LL; goto do_ld_lr; do_ld_lr: gen_ld(ctx, mips32_op, rt, rs, offset); break; do_st_lr: gen_st(ctx, mips32_op, rt, rs, offset); break; case SC: gen_st_cond(ctx, rt, rs, offset, MO_TESL, false); break; #if defined(TARGET_MIPS64) case SCD: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_st_cond(ctx, rt, rs, offset, MO_TEUQ, false); break; #endif case LD_EVA: if (!ctx->eva) { MIPS_INVAL("pool32c ld-eva"); gen_reserved_instruction(ctx); break; } check_cp0_enabled(ctx); minor2 = (ctx->opcode >> 9) & 0x7; offset = sextract32(ctx->opcode, 0, 9); switch (minor2) { case LBUE: mips32_op = OPC_LBUE; goto do_ld_lr; case LHUE: mips32_op = OPC_LHUE; goto do_ld_lr; case LWLE: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_LWLE; goto do_ld_lr; case LWRE: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_LWRE; goto do_ld_lr; case LBE: mips32_op = OPC_LBE; goto do_ld_lr; case LHE: mips32_op = OPC_LHE; goto do_ld_lr; case LLE: mips32_op = OPC_LLE; goto do_ld_lr; case LWE: mips32_op = OPC_LWE; goto do_ld_lr; }; break; case ST_EVA: if (!ctx->eva) { MIPS_INVAL("pool32c st-eva"); gen_reserved_instruction(ctx); break; } check_cp0_enabled(ctx); minor2 = (ctx->opcode >> 9) & 0x7; offset = sextract32(ctx->opcode, 0, 9); switch (minor2) { case SWLE: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_SWLE; goto do_st_lr; case SWRE: check_insn_opc_removed(ctx, ISA_MIPS_R6); mips32_op = OPC_SWRE; goto do_st_lr; case PREFE: /* Treat as no-op */ if ((ctx->insn_flags & ISA_MIPS_R6) && (rt >= 24)) { /* hint codes 24-31 are reserved and signal RI */ generate_exception(ctx, EXCP_RI); } break; case CACHEE: /* Treat as no-op */ if (ctx->hflags & MIPS_HFLAG_ITC_CACHE) { gen_cache_operation(ctx, rt, rs, offset); } break; case SBE: mips32_op = OPC_SBE; goto do_st_lr; case SHE: mips32_op = OPC_SHE; goto do_st_lr; case SCE: gen_st_cond(ctx, rt, rs, offset, MO_TESL, true); break; case SWE: mips32_op = OPC_SWE; goto do_st_lr; }; break; case PREF: /* Treat as no-op */ if ((ctx->insn_flags & ISA_MIPS_R6) && (rt >= 24)) { /* hint codes 24-31 are reserved and signal RI */ generate_exception(ctx, EXCP_RI); } break; default: MIPS_INVAL("pool32c"); gen_reserved_instruction(ctx); break; } break; case ADDI32: /* AUI, LUI */ if (ctx->insn_flags & ISA_MIPS_R6) { /* AUI, LUI */ gen_logic_imm(ctx, OPC_LUI, rt, rs, imm); } else { /* ADDI32 */ mips32_op = OPC_ADDI; goto do_addi; } break; case ADDIU32: mips32_op = OPC_ADDIU; do_addi: gen_arith_imm(ctx, mips32_op, rt, rs, imm); break; /* Logical operations */ case ORI32: mips32_op = OPC_ORI; goto do_logici; case XORI32: mips32_op = OPC_XORI; goto do_logici; case ANDI32: mips32_op = OPC_ANDI; do_logici: gen_logic_imm(ctx, mips32_op, rt, rs, imm); break; /* Set less than immediate */ case SLTI32: mips32_op = OPC_SLTI; goto do_slti; case SLTIU32: mips32_op = OPC_SLTIU; do_slti: gen_slt_imm(ctx, mips32_op, rt, rs, imm); break; case JALX32: check_insn_opc_removed(ctx, ISA_MIPS_R6); offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2; gen_compute_branch(ctx, OPC_JALX, 4, rt, rs, offset, 4); ctx->hflags |= MIPS_HFLAG_BDS_STRICT; break; case JALS32: /* BOVC, BEQC, BEQZALC */ if (ctx->insn_flags & ISA_MIPS_R6) { if (rs >= rt) { /* BOVC */ mips32_op = OPC_BOVC; } else if (rs < rt && rs == 0) { /* BEQZALC */ mips32_op = OPC_BEQZALC; } else { /* BEQC */ mips32_op = OPC_BEQC; } gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1); } else { /* JALS32 */ offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 1; gen_compute_branch(ctx, OPC_JAL, 4, rt, rs, offset, 2); ctx->hflags |= MIPS_HFLAG_BDS_STRICT; } break; case BEQ32: /* BC */ if (ctx->insn_flags & ISA_MIPS_R6) { /* BC */ gen_compute_compact_branch(ctx, OPC_BC, 0, 0, sextract32(ctx->opcode << 1, 0, 27)); } else { /* BEQ32 */ gen_compute_branch(ctx, OPC_BEQ, 4, rt, rs, imm << 1, 4); } break; case BNE32: /* BALC */ if (ctx->insn_flags & ISA_MIPS_R6) { /* BALC */ gen_compute_compact_branch(ctx, OPC_BALC, 0, 0, sextract32(ctx->opcode << 1, 0, 27)); } else { /* BNE32 */ gen_compute_branch(ctx, OPC_BNE, 4, rt, rs, imm << 1, 4); } break; case J32: /* BGTZC, BLTZC, BLTC */ if (ctx->insn_flags & ISA_MIPS_R6) { if (rs == 0 && rt != 0) { /* BGTZC */ mips32_op = OPC_BGTZC; } else if (rs != 0 && rt != 0 && rs == rt) { /* BLTZC */ mips32_op = OPC_BLTZC; } else { /* BLTC */ mips32_op = OPC_BLTC; } gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1); } else { /* J32 */ gen_compute_branch(ctx, OPC_J, 4, rt, rs, (int32_t)(ctx->opcode & 0x3FFFFFF) << 1, 4); } break; case JAL32: /* BLEZC, BGEZC, BGEC */ if (ctx->insn_flags & ISA_MIPS_R6) { if (rs == 0 && rt != 0) { /* BLEZC */ mips32_op = OPC_BLEZC; } else if (rs != 0 && rt != 0 && rs == rt) { /* BGEZC */ mips32_op = OPC_BGEZC; } else { /* BGEC */ mips32_op = OPC_BGEC; } gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1); } else { /* JAL32 */ gen_compute_branch(ctx, OPC_JAL, 4, rt, rs, (int32_t)(ctx->opcode & 0x3FFFFFF) << 1, 4); ctx->hflags |= MIPS_HFLAG_BDS_STRICT; } break; /* Floating point (COP1) */ case LWC132: mips32_op = OPC_LWC1; goto do_cop1; case LDC132: mips32_op = OPC_LDC1; goto do_cop1; case SWC132: mips32_op = OPC_SWC1; goto do_cop1; case SDC132: mips32_op = OPC_SDC1; do_cop1: gen_cop1_ldst(ctx, mips32_op, rt, rs, imm); break; case ADDIUPC: /* PCREL: ADDIUPC, AUIPC, ALUIPC, LWPC */ if (ctx->insn_flags & ISA_MIPS_R6) { /* PCREL: ADDIUPC, AUIPC, ALUIPC, LWPC */ switch ((ctx->opcode >> 16) & 0x1f) { case ADDIUPC_00: case ADDIUPC_01: case ADDIUPC_02: case ADDIUPC_03: case ADDIUPC_04: case ADDIUPC_05: case ADDIUPC_06: case ADDIUPC_07: gen_pcrel(ctx, OPC_ADDIUPC, ctx->base.pc_next & ~0x3, rt); break; case AUIPC: gen_pcrel(ctx, OPC_AUIPC, ctx->base.pc_next, rt); break; case ALUIPC: gen_pcrel(ctx, OPC_ALUIPC, ctx->base.pc_next, rt); break; case LWPC_08: case LWPC_09: case LWPC_0A: case LWPC_0B: case LWPC_0C: case LWPC_0D: case LWPC_0E: case LWPC_0F: gen_pcrel(ctx, R6_OPC_LWPC, ctx->base.pc_next & ~0x3, rt); break; default: generate_exception(ctx, EXCP_RI); break; } } else { /* ADDIUPC */ int reg = mmreg(ZIMM(ctx->opcode, 23, 3)); offset = SIMM(ctx->opcode, 0, 23) << 2; gen_addiupc(ctx, reg, offset, 0, 0); } break; case BNVC: /* BNEC, BNEZALC */ check_insn(ctx, ISA_MIPS_R6); if (rs >= rt) { /* BNVC */ mips32_op = OPC_BNVC; } else if (rs < rt && rs == 0) { /* BNEZALC */ mips32_op = OPC_BNEZALC; } else { /* BNEC */ mips32_op = OPC_BNEC; } gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1); break; case R6_BNEZC: /* JIALC */ check_insn(ctx, ISA_MIPS_R6); if (rt != 0) { /* BNEZC */ gen_compute_compact_branch(ctx, OPC_BNEZC, rt, 0, sextract32(ctx->opcode << 1, 0, 22)); } else { /* JIALC */ gen_compute_compact_branch(ctx, OPC_JIALC, 0, rs, imm); } break; case R6_BEQZC: /* JIC */ check_insn(ctx, ISA_MIPS_R6); if (rt != 0) { /* BEQZC */ gen_compute_compact_branch(ctx, OPC_BEQZC, rt, 0, sextract32(ctx->opcode << 1, 0, 22)); } else { /* JIC */ gen_compute_compact_branch(ctx, OPC_JIC, 0, rs, imm); } break; case BLEZALC: /* BGEZALC, BGEUC */ check_insn(ctx, ISA_MIPS_R6); if (rs == 0 && rt != 0) { /* BLEZALC */ mips32_op = OPC_BLEZALC; } else if (rs != 0 && rt != 0 && rs == rt) { /* BGEZALC */ mips32_op = OPC_BGEZALC; } else { /* BGEUC */ mips32_op = OPC_BGEUC; } gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1); break; case BGTZALC: /* BLTZALC, BLTUC */ check_insn(ctx, ISA_MIPS_R6); if (rs == 0 && rt != 0) { /* BGTZALC */ mips32_op = OPC_BGTZALC; } else if (rs != 0 && rt != 0 && rs == rt) { /* BLTZALC */ mips32_op = OPC_BLTZALC; } else { /* BLTUC */ mips32_op = OPC_BLTUC; } gen_compute_compact_branch(ctx, mips32_op, rs, rt, imm << 1); break; /* Loads and stores */ case LB32: mips32_op = OPC_LB; goto do_ld; case LBU32: mips32_op = OPC_LBU; goto do_ld; case LH32: mips32_op = OPC_LH; goto do_ld; case LHU32: mips32_op = OPC_LHU; goto do_ld; case LW32: mips32_op = OPC_LW; goto do_ld; #ifdef TARGET_MIPS64 case LD32: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); mips32_op = OPC_LD; goto do_ld; case SD32: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); mips32_op = OPC_SD; goto do_st; #endif case SB32: mips32_op = OPC_SB; goto do_st; case SH32: mips32_op = OPC_SH; goto do_st; case SW32: mips32_op = OPC_SW; goto do_st; do_ld: gen_ld(ctx, mips32_op, rt, rs, imm); break; do_st: gen_st(ctx, mips32_op, rt, rs, imm); break; default: gen_reserved_instruction(ctx); break; } }
target/mips/tcg/mips16e_translate.c.inc +15 -15
@@ -130,159 +130,159 @@ static int xlat(int r) static void gen_mips16_save(DisasContext *ctx, int xsregs, int aregs, int do_ra, int do_s0, int do_s1, int framesize) { TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); TCGv t2 = tcg_temp_new(); int args, astatic; switch (aregs) { case 0: case 1: case 2: case 3: case 11: args = 0; break; case 4: case 5: case 6: case 7: args = 1; break; case 8: case 9: case 10: args = 2; break; case 12: case 13: args = 3; break; case 14: args = 4; break; default: gen_reserved_instruction(ctx); return; } switch (args) { case 4: gen_base_offset_addr(ctx, t0, 29, 12); gen_load_gpr(t1, 7); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | ctx->default_tcg_memop_mask); - /* Fall through */ + fallthrough; case 3: gen_base_offset_addr(ctx, t0, 29, 8); gen_load_gpr(t1, 6); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | ctx->default_tcg_memop_mask); - /* Fall through */ + fallthrough; case 2: gen_base_offset_addr(ctx, t0, 29, 4); gen_load_gpr(t1, 5); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | ctx->default_tcg_memop_mask); - /* Fall through */ + fallthrough; case 1: gen_base_offset_addr(ctx, t0, 29, 0); gen_load_gpr(t1, 4); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | ctx->default_tcg_memop_mask); } gen_load_gpr(t0, 29); #define DECR_AND_STORE(reg) do { \ tcg_gen_movi_tl(t2, -4); \ gen_op_addr_add(ctx, t0, t0, t2); \ gen_load_gpr(t1, reg); \ tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | \ ctx->default_tcg_memop_mask); \ } while (0) if (do_ra) { DECR_AND_STORE(31); } switch (xsregs) { case 7: DECR_AND_STORE(30); - /* Fall through */ + fallthrough; case 6: DECR_AND_STORE(23); - /* Fall through */ + fallthrough; case 5: DECR_AND_STORE(22); - /* Fall through */ + fallthrough; case 4: DECR_AND_STORE(21); - /* Fall through */ + fallthrough; case 3: DECR_AND_STORE(20); - /* Fall through */ + fallthrough; case 2: DECR_AND_STORE(19); - /* Fall through */ + fallthrough; case 1: DECR_AND_STORE(18); } if (do_s1) { DECR_AND_STORE(17); } if (do_s0) { DECR_AND_STORE(16); } switch (aregs) { case 0: case 4: case 8: case 12: case 14: astatic = 0; break; case 1: case 5: case 9: case 13: astatic = 1; break; case 2: case 6: case 10: astatic = 2; break; case 3: case 7: astatic = 3; break; case 11: astatic = 4; break; default: gen_reserved_instruction(ctx); return; } if (astatic > 0) { DECR_AND_STORE(7); if (astatic > 1) { DECR_AND_STORE(6); if (astatic > 2) { DECR_AND_STORE(5); if (astatic > 3) { DECR_AND_STORE(4); } } } } #undef DECR_AND_STORE tcg_gen_movi_tl(t2, -framesize); gen_op_addr_add(ctx, cpu_gpr[29], cpu_gpr[29], t2); }
@@ -290,105 +290,105 @@ static void gen_mips16_save(DisasContext *ctx, static void gen_mips16_restore(DisasContext *ctx, int xsregs, int aregs, int do_ra, int do_s0, int do_s1, int framesize) { int astatic; TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); TCGv t2 = tcg_temp_new(); tcg_gen_movi_tl(t2, framesize); gen_op_addr_add(ctx, t0, cpu_gpr[29], t2); #define DECR_AND_LOAD(reg) do { \ tcg_gen_movi_tl(t2, -4); \ gen_op_addr_add(ctx, t0, t0, t2); \ tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TESL | \ ctx->default_tcg_memop_mask); \ gen_store_gpr(t1, reg); \ } while (0) if (do_ra) { DECR_AND_LOAD(31); } switch (xsregs) { case 7: DECR_AND_LOAD(30); - /* Fall through */ + fallthrough; case 6: DECR_AND_LOAD(23); - /* Fall through */ + fallthrough; case 5: DECR_AND_LOAD(22); - /* Fall through */ + fallthrough; case 4: DECR_AND_LOAD(21); - /* Fall through */ + fallthrough; case 3: DECR_AND_LOAD(20); - /* Fall through */ + fallthrough; case 2: DECR_AND_LOAD(19); - /* Fall through */ + fallthrough; case 1: DECR_AND_LOAD(18); } if (do_s1) { DECR_AND_LOAD(17); } if (do_s0) { DECR_AND_LOAD(16); } switch (aregs) { case 0: case 4: case 8: case 12: case 14: astatic = 0; break; case 1: case 5: case 9: case 13: astatic = 1; break; case 2: case 6: case 10: astatic = 2; break; case 3: case 7: astatic = 3; break; case 11: astatic = 4; break; default: gen_reserved_instruction(ctx); return; } if (astatic > 0) { DECR_AND_LOAD(7); if (astatic > 1) { DECR_AND_LOAD(6); if (astatic > 2) { DECR_AND_LOAD(5); if (astatic > 3) { DECR_AND_LOAD(4); } } } } #undef DECR_AND_LOAD tcg_gen_movi_tl(t2, framesize); gen_op_addr_add(ctx, cpu_gpr[29], cpu_gpr[29], t2); } #if defined(TARGET_MIPS64)
target/mips/tcg/mxu_translate.c +4 -4
@@ -4564,19 +4564,19 @@ static void decode_opc_mxu__pool05(DisasContext *ctx)static void decode_opc_mxu__pool06 (DisasContext *ctx) {uint32_t opcode =extract32 (ctx->opcode,10 ,4 );uint32_t strd2 =extract32 (ctx->opcode,14 ,2 );switch (opcode) {case OPC_MXU_S32LDST :case OPC_MXU_S32LDSTR :if (strd2 <=2 ) {gen_mxu_s32ldxvx (ctx, opcode, false, strd2);break ; } -/* fallthrough */ + fallthrough;default :MIPS_INVAL ("decode_opc_mxu" );gen_reserved_instruction (ctx);break ; } }
@@ -4584,19 +4584,19 @@ static void decode_opc_mxu__pool06(DisasContext *ctx)static void decode_opc_mxu__pool07 (DisasContext *ctx) {uint32_t opcode =extract32 (ctx->opcode,10 ,4 );uint32_t strd2 =extract32 (ctx->opcode,14 ,2 );switch (opcode) {case OPC_MXU_S32LDST :case OPC_MXU_S32LDSTR :if (strd2 <=2 ) {gen_mxu_s32stxvx (ctx, opcode, false, strd2);break ; } -/* fallthrough */ + fallthrough;default :MIPS_INVAL ("decode_opc_mxu" );gen_reserved_instruction (ctx);break ; } }
@@ -4630,19 +4630,19 @@ static void decode_opc_mxu__pool09(DisasContext *ctx)static void decode_opc_mxu__pool10 (DisasContext *ctx) {uint32_t opcode =extract32 (ctx->opcode,10 ,4 );uint32_t strd2 =extract32 (ctx->opcode,14 ,2 );switch (opcode) {case OPC_MXU_S32LDST :case OPC_MXU_S32LDSTR :if (strd2 <=2 ) {gen_mxu_s32ldxvx (ctx, opcode, true, strd2);break ; } -/* fallthrough */ + fallthrough;default :MIPS_INVAL ("decode_opc_mxu" );gen_reserved_instruction (ctx);break ; } }
@@ -4650,19 +4650,19 @@ static void decode_opc_mxu__pool10(DisasContext *ctx)static void decode_opc_mxu__pool11 (DisasContext *ctx) {uint32_t opcode =extract32 (ctx->opcode,10 ,4 );uint32_t strd2 =extract32 (ctx->opcode,14 ,2 );switch (opcode) {case OPC_MXU_S32LDST :case OPC_MXU_S32LDSTR :if (strd2 <=2 ) {gen_mxu_s32stxvx (ctx, opcode, true, strd2);break ; } -/* fallthrough */ + fallthrough;default :MIPS_INVAL ("decode_opc_mxu" );gen_reserved_instruction (ctx);break ; } }
target/mips/tcg/nanomips_translate.c.inc +2 -2
@@ -2604,121 +2604,121 @@ static void gen_compute_branch_cp1_nm(DisasContext *ctx, uint32_t op, static void gen_p_lsx(DisasContext *ctx, int rd, int rs, int rt) { TCGv t0, t1; t0 = tcg_temp_new(); t1 = tcg_temp_new(); gen_load_gpr(t0, rs); gen_load_gpr(t1, rt); if ((extract32(ctx->opcode, 6, 1)) == 1) { /* PP.LSXS instructions require shifting */ switch (extract32(ctx->opcode, 7, 4)) { case NM_SHXS: check_nms(ctx); - /* fall through */ + fallthrough; case NM_LHXS: case NM_LHUXS: tcg_gen_shli_tl(t0, t0, 1); break; case NM_SWXS: check_nms(ctx); - /* fall through */ + fallthrough; case NM_LWXS: case NM_LWC1XS: case NM_SWC1XS: tcg_gen_shli_tl(t0, t0, 2); break; case NM_LDC1XS: case NM_SDC1XS: tcg_gen_shli_tl(t0, t0, 3); break; default: gen_reserved_instruction(ctx); return; } } gen_op_addr_add(ctx, t0, t0, t1); switch (extract32(ctx->opcode, 7, 4)) { case NM_LBX: tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_SB); gen_store_gpr(t0, rd); break; case NM_LHX: /*case NM_LHXS:*/ tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TESW | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rd); break; case NM_LWX: /*case NM_LWXS:*/ tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TESL | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rd); break; case NM_LBUX: tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_UB); gen_store_gpr(t0, rd); break; case NM_LHUX: /*case NM_LHUXS:*/ tcg_gen_qemu_ld_tl(t0, t0, ctx->mem_idx, MO_TEUW | ctx->default_tcg_memop_mask); gen_store_gpr(t0, rd); break; case NM_SBX: check_nms(ctx); gen_load_gpr(t1, rd); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_8); break; case NM_SHX: /*case NM_SHXS:*/ check_nms(ctx); gen_load_gpr(t1, rd); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUW | ctx->default_tcg_memop_mask); break; case NM_SWX: /*case NM_SWXS:*/ check_nms(ctx); gen_load_gpr(t1, rd); tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | ctx->default_tcg_memop_mask); break; case NM_LWC1X: /*case NM_LWC1XS:*/ case NM_LDC1X: /*case NM_LDC1XS:*/ case NM_SWC1X: /*case NM_SWC1XS:*/ case NM_SDC1X: /*case NM_SDC1XS:*/ if (ctx->CP0_Config1 & (1 << CP0C1_FP)) { check_cp1_enabled(ctx); switch (extract32(ctx->opcode, 7, 4)) { case NM_LWC1X: /*case NM_LWC1XS:*/ gen_flt_ldst(ctx, OPC_LWC1, rd, t0); break; case NM_LDC1X: /*case NM_LDC1XS:*/ gen_flt_ldst(ctx, OPC_LDC1, rd, t0); break; case NM_SWC1X: /*case NM_SWC1XS:*/ gen_flt_ldst(ctx, OPC_SWC1, rd, t0); break; case NM_SDC1X: /*case NM_SDC1XS:*/ gen_flt_ldst(ctx, OPC_SDC1, rd, t0); break; } } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; default: gen_reserved_instruction(ctx); break; } }
target/mips/tcg/op_helper.c +1 -1
@@ -233,28 +233,28 @@ target_ulong helper_rdhwr_xnp(CPUMIPSState *env)void helper_pmon (CPUMIPSState *env,int function) { function /=2 ;switch (function) {case 2 :/* TODO: char inbyte(int waitflag); */ if (env->active_tc.gpr[4 ] ==0 ) { env->active_tc.gpr[2 ] =-1 ; } -/* Fall through */ + fallthrough;case 11 :/* TODO: char inbyte (void); */ env->active_tc.gpr[2 ] =-1 ;break ;case 3 :case 12 :printf ("%c" , (char )(env->active_tc.gpr[4 ] &0xFF ));break ;case 17 :break ;case 158 : {unsigned char *fmt = (void *)(uintptr_t )env->active_tc.gpr[4 ];printf ("%s" , fmt); }break ; } }#ifdef TARGET_MIPS64
target/mips/tcg/translate.c +41 -38
1,081 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.39.2
Part of the diff is not shown here. View the raw message.
RFC PATCH 21/78 target/sparc: add fallthrough pseudo-keyword
In reply to Emmanouil PitsidianakisIn preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.
--- target/sparc/ldst_helper.c | 4 ++-- target/sparc/mmu_helper.c | 6 +++--- target/sparc/translate.c | 3 ++- target/sparc/win_helper.c | 1 + 4 files changed, 8 insertions(+), 6 deletions(-)
target/sparc/ldst_helper.c +2 -2
@@ -1296,294 +1296,294 @@ void helper_st_asi(CPUSPARCState *env, target_ulong addr, target_ulong val,uint64_t helper_ld_asi (CPUSPARCState *env,target_ulong addr,int asi,uint32_t memop) {int size =1 << (memop &MO_SIZE );int sign = memop &MO_SIGN ;CPUState *cs =env_cpu (env);uint64_t ret =0 ;#if defined(DEBUG_ASI )target_ulong last_addr = addr;#endif asi &=0xff ;do_check_asi (env, asi,GETPC ());do_check_align (env, addr, size -1 ,GETPC ()); addr =asi_address_mask (env, asi, addr);switch (asi) {case ASI_PNF :case ASI_PNFL :case ASI_SNF :case ASI_SNFL : {MemOpIdx oi;int idx = (env->pstate &PS_PRIV ? (asi &1 ?MMU_KERNEL_SECONDARY_IDX :MMU_KERNEL_IDX ) : (asi &1 ?MMU_USER_SECONDARY_IDX :MMU_USER_IDX ));if (cpu_get_phys_page_nofault (env, addr, idx) ==-1ULL ) {#ifdef DEBUG_ASI dump_asi ("read " , last_addr, asi, size, ret);#endif /* exception_index is set in get_physical_address_data. */ cpu_raise_exception_ra (env, cs->exception_index,GETPC ()); } oi =make_memop_idx (memop, idx);switch (size) {case 1 : ret =cpu_ldb_mmu (env, addr, oi,GETPC ());break ;case 2 : ret =cpu_ldw_mmu (env, addr, oi,GETPC ());break ;case 4 : ret =cpu_ldl_mmu (env, addr, oi,GETPC ());break ;case 8 : ret =cpu_ldq_mmu (env, addr, oi,GETPC ());break ;default :g_assert_not_reached (); } }break ;case ASI_AIUP :/* As if user primary */ case ASI_AIUS :/* As if user secondary */ case ASI_AIUPL :/* As if user primary LE */ case ASI_AIUSL :/* As if user secondary LE */ case ASI_P :/* Primary */ case ASI_S :/* Secondary */ case ASI_PL :/* Primary LE */ case ASI_SL :/* Secondary LE */ case ASI_REAL :/* Bypass */ case ASI_REAL_IO :/* Bypass, non-cacheable */ case ASI_REAL_L :/* Bypass LE */ case ASI_REAL_IO_L :/* Bypass, non-cacheable LE */ case ASI_N :/* Nucleus */ case ASI_NL :/* Nucleus Little Endian (LE) */ case ASI_NUCLEUS_QUAD_LDD :/* Nucleus quad LDD 128 bit atomic */ case ASI_NUCLEUS_QUAD_LDD_L :/* Nucleus quad LDD 128 bit atomic LE */ case ASI_TWINX_AIUP :/* As if user primary, twinx */ case ASI_TWINX_AIUS :/* As if user secondary, twinx */ case ASI_TWINX_REAL :/* Real address, twinx */ case ASI_TWINX_AIUP_L :/* As if user primary, twinx, LE */ case ASI_TWINX_AIUS_L :/* As if user secondary, twinx, LE */ case ASI_TWINX_REAL_L :/* Real address, twinx, LE */ case ASI_TWINX_N :/* Nucleus, twinx */ case ASI_TWINX_NL :/* Nucleus, twinx, LE */ /* ??? From the UA2011 document; overlaps BLK_INIT_QUAD_LDD_* */ case ASI_TWINX_P :/* Primary, twinx */ case ASI_TWINX_PL :/* Primary, twinx, LE */ case ASI_TWINX_S :/* Secondary, twinx */ case ASI_TWINX_SL :/* Secondary, twinx, LE */ /* These are always handled inline. */ g_assert_not_reached ();case ASI_UPA_CONFIG :/* UPA config */ /* XXX */ break ;case ASI_LSU_CONTROL :/* LSU */ ret = env->lsu;break ;case ASI_IMMU :/* I-MMU regs */ {int reg = (addr >>3 ) &0xf ;switch (reg) {case 0 :/* 0x00 I-TSB Tag Target register */ ret =ultrasparc_tag_target (env->immu.tag_access);break ;case 3 :/* SFSR */ ret = env->immu.sfsr;break ;case 5 :/* TSB access */ ret = env->immu.tsb;break ;case 6 :/* 0x30 I-TSB Tag Access register */ ret = env->immu.tag_access;break ;default :sparc_raise_mmu_fault (cs, addr, false, false,1 , size,GETPC ()); ret =0 ; }break ; }case ASI_IMMU_TSB_8KB_PTR :/* I-MMU 8k TSB pointer */ {/* env->immuregs[5] holds I-MMU TSB register value env->immuregs[6] holds I-MMU Tag Access register value */ ret =ultrasparc_tsb_pointer (env, &env->immu,0 );break ; }case ASI_IMMU_TSB_64KB_PTR :/* I-MMU 64k TSB pointer */ {/* env->immuregs[5] holds I-MMU TSB register value env->immuregs[6] holds I-MMU Tag Access register value */ ret =ultrasparc_tsb_pointer (env, &env->immu,1 );break ; }case ASI_ITLB_DATA_ACCESS :/* I-MMU data access */ {int reg = (addr >>3 ) &0x3f ; ret = env->itlb[reg].tte;break ; }case ASI_ITLB_TAG_READ :/* I-MMU tag read */ {int reg = (addr >>3 ) &0x3f ; ret = env->itlb[reg].tag;break ; }case ASI_DMMU :/* D-MMU regs */ {int reg = (addr >>3 ) &0xf ;switch (reg) {case 0 :/* 0x00 D-TSB Tag Target register */ ret =ultrasparc_tag_target (env->dmmu.tag_access);break ;case 1 :/* 0x08 Primary Context */ ret = env->dmmu.mmu_primary_context;break ;case 2 :/* 0x10 Secondary Context */ ret = env->dmmu.mmu_secondary_context;break ;case 3 :/* SFSR */ ret = env->dmmu.sfsr;break ;case 4 :/* 0x20 SFAR */ ret = env->dmmu.sfar;break ;case 5 :/* 0x28 TSB access */ ret = env->dmmu.tsb;break ;case 6 :/* 0x30 D-TSB Tag Access register */ ret = env->dmmu.tag_access;break ;case 7 : ret = env->dmmu.virtual_watchpoint;break ;case 8 : ret = env->dmmu.physical_watchpoint;break ;default :sparc_raise_mmu_fault (cs, addr, false, false,1 , size,GETPC ()); ret =0 ; }break ; }case ASI_DMMU_TSB_8KB_PTR :/* D-MMU 8k TSB pointer */ {/* env->dmmuregs[5] holds D-MMU TSB register value env->dmmuregs[6] holds D-MMU Tag Access register value */ ret =ultrasparc_tsb_pointer (env, &env->dmmu,0 );break ; }case ASI_DMMU_TSB_64KB_PTR :/* D-MMU 64k TSB pointer */ {/* env->dmmuregs[5] holds D-MMU TSB register value env->dmmuregs[6] holds D-MMU Tag Access register value */ ret =ultrasparc_tsb_pointer (env, &env->dmmu,1 );break ; }case ASI_DTLB_DATA_ACCESS :/* D-MMU data access */ {int reg = (addr >>3 ) &0x3f ; ret = env->dtlb[reg].tte;break ; }case ASI_DTLB_TAG_READ :/* D-MMU tag read */ {int reg = (addr >>3 ) &0x3f ; ret = env->dtlb[reg].tag;break ; }case ASI_INTR_DISPATCH_STAT :/* Interrupt dispatch, RO */ break ;case ASI_INTR_RECEIVE :/* Interrupt data receive */ ret = env->ivec_status;break ;case ASI_INTR_R :/* Incoming interrupt vector, RO */ {int reg = (addr >>4 ) &0x3 ;if (reg <3 ) { ret = env->ivec_data[reg]; }break ; }case ASI_SCRATCHPAD :/* UA2005 privileged scratchpad */ if (unlikely ((addr >=0x20 ) && (addr <0x30 ))) {/* Hyperprivileged access only */ sparc_raise_mmu_fault (cs, addr, false, false,1 , size,GETPC ()); } -/* fall through */ + fallthrough;case ASI_HYP_SCRATCHPAD :/* UA2005 hyperprivileged scratchpad */ {unsigned int i = (addr >>3 ) &0x7 ; ret = env->scratch[i];break ; }case ASI_MMU :/* UA2005 Context ID registers */ switch ((addr >>3 ) &0x3 ) {case 1 : ret = env->dmmu.mmu_primary_context;break ;case 2 : ret = env->dmmu.mmu_secondary_context;break ;default :sparc_raise_mmu_fault (cs, addr, true, false,1 , size,GETPC ()); }break ;case ASI_DCACHE_DATA :/* D-cache data */ case ASI_DCACHE_TAG :/* D-cache tag access */ case ASI_ESTATE_ERROR_EN :/* E-cache error enable */ case ASI_AFSR :/* E-cache asynchronous fault status */ case ASI_AFAR :/* E-cache asynchronous fault address */ case ASI_EC_TAG_DATA :/* E-cache tag data */ case ASI_IC_INSTR :/* I-cache instruction access */ case ASI_IC_TAG :/* I-cache tag access */ case ASI_IC_PRE_DECODE :/* I-cache predecode */ case ASI_IC_NEXT_FIELD :/* I-cache LRU etc. */ case ASI_EC_W :/* E-cache tag */ case ASI_EC_R :/* E-cache tag */ break ;case ASI_DMMU_TSB_DIRECT_PTR :/* D-MMU data pointer */ case ASI_ITLB_DATA_IN :/* I-MMU data in, WO */ case ASI_IMMU_DEMAP :/* I-MMU demap, WO */ case ASI_DTLB_DATA_IN :/* D-MMU data in, WO */ case ASI_DMMU_DEMAP :/* D-MMU demap, WO */ case ASI_INTR_W :/* Interrupt vector, WO */ default :sparc_raise_mmu_fault (cs, addr, false, false,1 , size,GETPC ()); ret =0 ;break ; }/* Convert to signed number */ if (sign) {switch (size) {case 1 : ret = (int8_t ) ret;break ;case 2 : ret = (int16_t ) ret;break ;case 4 : ret = (int32_t ) ret;break ;default :break ; } }#ifdef DEBUG_ASI dump_asi ("read " , last_addr, asi, size, ret);#endif return ret; }
@@ -1591,341 +1591,341 @@ uint64_t helper_ld_asi(CPUSPARCState *env, target_ulong addr,void helper_st_asi (CPUSPARCState *env,target_ulong addr,target_ulong val,int asi,uint32_t memop) {int size =1 << (memop &MO_SIZE );CPUState *cs =env_cpu (env);#ifdef DEBUG_ASI dump_asi ("write" , addr, asi, size, val);#endif asi &=0xff ;do_check_asi (env, asi,GETPC ());do_check_align (env, addr, size -1 ,GETPC ()); addr =asi_address_mask (env, asi, addr);switch (asi) {case ASI_AIUP :/* As if user primary */ case ASI_AIUS :/* As if user secondary */ case ASI_AIUPL :/* As if user primary LE */ case ASI_AIUSL :/* As if user secondary LE */ case ASI_P :/* Primary */ case ASI_S :/* Secondary */ case ASI_PL :/* Primary LE */ case ASI_SL :/* Secondary LE */ case ASI_REAL :/* Bypass */ case ASI_REAL_IO :/* Bypass, non-cacheable */ case ASI_REAL_L :/* Bypass LE */ case ASI_REAL_IO_L :/* Bypass, non-cacheable LE */ case ASI_N :/* Nucleus */ case ASI_NL :/* Nucleus Little Endian (LE) */ case ASI_NUCLEUS_QUAD_LDD :/* Nucleus quad LDD 128 bit atomic */ case ASI_NUCLEUS_QUAD_LDD_L :/* Nucleus quad LDD 128 bit atomic LE */ case ASI_TWINX_AIUP :/* As if user primary, twinx */ case ASI_TWINX_AIUS :/* As if user secondary, twinx */ case ASI_TWINX_REAL :/* Real address, twinx */ case ASI_TWINX_AIUP_L :/* As if user primary, twinx, LE */ case ASI_TWINX_AIUS_L :/* As if user secondary, twinx, LE */ case ASI_TWINX_REAL_L :/* Real address, twinx, LE */ case ASI_TWINX_N :/* Nucleus, twinx */ case ASI_TWINX_NL :/* Nucleus, twinx, LE */ /* ??? From the UA2011 document; overlaps BLK_INIT_QUAD_LDD_* */ case ASI_TWINX_P :/* Primary, twinx */ case ASI_TWINX_PL :/* Primary, twinx, LE */ case ASI_TWINX_S :/* Secondary, twinx */ case ASI_TWINX_SL :/* Secondary, twinx, LE */ /* These are always handled inline. */ g_assert_not_reached ();/* these ASIs have different functions on UltraSPARC-IIIi * and UA2005 CPUs. Use the explicit numbers to avoid confusion */ case 0x31 :case 0x32 :case 0x39 :case 0x3a :if (cpu_has_hypervisor (env)) {/* UA2005 * ASI_DMMU_CTX_ZERO_TSB_BASE_PS0 * ASI_DMMU_CTX_ZERO_TSB_BASE_PS1 * ASI_DMMU_CTX_NONZERO_TSB_BASE_PS0 * ASI_DMMU_CTX_NONZERO_TSB_BASE_PS1 */ int idx = ((asi &2 ) >>1 ) | ((asi &8 ) >>2 ); env->dmmu.sun4v_tsb_pointers[idx] = val; }else {helper_raise_exception (env,TT_ILL_INSN ); }break ;case 0x33 :case 0x3b :if (cpu_has_hypervisor (env)) {/* UA2005 * ASI_DMMU_CTX_ZERO_CONFIG * ASI_DMMU_CTX_NONZERO_CONFIG */ env->dmmu.sun4v_ctx_config[(asi &8 ) >>3 ] = val; }else {helper_raise_exception (env,TT_ILL_INSN ); }break ;case 0x35 :case 0x36 :case 0x3d :case 0x3e :if (cpu_has_hypervisor (env)) {/* UA2005 * ASI_IMMU_CTX_ZERO_TSB_BASE_PS0 * ASI_IMMU_CTX_ZERO_TSB_BASE_PS1 * ASI_IMMU_CTX_NONZERO_TSB_BASE_PS0 * ASI_IMMU_CTX_NONZERO_TSB_BASE_PS1 */ int idx = ((asi &2 ) >>1 ) | ((asi &8 ) >>2 ); env->immu.sun4v_tsb_pointers[idx] = val; }else {helper_raise_exception (env,TT_ILL_INSN ); }break ;case 0x37 :case 0x3f :if (cpu_has_hypervisor (env)) {/* UA2005 * ASI_IMMU_CTX_ZERO_CONFIG * ASI_IMMU_CTX_NONZERO_CONFIG */ env->immu.sun4v_ctx_config[(asi &8 ) >>3 ] = val; }else {helper_raise_exception (env,TT_ILL_INSN ); }break ;case ASI_UPA_CONFIG :/* UPA config */ /* XXX */ return ;case ASI_LSU_CONTROL :/* LSU */ env->lsu = val & (DMMU_E |IMMU_E );return ;case ASI_IMMU :/* I-MMU regs */ {int reg = (addr >>3 ) &0xf ;uint64_t oldreg; oldreg = env->immu.mmuregs[reg];switch (reg) {case 0 :/* RO */ return ;case 1 :/* Not in I-MMU */ case 2 :return ;case 3 :/* SFSR */ if ((val &1 ) ==0 ) { val =0 ;/* Clear SFSR */ } env->immu.sfsr = val;break ;case 4 :/* RO */ return ;case 5 :/* TSB access */ DPRINTF_MMU ("immu TSB write: 0x%016" PRIx64" -> 0x%016" PRIx64"\n" , env->immu.tsb, val); env->immu.tsb = val;break ;case 6 :/* Tag access */ env->immu.tag_access = val;break ;case 7 :case 8 :return ;default :sparc_raise_mmu_fault (cs, addr, true, false,1 , size,GETPC ());break ; }if (oldreg != env->immu.mmuregs[reg]) {DPRINTF_MMU ("immu change reg[%d]: 0x%016" PRIx64" -> 0x%016" PRIx64"\n" , reg, oldreg, env->immuregs[reg]); }#ifdef DEBUG_MMU dump_mmu (env);#endif return ; }case ASI_ITLB_DATA_IN :/* I-MMU data in */ /* ignore real translation entries */ if (!(addr &TLB_UST1_IS_REAL_BIT )) {replace_tlb_1bit_lru (env->itlb, env->immu.tag_access, val,"immu" , env, addr); }return ;case ASI_ITLB_DATA_ACCESS :/* I-MMU data access */ {/* TODO: auto demap */ unsigned int i = (addr >>3 ) &0x3f ;/* ignore real translation entries */ if (!(addr &TLB_UST1_IS_REAL_BIT )) {replace_tlb_entry (&env->itlb[i], env->immu.tag_access,sun4v_tte_to_sun4u (env, addr, val), env); }#ifdef DEBUG_MMU DPRINTF_MMU ("immu data access replaced entry [%i]\n" , i);dump_mmu (env);#endif return ; }case ASI_IMMU_DEMAP :/* I-MMU demap */ demap_tlb (env->itlb, addr,"immu" , env);return ;case ASI_DMMU :/* D-MMU regs */ {int reg = (addr >>3 ) &0xf ;uint64_t oldreg; oldreg = env->dmmu.mmuregs[reg];switch (reg) {case 0 :/* RO */ case 4 :return ;case 3 :/* SFSR */ if ((val &1 ) ==0 ) { val =0 ;/* Clear SFSR, Fault address */ env->dmmu.sfar =0 ; } env->dmmu.sfsr = val;break ;case 1 :/* Primary context */ env->dmmu.mmu_primary_context = val;/* can be optimized to only flush MMU_USER_IDX and MMU_KERNEL_IDX entries */ tlb_flush (cs);break ;case 2 :/* Secondary context */ env->dmmu.mmu_secondary_context = val;/* can be optimized to only flush MMU_USER_SECONDARY_IDX and MMU_KERNEL_SECONDARY_IDX entries */ tlb_flush (cs);break ;case 5 :/* TSB access */ DPRINTF_MMU ("dmmu TSB write: 0x%016" PRIx64" -> 0x%016" PRIx64"\n" , env->dmmu.tsb, val); env->dmmu.tsb = val;break ;case 6 :/* Tag access */ env->dmmu.tag_access = val;break ;case 7 :/* Virtual Watchpoint */ env->dmmu.virtual_watchpoint = val;break ;case 8 :/* Physical Watchpoint */ env->dmmu.physical_watchpoint = val;break ;default :sparc_raise_mmu_fault (cs, addr, true, false,1 , size,GETPC ());break ; }if (oldreg != env->dmmu.mmuregs[reg]) {DPRINTF_MMU ("dmmu change reg[%d]: 0x%016" PRIx64" -> 0x%016" PRIx64"\n" , reg, oldreg, env->dmmuregs[reg]); }#ifdef DEBUG_MMU dump_mmu (env);#endif return ; }case ASI_DTLB_DATA_IN :/* D-MMU data in */ /* ignore real translation entries */ if (!(addr &TLB_UST1_IS_REAL_BIT )) {replace_tlb_1bit_lru (env->dtlb, env->dmmu.tag_access, val,"dmmu" , env, addr); }return ;case ASI_DTLB_DATA_ACCESS :/* D-MMU data access */ {unsigned int i = (addr >>3 ) &0x3f ;/* ignore real translation entries */ if (!(addr &TLB_UST1_IS_REAL_BIT )) {replace_tlb_entry (&env->dtlb[i], env->dmmu.tag_access,sun4v_tte_to_sun4u (env, addr, val), env); }#ifdef DEBUG_MMU DPRINTF_MMU ("dmmu data access replaced entry [%i]\n" , i);dump_mmu (env);#endif return ; }case ASI_DMMU_DEMAP :/* D-MMU demap */ demap_tlb (env->dtlb, addr,"dmmu" , env);return ;case ASI_INTR_RECEIVE :/* Interrupt data receive */ env->ivec_status = val &0x20 ;return ;case ASI_SCRATCHPAD :/* UA2005 privileged scratchpad */ if (unlikely ((addr >=0x20 ) && (addr <0x30 ))) {/* Hyperprivileged access only */ sparc_raise_mmu_fault (cs, addr, true, false,1 , size,GETPC ()); } -/* fall through */ + fallthrough;case ASI_HYP_SCRATCHPAD :/* UA2005 hyperprivileged scratchpad */ {unsigned int i = (addr >>3 ) &0x7 ; env->scratch[i] = val;return ; }case ASI_MMU :/* UA2005 Context ID registers */ {switch ((addr >>3 ) &0x3 ) {case 1 : env->dmmu.mmu_primary_context = val; env->immu.mmu_primary_context = val;tlb_flush_by_mmuidx (cs, (1 <<MMU_USER_IDX ) | (1 <<MMU_KERNEL_IDX ));break ;case 2 : env->dmmu.mmu_secondary_context = val; env->immu.mmu_secondary_context = val;tlb_flush_by_mmuidx (cs, (1 <<MMU_USER_SECONDARY_IDX ) | (1 <<MMU_KERNEL_SECONDARY_IDX ));break ;default :sparc_raise_mmu_fault (cs, addr, true, false,1 , size,GETPC ()); } }return ;case ASI_QUEUE :/* UA2005 CPU mondo queue */ case ASI_DCACHE_DATA :/* D-cache data */ case ASI_DCACHE_TAG :/* D-cache tag access */ case ASI_ESTATE_ERROR_EN :/* E-cache error enable */ case ASI_AFSR :/* E-cache asynchronous fault status */ case ASI_AFAR :/* E-cache asynchronous fault address */ case ASI_EC_TAG_DATA :/* E-cache tag data */ case ASI_IC_INSTR :/* I-cache instruction access */ case ASI_IC_TAG :/* I-cache tag access */ case ASI_IC_PRE_DECODE :/* I-cache predecode */ case ASI_IC_NEXT_FIELD :/* I-cache LRU etc. */ case ASI_EC_W :/* E-cache tag */ case ASI_EC_R :/* E-cache tag */ return ;case ASI_IMMU_TSB_8KB_PTR :/* I-MMU 8k TSB pointer, RO */ case ASI_IMMU_TSB_64KB_PTR :/* I-MMU 64k TSB pointer, RO */ case ASI_ITLB_TAG_READ :/* I-MMU tag read, RO */ case ASI_DMMU_TSB_8KB_PTR :/* D-MMU 8k TSB pointer, RO */ case ASI_DMMU_TSB_64KB_PTR :/* D-MMU 64k TSB pointer, RO */ case ASI_DMMU_TSB_DIRECT_PTR :/* D-MMU data pointer, RO */ case ASI_DTLB_TAG_READ :/* D-MMU tag read, RO */ case ASI_INTR_DISPATCH_STAT :/* Interrupt dispatch, RO */ case ASI_INTR_R :/* Incoming interrupt vector, RO */ case ASI_PNF :/* Primary no-fault, RO */ case ASI_SNF :/* Secondary no-fault, RO */ case ASI_PNFL :/* Primary no-fault LE, RO */ case ASI_SNFL :/* Secondary no-fault LE, RO */ default :sparc_raise_mmu_fault (cs, addr, true, false,1 , size,GETPC ());return ; } }#endif /* CONFIG_USER_ONLY */ #endif /* TARGET_SPARC64 */ #if !defined(CONFIG_USER_ONLY )
target/sparc/mmu_helper.c +3 -3
@@ -545,99 +545,99 @@ static uint64_t build_sfsr(CPUSPARCState *env, int mmu_idx, int rw)static int get_physical_address_data (CPUSPARCState *env,CPUTLBEntryFull *full,target_ulong address,int rw,int mmu_idx) {CPUState *cs =env_cpu (env);unsigned int i;uint64_t sfsr;uint64_t context;bool is_user = false; sfsr =build_sfsr (env, mmu_idx, rw);switch (mmu_idx) {case MMU_PHYS_IDX :g_assert_not_reached ();case MMU_USER_IDX : is_user = true; -/* fallthru */ + fallthrough;case MMU_KERNEL_IDX : context = env->dmmu.mmu_primary_context &0x1fff ;break ;case MMU_USER_SECONDARY_IDX : is_user = true; -/* fallthru */ + fallthrough;case MMU_KERNEL_SECONDARY_IDX : context = env->dmmu.mmu_secondary_context &0x1fff ;break ;default : context =0 ;break ; }for (i =0 ; i <64 ; i++) {/* ctx match, vaddr match, valid? */ if (ultrasparc_tag_match (&env->dtlb[i], address, context, &full->phys_addr)) {int do_fault =0 ;if (TTE_IS_IE (env->dtlb[i].tte)) { full->attrs.byte_swap = true; }/* access ok? */ /* multiple bits in SFSR.FT may be set on TT_DFAULT */ if (TTE_IS_PRIV (env->dtlb[i].tte) && is_user) { do_fault =1 ; sfsr |=SFSR_FT_PRIV_BIT ;/* privilege violation */ trace_mmu_helper_dfault (address, context, mmu_idx, env->tl); }if (rw ==4 ) {if (TTE_IS_SIDEEFFECT (env->dtlb[i].tte)) { do_fault =1 ; sfsr |=SFSR_FT_NF_E_BIT ; } }else {if (TTE_IS_NFO (env->dtlb[i].tte)) { do_fault =1 ; sfsr |=SFSR_FT_NFO_BIT ; } }if (do_fault) {/* faults above are reported with TT_DFAULT. */ cs->exception_index =TT_DFAULT ; }else if (!TTE_IS_W_OK (env->dtlb[i].tte) && (rw ==1 )) { do_fault =1 ; cs->exception_index =TT_DPROT ;trace_mmu_helper_dprot (address, context, mmu_idx, env->tl); }if (!do_fault) { full->prot =PAGE_READ ;if (TTE_IS_W_OK (env->dtlb[i].tte)) { full->prot |=PAGE_WRITE ; }TTE_SET_USED (env->dtlb[i].tte);return 0 ; } env->dmmu.sfsr = sfsr; env->dmmu.sfar = address;/* Fault address register */ env->dmmu.tag_access = (address & ~0x1fffULL ) | context;return 1 ; } }trace_mmu_helper_dmiss (address, context);/* * On MMU misses: * - UltraSPARC IIi: SFSR and SFAR unmodified * - JPS1: SFAR updated and some fields of SFSR updated */ env->dmmu.tag_access = (address & ~0x1fffULL ) | context; cs->exception_index =TT_DMISS ;return 1 ; }
@@ -645,75 +645,75 @@ static int get_physical_address_data(CPUSPARCState *env, CPUTLBEntryFull *full,static int get_physical_address_code (CPUSPARCState *env,CPUTLBEntryFull *full,target_ulong address,int mmu_idx) {CPUState *cs =env_cpu (env);unsigned int i;uint64_t context;bool is_user = false;switch (mmu_idx) {case MMU_PHYS_IDX :case MMU_USER_SECONDARY_IDX :case MMU_KERNEL_SECONDARY_IDX :g_assert_not_reached ();case MMU_USER_IDX : is_user = true; -/* fallthru */ + fallthrough;case MMU_KERNEL_IDX : context = env->dmmu.mmu_primary_context &0x1fff ;break ;default : context =0 ;break ; }if (env->tl ==0 ) {/* PRIMARY context */ context = env->dmmu.mmu_primary_context &0x1fff ; }else {/* NUCLEUS context */ context =0 ; }for (i =0 ; i <64 ; i++) {/* ctx match, vaddr match, valid? */ if (ultrasparc_tag_match (&env->itlb[i], address, context, &full->phys_addr)) {/* access ok? */ if (TTE_IS_PRIV (env->itlb[i].tte) && is_user) {/* Fault status register */ if (env->immu.sfsr &SFSR_VALID_BIT ) { env->immu.sfsr =SFSR_OW_BIT ;/* overflow (not read before another fault) */ }else { env->immu.sfsr =0 ; }if (env->pstate &PS_PRIV ) { env->immu.sfsr |=SFSR_PR_BIT ; }if (env->tl >0 ) { env->immu.sfsr |=SFSR_CT_NUCLEUS ; }/* FIXME: ASI field in SFSR must be set */ env->immu.sfsr |=SFSR_FT_PRIV_BIT |SFSR_VALID_BIT ; cs->exception_index =TT_TFAULT ; env->immu.tag_access = (address & ~0x1fffULL ) | context;trace_mmu_helper_tfault (address, context);return 1 ; } full->prot =PAGE_EXEC ;TTE_SET_USED (env->itlb[i].tte);return 0 ; } }trace_mmu_helper_tmiss (address, context);/* Context is stored in DMMU (dmmuregs[1]) also for IMMU */ env->immu.tag_access = (address & ~0x1fffULL ) | context; cs->exception_index =TT_TMISS ;return 1 ; }
target/sparc/translate.c +2 -1
@@ -1020,167 +1020,168 @@ static void gen_op_next_insn(void)static void gen_compare (DisasCompare *cmp,bool xcc,unsigned int cond,DisasContext *dc) {static int subcc_cond[16 ] = {TCG_COND_NEVER ,TCG_COND_EQ ,TCG_COND_LE ,TCG_COND_LT ,TCG_COND_LEU ,TCG_COND_LTU ,-1 ,/* neg */ -1 ,/* overflow */ TCG_COND_ALWAYS ,TCG_COND_NE ,TCG_COND_GT ,TCG_COND_GE ,TCG_COND_GTU ,TCG_COND_GEU ,-1 ,/* pos */ -1 ,/* no overflow */ };static int logic_cond[16 ] = {TCG_COND_NEVER ,TCG_COND_EQ ,/* eq: Z */ TCG_COND_LE ,/* le: Z | (N ^ V) -> Z | N */ TCG_COND_LT ,/* lt: N ^ V -> N */ TCG_COND_EQ ,/* leu: C | Z -> Z */ TCG_COND_NEVER ,/* ltu: C -> 0 */ TCG_COND_LT ,/* neg: N */ TCG_COND_NEVER ,/* vs: V -> 0 */ TCG_COND_ALWAYS ,TCG_COND_NE ,/* ne: !Z */ TCG_COND_GT ,/* gt: !(Z | (N ^ V)) -> !(Z | N) */ TCG_COND_GE ,/* ge: !(N ^ V) -> !N */ TCG_COND_NE ,/* gtu: !(C | Z) -> !Z */ TCG_COND_ALWAYS ,/* geu: !C -> 1 */ TCG_COND_GE ,/* pos: !N */ TCG_COND_ALWAYS ,/* vc: !V -> 1 */ };TCGv_i32 r_src;TCGv r_dst;#ifdef TARGET_SPARC64 if (xcc) { r_src = cpu_xcc; }else { r_src = cpu_psr; }#else r_src = cpu_psr;#endif switch (dc->cc_op) {case CC_OP_LOGIC : cmp->cond = logic_cond[cond]; do_compare_dst_0: cmp->is_bool = false; cmp->c2 =tcg_constant_tl (0 );#ifdef TARGET_SPARC64 if (!xcc) { cmp->c1 =tcg_temp_new ();tcg_gen_ext32s_tl (cmp->c1, cpu_cc_dst);break ; }#endif cmp->c1 = cpu_cc_dst;break ;case CC_OP_SUB :switch (cond) {case 6 :/* neg */ case 14 :/* pos */ cmp->cond = (cond ==6 ?TCG_COND_LT :TCG_COND_GE ); goto do_compare_dst_0;case 7 :/* overflow */ case 15 :/* !overflow */ goto do_dynamic;default : cmp->cond = subcc_cond[cond]; cmp->is_bool = false;#ifdef TARGET_SPARC64 if (!xcc) {/* Note that sign-extension works for unsigned compares as long as both operands are sign-extended. */ cmp->c1 =tcg_temp_new (); cmp->c2 =tcg_temp_new ();tcg_gen_ext32s_tl (cmp->c1, cpu_cc_src);tcg_gen_ext32s_tl (cmp->c2, cpu_cc_src2);break ; }#endif cmp->c1 = cpu_cc_src; cmp->c2 = cpu_cc_src2;break ; }break ;default : do_dynamic:gen_helper_compute_psr (tcg_env); dc->cc_op =CC_OP_FLAGS ;/* FALLTHRU */ + fallthrough;case CC_OP_FLAGS :/* We're going to generate a boolean result. */ cmp->cond =TCG_COND_NE ; cmp->is_bool = true; cmp->c1 = r_dst =tcg_temp_new (); cmp->c2 =tcg_constant_tl (0 );switch (cond) {case 0x0 :gen_op_eval_bn (r_dst);break ;case 0x1 :gen_op_eval_be (r_dst, r_src);break ;case 0x2 :gen_op_eval_ble (r_dst, r_src);break ;case 0x3 :gen_op_eval_bl (r_dst, r_src);break ;case 0x4 :gen_op_eval_bleu (r_dst, r_src);break ;case 0x5 :gen_op_eval_bcs (r_dst, r_src);break ;case 0x6 :gen_op_eval_bneg (r_dst, r_src);break ;case 0x7 :gen_op_eval_bvs (r_dst, r_src);break ;case 0x8 :gen_op_eval_ba (r_dst);break ;case 0x9 :gen_op_eval_bne (r_dst, r_src);break ;case 0xa :gen_op_eval_bg (r_dst, r_src);break ;case 0xb :gen_op_eval_bge (r_dst, r_src);break ;case 0xc :gen_op_eval_bgu (r_dst, r_src);break ;case 0xd :gen_op_eval_bcc (r_dst, r_src);break ;case 0xe :gen_op_eval_bpos (r_dst, r_src);break ;case 0xf :gen_op_eval_bvc (r_dst, r_src);break ; }break ; } }
@@ -2186,75 +2187,75 @@ static void gen_ld_asi(DisasContext *dc, TCGv dst, TCGv addr,static void gen_st_asi (DisasContext *dc,TCGv src,TCGv addr,int insn,MemOp memop) {DisasASI da =get_asi (dc, insn, memop);switch (da.type) {case GET_ASI_EXCP :break ;case GET_ASI_DTWINX :/* Reserved for stda. */ #ifndef TARGET_SPARC64 gen_exception (dc,TT_ILL_INSN );break ;#else if (!(dc->def->features &CPU_FEATURE_HYPV )) {/* Pre OpenSPARC CPUs don't have these */ gen_exception (dc,TT_ILL_INSN );return ; }/* in OpenSPARC T1+ CPUs TWINX ASIs in store instructions * are ST_BLKINIT_ ASIs */ #endif -/* fall through */ + fallthrough;case GET_ASI_DIRECT :gen_address_mask (dc, addr);tcg_gen_qemu_st_tl (src, addr, da.mem_idx, da.memop |MO_ALIGN );break ;#if !defined(TARGET_SPARC64 ) && !defined(CONFIG_USER_ONLY )case GET_ASI_BCOPY :/* Copy 32 bytes from the address in SRC to ADDR. */ /* ??? The original qemu code suggests 4-byte alignment, dropping the low bits, but the only place I can see this used is in the Linux kernel with 32 byte alignment, which would make more sense as a cacheline-style operation. */ {TCGv saddr =tcg_temp_new ();TCGv daddr =tcg_temp_new ();TCGv four =tcg_constant_tl (4 );TCGv_i32 tmp =tcg_temp_new_i32 ();int i;tcg_gen_andi_tl (saddr, src,-4 );tcg_gen_andi_tl (daddr, addr,-4 );for (i =0 ; i <32 ; i +=4 ) {/* Since the loads and stores are paired, allow the copy to happen in the host endianness. */ tcg_gen_qemu_ld_i32 (tmp, saddr, da.mem_idx,MO_UL );tcg_gen_qemu_st_i32 (tmp, daddr, da.mem_idx,MO_UL );tcg_gen_add_tl (saddr, saddr, four);tcg_gen_add_tl (daddr, daddr, four); } }break ;#endif default : {TCGv_i32 r_asi =tcg_constant_i32 (da.asi);TCGv_i32 r_mop =tcg_constant_i32 (memop |MO_ALIGN );save_state (dc);#ifdef TARGET_SPARC64 gen_helper_st_asi (tcg_env, addr, src, r_asi, r_mop);#else {TCGv_i64 t64 =tcg_temp_new_i64 ();tcg_gen_extu_tl_i64 (t64, src);gen_helper_st_asi (tcg_env, addr, t64, r_asi, r_mop); }#endif /* A write to a TLB register may alter page maps. End the TB. */ dc->npc =DYNAMIC_PC ; }break ; } }
target/sparc/win_helper.c +1 -0
@@ -296,20 +296,21 @@ void helper_wrcwp(CPUSPARCState *env, target_ulong new_cwp)static inline uint64_t *get_gregset (CPUSPARCState *env,uint32_t pstate) {if (env->def.features &CPU_FEATURE_GL ) {return env->glregs + (env->gl &7 ) *8 ; }switch (pstate) {default :trace_win_helper_gregset_error (pstate);/* fall through to normal set of global registers */ + fallthrough;case 0 :return env->bgregs;case PS_AG :return env->agregs;case PS_MG :return env->mgregs;case PS_IG :return env->igregs; } }
Signature · 1 line
2.39.2