Skip to contentSkip to conversation

Strict disable implicit fallthrough

RFC PATCH Superseded Emmanouil Pitsidianakis 8 participants 92 messages Oct 13, 2023 – Oct 19, 2023 2 messages not in the archive Page 1 of 3

Subsystems (8)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#8 lore raw

RFC PATCH v2 2/78 block: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In 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
index 1c60368d72..b4ceb6a079 100644
@@ -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
index 50e2b20d5c..31c7719da5 100644
@@ -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
index e7f9448d5a..cc05457d02 100644
@@ -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
index 5640c8b565..2fb7037748 100644
@@ -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
index f4f6cd6ad0..c50143d493 100644
@@ -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
index a67edcc03e..9000b3fcea 100644
@@ -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
#29 lore raw

RFC PATCH v2 20/78 target/mips: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In 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
index 05990aa5bb..ebcaeea1bc 100644
@@ -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
index 7510831701..00e96ce27a 100644
@@ -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
index 5cffe0e412..b8bdd6a7f2 100644
@@ -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
index c517258ac5..3811ac0d54 100644
@@ -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
index b4b746d418..3e5f4f4e58 100644
@@ -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
index 98935b5e64..b53f4fa694 100644
@@ -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.

#32 lore raw

RFC PATCH v2 23/78 target/arm: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 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 ++--
 7 files changed, 68 insertions(+), 66 deletions(-)
target/arm/helper.c +18 -16
index 74fbb6e1d7..e2d1426cf4 100644
@@ -2507,42 +2507,42 @@ static CPAccessResult gt_counter_access(CPUARMState *env, int timeridx,
 static CPAccessResult gt_timer_access(CPUARMState *env, int timeridx,
                                       bool isread)
 {
     unsigned int cur_el = arm_current_el(env);
     bool has_el2 = arm_is_el2_enabled(env);
     uint64_t hcr = arm_hcr_el2_eff(env);
 
     switch (cur_el) {
     case 0:
         if ((hcr & (HCR_E2H | HCR_TGE)) == (HCR_E2H | HCR_TGE)) {
             /* If HCR_EL2.<E2H,TGE> == '11': check CNTHCTL_EL2.EL0[PV]TEN. */
             return (extract32(env->cp15.cnthctl_el2, 9 - timeridx, 1)
                     ? CP_ACCESS_OK : CP_ACCESS_TRAP_EL2);
         }
 
         /*
          * CNT[PV]_CVAL, CNT[PV]_CTL, CNT[PV]_TVAL: not visible from
          * EL0 if EL0[PV]TEN is zero.
          */
         if (!extract32(env->cp15.c14_cntkctl, 9 - timeridx, 1)) {
             return CP_ACCESS_TRAP;
         }
-        /* fall through */
+        fallthrough;
 
     case 1:
         if (has_el2 && timeridx == GTIMER_PHYS) {
             if (hcr & HCR_E2H) {
                 /* If HCR_EL2.<E2H,TGE> == '10': check CNTHCTL_EL2.EL1PTEN. */
                 if (!extract32(env->cp15.cnthctl_el2, 11, 1)) {
                     return CP_ACCESS_TRAP_EL2;
                 }
             } else {
                 /* If HCR_EL2.<E2H> == 0: check CNTHCTL_EL2.EL1PCEN. */
                 if (!extract32(env->cp15.cnthctl_el2, 1, 1)) {
                     return CP_ACCESS_TRAP_EL2;
                 }
             }
         }
         break;
     }
     return CP_ACCESS_OK;
 }
@@ -3573,69 +3573,69 @@ static uint64_t do_ats_write(CPUARMState *env, uint64_t value,
 static void ats_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
 {
 #ifdef CONFIG_TCG
     MMUAccessType access_type = ri->opc2 & 1 ? MMU_DATA_STORE : MMU_DATA_LOAD;
     uint64_t par64;
     ARMMMUIdx mmu_idx;
     int el = arm_current_el(env);
     ARMSecuritySpace ss = arm_security_space(env);
 
     switch (ri->opc2 & 6) {
     case 0:
         /* stage 1 current state PL1: ATS1CPR, ATS1CPW, ATS1CPRP, ATS1CPWP */
         switch (el) {
         case 3:
             mmu_idx = ARMMMUIdx_E3;
             break;
         case 2:
             g_assert(ss != ARMSS_Secure);  /* ARMv8.4-SecEL2 is 64-bit only */
-            /* fall through */
+            fallthrough;
         case 1:
             if (ri->crm == 9 && (env->uncached_cpsr & CPSR_PAN)) {
                 mmu_idx = ARMMMUIdx_Stage1_E1_PAN;
             } else {
                 mmu_idx = ARMMMUIdx_Stage1_E1;
             }
             break;
         default:
             g_assert_not_reached();
         }
         break;
     case 2:
         /* stage 1 current state PL0: ATS1CUR, ATS1CUW */
         switch (el) {
         case 3:
             mmu_idx = ARMMMUIdx_E10_0;
             break;
         case 2:
             g_assert(ss != ARMSS_Secure);  /* ARMv8.4-SecEL2 is 64-bit only */
             mmu_idx = ARMMMUIdx_Stage1_E0;
             break;
         case 1:
             mmu_idx = ARMMMUIdx_Stage1_E0;
             break;
         default:
             g_assert_not_reached();
         }
         break;
     case 4:
         /* stage 1+2 NonSecure PL1: ATS12NSOPR, ATS12NSOPW */
         mmu_idx = ARMMMUIdx_E10_1;
         ss = ARMSS_NonSecure;
         break;
     case 6:
         /* stage 1+2 NonSecure PL0: ATS12NSOUR, ATS12NSOUW */
         mmu_idx = ARMMMUIdx_E10_0;
         ss = ARMSS_NonSecure;
         break;
     default:
         g_assert_not_reached();
     }
 
     par64 = do_ats_write(env, value, access_type, mmu_idx, ss);
 
     A32_BANKED_CURRENT_REG_SET(env, par, par64);
 #else
     /* Handled by hardware accelerator. */
     g_assert_not_reached();
 #endif /* CONFIG_TCG */
 }
@@ -4649,21 +4649,21 @@ static const ARMCPRegInfo ssbs_reginfo = {
 static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env,
                                               const ARMCPRegInfo *ri,
                                               bool isread)
 {
     /* Cache invalidate/clean to Point of Coherency or Persistence...  */
     switch (arm_current_el(env)) {
     case 0:
         /* ... EL0 must UNDEF unless SCTLR_EL1.UCI is set.  */
         if (!(arm_sctlr(env, 0) & SCTLR_UCI)) {
             return CP_ACCESS_TRAP;
         }
-        /* fall through */
+        fallthrough;
     case 1:
         /* ... EL1 must trap to EL2 if HCR_EL2.TPCP is set.  */
         if (arm_hcr_el2_eff(env) & HCR_TPCP) {
             return CP_ACCESS_TRAP_EL2;
         }
         break;
     }
     return CP_ACCESS_OK;
 }
@@ -4671,19 +4671,19 @@ static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env,
 static CPAccessResult do_cacheop_pou_access(CPUARMState *env, uint64_t hcrflags)
 {
     /* Cache invalidate/clean to Point of Unification... */
     switch (arm_current_el(env)) {
     case 0:
         /* ... EL0 must UNDEF unless SCTLR_EL1.UCI is set.  */
         if (!(arm_sctlr(env, 0) & SCTLR_UCI)) {
             return CP_ACCESS_TRAP;
         }
-        /* fall through */
+        fallthrough;
     case 1:
         /* ... EL1 must trap to EL2 if relevant HCR_EL2 flags are set.  */
         if (arm_hcr_el2_eff(env) & hcrflags) {
             return CP_ACCESS_TRAP_EL2;
         }
         break;
     }
     return CP_ACCESS_OK;
 }
@@ -6741,107 +6741,107 @@ static const ARMCPRegInfo minimal_ras_reginfo[] = {
 /*
  * Return the exception level to which exceptions should be taken
  * via SVEAccessTrap.  This excludes the check for whether the exception
  * should be routed through AArch64.AdvSIMDFPAccessTrap.  That can easily
  * be found by testing 0 < fp_exception_el < sve_exception_el.
  *
  * C.f. the ARM pseudocode function CheckSVEEnabled.  Note that the
  * pseudocode does *not* separate out the FP trap checks, but has them
  * all in one function.
  */
 int sve_exception_el(CPUARMState *env, int el)
 {
 #ifndef CONFIG_USER_ONLY
     if (el <= 1 && !el_is_in_host(env, el)) {
         switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, ZEN)) {
         case 1:
             if (el != 0) {
                 break;
             }
-            /* fall through */
+            fallthrough;
         case 0:
         case 2:
             return 1;
         }
     }
 
     if (el <= 2 && arm_is_el2_enabled(env)) {
         /* CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). */
         if (env->cp15.hcr_el2 & HCR_E2H) {
             switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, ZEN)) {
             case 1:
                 if (el != 0 || !(env->cp15.hcr_el2 & HCR_TGE)) {
                     break;
                 }
-                /* fall through */
+                fallthrough;
             case 0:
             case 2:
                 return 2;
             }
         } else {
             if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TZ)) {
                 return 2;
             }
         }
     }
 
     /* CPTR_EL3.  Since EZ is negative we must check for EL3.  */
     if (arm_feature(env, ARM_FEATURE_EL3)
         && !FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, EZ)) {
         return 3;
     }
 #endif
     return 0;
 }
 
 /*
  * Return the exception level to which exceptions should be taken for SME.
  * C.f. the ARM pseudocode function CheckSMEAccess.
  */
 int sme_exception_el(CPUARMState *env, int el)
 {
 #ifndef CONFIG_USER_ONLY
     if (el <= 1 && !el_is_in_host(env, el)) {
         switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, SMEN)) {
         case 1:
             if (el != 0) {
                 break;
             }
-            /* fall through */
+            fallthrough;
         case 0:
         case 2:
             return 1;
         }
     }
 
     if (el <= 2 && arm_is_el2_enabled(env)) {
         /* CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). */
         if (env->cp15.hcr_el2 & HCR_E2H) {
             switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, SMEN)) {
             case 1:
                 if (el != 0 || !(env->cp15.hcr_el2 & HCR_TGE)) {
                     break;
                 }
-                /* fall through */
+                fallthrough;
             case 0:
             case 2:
                 return 2;
             }
         } else {
             if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TSM)) {
                 return 2;
             }
         }
     }
 
     /* CPTR_EL3.  Since ESM is negative we must check for EL3.  */
     if (arm_feature(env, ARM_FEATURE_EL3)
         && !FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, ESM)) {
         return 3;
     }
 #endif
     return 0;
 }
 
 /*
  * Given that SVE is enabled, return the vector length for EL.
  */
@@ -9678,182 +9678,182 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r,
 void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu,
                                        const ARMCPRegInfo *r, void *opaque)
 {
     /*
      * Define implementations of coprocessor registers.
      * We store these in a hashtable because typically
      * there are less than 150 registers in a space which
      * is 16*16*16*8*8 = 262144 in size.
      * Wildcarding is supported for the crm, opc1 and opc2 fields.
      * If a register is defined twice then the second definition is
      * used, so this can be used to define some generic registers and
      * then override them with implementation specific variations.
      * At least one of the original and the second definition should
      * include ARM_CP_OVERRIDE in its type bits -- this is just a guard
      * against accidental use.
      *
      * The state field defines whether the register is to be
      * visible in the AArch32 or AArch64 execution state. If the
      * state is set to ARM_CP_STATE_BOTH then we synthesise a
      * reginfo structure for the AArch32 view, which sees the lower
      * 32 bits of the 64 bit register.
      *
      * Only registers visible in AArch64 may set r->opc0; opc0 cannot
      * be wildcarded. AArch64 registers are always considered to be 64
      * bits; the ARM_CP_64BIT* flag applies only to the AArch32 view of
      * the register, if any.
      */
     int crm, opc1, opc2;
     int crmmin = (r->crm == CP_ANY) ? 0 : r->crm;
     int crmmax = (r->crm == CP_ANY) ? 15 : r->crm;
     int opc1min = (r->opc1 == CP_ANY) ? 0 : r->opc1;
     int opc1max = (r->opc1 == CP_ANY) ? 7 : r->opc1;
     int opc2min = (r->opc2 == CP_ANY) ? 0 : r->opc2;
     int opc2max = (r->opc2 == CP_ANY) ? 7 : r->opc2;
     CPState state;
 
     /* 64 bit registers have only CRm and Opc1 fields */
     assert(!((r->type & ARM_CP_64BIT) && (r->opc2 || r->crn)));
     /* op0 only exists in the AArch64 encodings */
     assert((r->state != ARM_CP_STATE_AA32) || (r->opc0 == 0));
     /* AArch64 regs are all 64 bit so ARM_CP_64BIT is meaningless */
     assert((r->state != ARM_CP_STATE_AA64) || !(r->type & ARM_CP_64BIT));
     /*
      * This API is only for Arm's system coprocessors (14 and 15) or
      * (M-profile or v7A-and-earlier only) for implementation defined
      * coprocessors in the range 0..7.  Our decode assumes this, since
      * 8..13 can be used for other insns including VFP and Neon. See
      * valid_cp() in translate.c.  Assert here that we haven't tried
      * to use an invalid coprocessor number.
      */
     switch (r->state) {
     case ARM_CP_STATE_BOTH:
         /* 0 has a special meaning, but otherwise the same rules as AA32. */
         if (r->cp == 0) {
             break;
         }
-        /* fall through */
+        fallthrough;
     case ARM_CP_STATE_AA32:
         if (arm_feature(&cpu->env, ARM_FEATURE_V8) &&
             !arm_feature(&cpu->env, ARM_FEATURE_M)) {
             assert(r->cp >= 14 && r->cp <= 15);
         } else {
             assert(r->cp < 8 || (r->cp >= 14 && r->cp <= 15));
         }
         break;
     case ARM_CP_STATE_AA64:
         assert(r->cp == 0 || r->cp == CP_REG_ARM64_SYSREG_CP);
         break;
     default:
         g_assert_not_reached();
     }
     /*
      * The AArch64 pseudocode CheckSystemAccess() specifies that op1
      * encodes a minimum access level for the register. We roll this
      * runtime check into our general permission check code, so check
      * here that the reginfo's specified permissions are strict enough
      * to encompass the generic architectural permission check.
      */
     if (r->state != ARM_CP_STATE_AA32) {
         CPAccessRights mask;
         switch (r->opc1) {
         case 0:
             /* min_EL EL1, but some accessible to EL0 via kernel ABI */
             mask = PL0U_R | PL1_RW;
             break;
         case 1: case 2:
             /* min_EL EL1 */
             mask = PL1_RW;
             break;
         case 3:
             /* min_EL EL0 */
             mask = PL0_RW;
             break;
         case 4:
         case 5:
             /* min_EL EL2 */
             mask = PL2_RW;
             break;
         case 6:
             /* min_EL EL3 */
             mask = PL3_RW;
             break;
         case 7:
             /* min_EL EL1, secure mode only (we don't check the latter) */
             mask = PL1_RW;
             break;
         default:
             /* broken reginfo with out-of-range opc1 */
             g_assert_not_reached();
         }
         /* assert our permissions are not too lax (stricter is fine) */
         assert((r->access & ~mask) == 0);
     }
 
     /*
      * Check that the register definition has enough info to handle
      * reads and writes if they are permitted.
      */
     if (!(r->type & (ARM_CP_SPECIAL_MASK | ARM_CP_CONST))) {
         if (r->access & PL3_R) {
             assert((r->fieldoffset ||
                    (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1])) ||
                    r->readfn);
         }
         if (r->access & PL3_W) {
             assert((r->fieldoffset ||
                    (r->bank_fieldoffsets[0] && r->bank_fieldoffsets[1])) ||
                    r->writefn);
         }
     }
 
     for (crm = crmmin; crm <= crmmax; crm++) {
         for (opc1 = opc1min; opc1 <= opc1max; opc1++) {
             for (opc2 = opc2min; opc2 <= opc2max; opc2++) {
                 for (state = ARM_CP_STATE_AA32;
                      state <= ARM_CP_STATE_AA64; state++) {
                     if (r->state != state && r->state != ARM_CP_STATE_BOTH) {
                         continue;
                     }
                     if (state == ARM_CP_STATE_AA32) {
                         /*
                          * Under AArch32 CP registers can be common
                          * (same for secure and non-secure world) or banked.
                          */
                         char *name;
 
                         switch (r->secure) {
                         case ARM_CP_SECSTATE_S:
                         case ARM_CP_SECSTATE_NS:
                             add_cpreg_to_hashtable(cpu, r, opaque, state,
                                                    r->secure, crm, opc1, opc2,
                                                    r->name);
                             break;
                         case ARM_CP_SECSTATE_BOTH:
                             name = g_strdup_printf("%s_S", r->name);
                             add_cpreg_to_hashtable(cpu, r, opaque, state,
                                                    ARM_CP_SECSTATE_S,
                                                    crm, opc1, opc2, name);
                             g_free(name);
                             add_cpreg_to_hashtable(cpu, r, opaque, state,
                                                    ARM_CP_SECSTATE_NS,
                                                    crm, opc1, opc2, r->name);
                             break;
                         default:
                             g_assert_not_reached();
                         }
                     } else {
                         /*
                          * AArch64 registers get mapped to non-secure instance
                          * of AArch32
                          */
                         add_cpreg_to_hashtable(cpu, r, opaque, state,
                                                ARM_CP_SECSTATE_NS,
                                                crm, opc1, opc2, r->name);
                     }
                 }
             }
         }
     }
 }
 
 /* Define a whole list of registers */
@@ -10609,79 +10609,79 @@ void aarch64_sync_64_to_32(CPUARMState *env)
 static void take_aarch32_exception(CPUARMState *env, int new_mode,
                                    uint32_t mask, uint32_t offset,
                                    uint32_t newpc)
 {
     int new_el;
 
     /* Change the CPU state so as to actually take the exception. */
     switch_mode(env, new_mode);
 
     /*
      * For exceptions taken to AArch32 we must clear the SS bit in both
      * PSTATE and in the old-state value we save to SPSR_<mode>, so zero it now.
      */
     env->pstate &= ~PSTATE_SS;
     env->spsr = cpsr_read(env);
     /* Clear IT bits.  */
     env->condexec_bits = 0;
     /* Switch to the new mode, and to the correct instruction set.  */
     env->uncached_cpsr = (env->uncached_cpsr & ~CPSR_M) | new_mode;
 
     /* This must be after mode switching. */
     new_el = arm_current_el(env);
 
     /* Set new mode endianness */
     env->uncached_cpsr &= ~CPSR_E;
     if (env->cp15.sctlr_el[new_el] & SCTLR_EE) {
         env->uncached_cpsr |= CPSR_E;
     }
     /* J and IL must always be cleared for exception entry */
     env->uncached_cpsr &= ~(CPSR_IL | CPSR_J);
     env->daif |= mask;
 
     if (cpu_isar_feature(aa32_ssbs, env_archcpu(env))) {
         if (env->cp15.sctlr_el[new_el] & SCTLR_DSSBS_32) {
             env->uncached_cpsr |= CPSR_SSBS;
         } else {
             env->uncached_cpsr &= ~CPSR_SSBS;
         }
     }
 
     if (new_mode == ARM_CPU_MODE_HYP) {
         env->thumb = (env->cp15.sctlr_el[2] & SCTLR_TE) != 0;
         env->elr_el[2] = env->regs[15];
     } else {
         /* CPSR.PAN is normally preserved preserved unless...  */
         if (cpu_isar_feature(aa32_pan, env_archcpu(env))) {
             switch (new_el) {
             case 3:
                 if (!arm_is_secure_below_el3(env)) {
                     /* ... the target is EL3, from non-secure state.  */
                     env->uncached_cpsr &= ~CPSR_PAN;
                     break;
                 }
                 /* ... the target is EL3, from secure state ... */
-                /* fall through */
+                fallthrough;
             case 1:
                 /* ... the target is EL1 and SCTLR.SPAN is 0.  */
                 if (!(env->cp15.sctlr_el[new_el] & SCTLR_SPAN)) {
                     env->uncached_cpsr |= CPSR_PAN;
                 }
                 break;
             }
         }
         /*
          * this is a lie, as there was no c1_sys on V4T/V5, but who cares
          * and we should just guard the thumb mode on V4
          */
         if (arm_feature(env, ARM_FEATURE_V4T)) {
             env->thumb =
                 (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_TE) != 0;
         }
         env->regs[14] = env->regs[15] + offset;
     }
     env->regs[15] = newpc;
 
     if (tcg_enabled()) {
         arm_rebuild_hflags(env);
     }
 }
@@ -10689,90 +10689,91 @@ static void take_aarch32_exception(CPUARMState *env, int new_mode,
 static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs)
 {
     /*
      * Handle exception entry to Hyp mode; this is sufficiently
      * different to entry to other AArch32 modes that we handle it
      * separately here.
      *
      * The vector table entry used is always the 0x14 Hyp mode entry point,
      * unless this is an UNDEF/SVC/HVC/abort taken from Hyp to Hyp.
      * The offset applied to the preferred return address is always zero
      * (see DDI0487C.a section G1.12.3).
      * PSTATE A/I/F masks are set based only on the SCR.EA/IRQ/FIQ values.
      */
     uint32_t addr, mask;
     ARMCPU *cpu = ARM_CPU(cs);
     CPUARMState *env = &cpu->env;
 
     switch (cs->exception_index) {
     case EXCP_UDEF:
         addr = 0x04;
         break;
     case EXCP_SWI:
         addr = 0x08;
         break;
     case EXCP_BKPT:
         /* Fall through to prefetch abort.  */
+        fallthrough;
     case EXCP_PREFETCH_ABORT:
         env->cp15.ifar_s = env->exception.vaddress;
         qemu_log_mask(CPU_LOG_INT, "...with HIFAR 0x%x\n",
                       (uint32_t)env->exception.vaddress);
         addr = 0x0c;
         break;
     case EXCP_DATA_ABORT:
         env->cp15.dfar_s = env->exception.vaddress;
         qemu_log_mask(CPU_LOG_INT, "...with HDFAR 0x%x\n",
                       (uint32_t)env->exception.vaddress);
         addr = 0x10;
         break;
     case EXCP_IRQ:
         addr = 0x18;
         break;
     case EXCP_FIQ:
         addr = 0x1c;
         break;
     case EXCP_HVC:
         addr = 0x08;
         break;
     case EXCP_HYP_TRAP:
         addr = 0x14;
         break;
     default:
         cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
     }
 
     if (cs->exception_index != EXCP_IRQ && cs->exception_index != EXCP_FIQ) {
         if (!arm_feature(env, ARM_FEATURE_V8)) {
             /*
              * QEMU syndrome values are v8-style. v7 has the IL bit
              * UNK/SBZP for "field not valid" cases, where v8 uses RES1.
              * If this is a v7 CPU, squash the IL bit in those cases.
              */
             if (cs->exception_index == EXCP_PREFETCH_ABORT ||
                 (cs->exception_index == EXCP_DATA_ABORT &&
                  !(env->exception.syndrome & ARM_EL_ISV)) ||
                 syn_get_ec(env->exception.syndrome) == EC_UNCATEGORIZED) {
                 env->exception.syndrome &= ~ARM_EL_IL;
             }
         }
         env->cp15.esr_el[2] = env->exception.syndrome;
     }
 
     if (arm_current_el(env) != 2 && addr < 0x14) {
         addr = 0x14;
     }
 
     mask = 0;
     if (!(env->cp15.scr_el3 & SCR_EA)) {
         mask |= CPSR_A;
     }
     if (!(env->cp15.scr_el3 & SCR_IRQ)) {
         mask |= CPSR_I;
     }
     if (!(env->cp15.scr_el3 & SCR_FIQ)) {
         mask |= CPSR_F;
     }
 
     addr += env->cp15.hvbar;
 
     take_aarch32_exception(env, ARM_CPU_MODE_HYP, mask, 0, addr);
 }
@@ -10780,175 +10781,176 @@ static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs)
 static void arm_cpu_do_interrupt_aarch32(CPUState *cs)
 {
     ARMCPU *cpu = ARM_CPU(cs);
     CPUARMState *env = &cpu->env;
     uint32_t addr;
     uint32_t mask;
     int new_mode;
     uint32_t offset;
     uint32_t moe;
 
     /* If this is a debug exception we must update the DBGDSCR.MOE bits */
     switch (syn_get_ec(env->exception.syndrome)) {
     case EC_BREAKPOINT:
     case EC_BREAKPOINT_SAME_EL:
         moe = 1;
         break;
     case EC_WATCHPOINT:
     case EC_WATCHPOINT_SAME_EL:
         moe = 10;
         break;
     case EC_AA32_BKPT:
         moe = 3;
         break;
     case EC_VECTORCATCH:
         moe = 5;
         break;
     default:
         moe = 0;
         break;
     }
 
     if (moe) {
         env->cp15.mdscr_el1 = deposit64(env->cp15.mdscr_el1, 2, 4, moe);
     }
 
     if (env->exception.target_el == 2) {
         arm_cpu_do_interrupt_aarch32_hyp(cs);
         return;
     }
 
     switch (cs->exception_index) {
     case EXCP_UDEF:
         new_mode = ARM_CPU_MODE_UND;
         addr = 0x04;
         mask = CPSR_I;
         if (env->thumb) {
             offset = 2;
         } else {
             offset = 4;
         }
         break;
     case EXCP_SWI:
         new_mode = ARM_CPU_MODE_SVC;
         addr = 0x08;
         mask = CPSR_I;
         /* The PC already points to the next instruction.  */
         offset = 0;
         break;
     case EXCP_BKPT:
         /* Fall through to prefetch abort.  */
+        fallthrough;
     case EXCP_PREFETCH_ABORT:
         A32_BANKED_CURRENT_REG_SET(env, ifsr, env->exception.fsr);
         A32_BANKED_CURRENT_REG_SET(env, ifar, env->exception.vaddress);
         qemu_log_mask(CPU_LOG_INT, "...with IFSR 0x%x IFAR 0x%x\n",
                       env->exception.fsr, (uint32_t)env->exception.vaddress);
         new_mode = ARM_CPU_MODE_ABT;
         addr = 0x0c;
         mask = CPSR_A | CPSR_I;
         offset = 4;
         break;
     case EXCP_DATA_ABORT:
         A32_BANKED_CURRENT_REG_SET(env, dfsr, env->exception.fsr);
         A32_BANKED_CURRENT_REG_SET(env, dfar, env->exception.vaddress);
         qemu_log_mask(CPU_LOG_INT, "...with DFSR 0x%x DFAR 0x%x\n",
                       env->exception.fsr,
                       (uint32_t)env->exception.vaddress);
         new_mode = ARM_CPU_MODE_ABT;
         addr = 0x10;
         mask = CPSR_A | CPSR_I;
         offset = 8;
         break;
     case EXCP_IRQ:
         new_mode = ARM_CPU_MODE_IRQ;
         addr = 0x18;
         /* Disable IRQ and imprecise data aborts.  */
         mask = CPSR_A | CPSR_I;
         offset = 4;
         if (env->cp15.scr_el3 & SCR_IRQ) {
             /* IRQ routed to monitor mode */
             new_mode = ARM_CPU_MODE_MON;
             mask |= CPSR_F;
         }
         break;
     case EXCP_FIQ:
         new_mode = ARM_CPU_MODE_FIQ;
         addr = 0x1c;
         /* Disable FIQ, IRQ and imprecise data aborts.  */
         mask = CPSR_A | CPSR_I | CPSR_F;
         if (env->cp15.scr_el3 & SCR_FIQ) {
             /* FIQ routed to monitor mode */
             new_mode = ARM_CPU_MODE_MON;
         }
         offset = 4;
         break;
     case EXCP_VIRQ:
         new_mode = ARM_CPU_MODE_IRQ;
         addr = 0x18;
         /* Disable IRQ and imprecise data aborts.  */
         mask = CPSR_A | CPSR_I;
         offset = 4;
         break;
     case EXCP_VFIQ:
         new_mode = ARM_CPU_MODE_FIQ;
         addr = 0x1c;
         /* Disable FIQ, IRQ and imprecise data aborts.  */
         mask = CPSR_A | CPSR_I | CPSR_F;
         offset = 4;
         break;
     case EXCP_VSERR:
         {
             /*
              * Note that this is reported as a data abort, but the DFAR
              * has an UNKNOWN value.  Construct the SError syndrome from
              * AET and ExT fields.
              */
             ARMMMUFaultInfo fi = { .type = ARMFault_AsyncExternal, };
 
             if (extended_addresses_enabled(env)) {
                 env->exception.fsr = arm_fi_to_lfsc(&fi);
             } else {
                 env->exception.fsr = arm_fi_to_sfsc(&fi);
             }
             env->exception.fsr |= env->cp15.vsesr_el2 & 0xd000;
             A32_BANKED_CURRENT_REG_SET(env, dfsr, env->exception.fsr);
             qemu_log_mask(CPU_LOG_INT, "...with IFSR 0x%x\n",
                           env->exception.fsr);
 
             new_mode = ARM_CPU_MODE_ABT;
             addr = 0x10;
             mask = CPSR_A | CPSR_I;
             offset = 8;
         }
         break;
     case EXCP_SMC:
         new_mode = ARM_CPU_MODE_MON;
         addr = 0x08;
         mask = CPSR_A | CPSR_I | CPSR_F;
         offset = 0;
         break;
     default:
         cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
         return; /* Never happens.  Keep compiler happy.  */
     }
 
     if (new_mode == ARM_CPU_MODE_MON) {
         addr += env->cp15.mvbar;
     } else if (A32_BANKED_CURRENT_REG_GET(env, sctlr) & SCTLR_V) {
         /* High vectors. When enabled, base address cannot be remapped. */
         addr += 0xffff0000;
     } else {
         /*
          * ARM v7 architectures provide a vector base address register to remap
          * the interrupt vector table.
          * This register is only followed in non-monitor mode, and is banked.
          * Note: only bits 31:5 are valid.
          */
         addr += A32_BANKED_CURRENT_REG_GET(env, vbar);
     }
 
     if ((env->uncached_cpsr & CPSR_M) == ARM_CPU_MODE_MON) {
         env->cp15.scr_el3 &= ~SCR_NS;
     }
 
     take_aarch32_exception(env, new_mode, mask, offset, addr);
 }
@@ -11056,209 +11058,209 @@ static bool syndrome_is_sync_extabt(uint32_t syndrome)
 /* Handle exception entry to a target EL which is using AArch64 */
 static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
 {
     ARMCPU *cpu = ARM_CPU(cs);
     CPUARMState *env = &cpu->env;
     unsigned int new_el = env->exception.target_el;
     target_ulong addr = env->cp15.vbar_el[new_el];
     unsigned int new_mode = aarch64_pstate_mode(new_el, true);
     unsigned int old_mode;
     unsigned int cur_el = arm_current_el(env);
     int rt;
 
     if (tcg_enabled()) {
         /*
          * Note that new_el can never be 0.  If cur_el is 0, then
          * el0_a64 is is_a64(), else el0_a64 is ignored.
          */
         aarch64_sve_change_el(env, cur_el, new_el, is_a64(env));
     }
 
     if (cur_el < new_el) {
         /*
          * Entry vector offset depends on whether the implemented EL
          * immediately lower than the target level is using AArch32 or AArch64
          */
         bool is_aa64;
         uint64_t hcr;
 
         switch (new_el) {
         case 3:
             is_aa64 = (env->cp15.scr_el3 & SCR_RW) != 0;
             break;
         case 2:
             hcr = arm_hcr_el2_eff(env);
             if ((hcr & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) {
                 is_aa64 = (hcr & HCR_RW) != 0;
                 break;
             }
-            /* fall through */
+            fallthrough;
         case 1:
             is_aa64 = is_a64(env);
             break;
         default:
             g_assert_not_reached();
         }
 
         if (is_aa64) {
             addr += 0x400;
         } else {
             addr += 0x600;
         }
     } else if (pstate_read(env) & PSTATE_SP) {
         addr += 0x200;
     }
 
     switch (cs->exception_index) {
     case EXCP_GPC:
         qemu_log_mask(CPU_LOG_INT, "...with MFAR 0x%" PRIx64 "\n",
                       env->cp15.mfar_el3);
-        /* fall through */
+        fallthrough;
     case EXCP_PREFETCH_ABORT:
     case EXCP_DATA_ABORT:
         /*
          * FEAT_DoubleFault allows synchronous external aborts taken to EL3
          * to be taken to the SError vector entrypoint.
          */
         if (new_el == 3 && (env->cp15.scr_el3 & SCR_EASE) &&
             syndrome_is_sync_extabt(env->exception.syndrome)) {
             addr += 0x180;
         }
         env->cp15.far_el[new_el] = env->exception.vaddress;
         qemu_log_mask(CPU_LOG_INT, "...with FAR 0x%" PRIx64 "\n",
                       env->cp15.far_el[new_el]);
-        /* fall through */
+        fallthrough;
     case EXCP_BKPT:
     case EXCP_UDEF:
     case EXCP_SWI:
     case EXCP_HVC:
     case EXCP_HYP_TRAP:
     case EXCP_SMC:
         switch (syn_get_ec(env->exception.syndrome)) {
         case EC_ADVSIMDFPACCESSTRAP:
             /*
              * QEMU internal FP/SIMD syndromes from AArch32 include the
              * TA and coproc fields which are only exposed if the exception
              * is taken to AArch32 Hyp mode. Mask them out to get a valid
              * AArch64 format syndrome.
              */
             env->exception.syndrome &= ~MAKE_64BIT_MASK(0, 20);
             break;
         case EC_CP14RTTRAP:
         case EC_CP15RTTRAP:
         case EC_CP14DTTRAP:
             /*
              * For a trap on AArch32 MRC/MCR/LDC/STC the Rt field is currently
              * the raw register field from the insn; when taking this to
              * AArch64 we must convert it to the AArch64 view of the register
              * number. Notice that we read a 4-bit AArch32 register number and
              * write back a 5-bit AArch64 one.
              */
             rt = extract32(env->exception.syndrome, 5, 4);
             rt = aarch64_regnum(env, rt);
             env->exception.syndrome = deposit32(env->exception.syndrome,
                                                 5, 5, rt);
             break;
         case EC_CP15RRTTRAP:
         case EC_CP14RRTTRAP:
             /* Similarly for MRRC/MCRR traps for Rt and Rt2 fields */
             rt = extract32(env->exception.syndrome, 5, 4);
             rt = aarch64_regnum(env, rt);
             env->exception.syndrome = deposit32(env->exception.syndrome,
                                                 5, 5, rt);
             rt = extract32(env->exception.syndrome, 10, 4);
             rt = aarch64_regnum(env, rt);
             env->exception.syndrome = deposit32(env->exception.syndrome,
                                                 10, 5, rt);
             break;
         }
         env->cp15.esr_el[new_el] = env->exception.syndrome;
         break;
     case EXCP_IRQ:
     case EXCP_VIRQ:
         addr += 0x80;
         break;
     case EXCP_FIQ:
     case EXCP_VFIQ:
         addr += 0x100;
         break;
     case EXCP_VSERR:
         addr += 0x180;
         /* Construct the SError syndrome from IDS and ISS fields. */
         env->exception.syndrome = syn_serror(env->cp15.vsesr_el2 & 0x1ffffff);
         env->cp15.esr_el[new_el] = env->exception.syndrome;
         break;
     default:
         cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index);
     }
 
     if (is_a64(env)) {
         old_mode = pstate_read(env);
         aarch64_save_sp(env, arm_current_el(env));
         env->elr_el[new_el] = env->pc;
     } else {
         old_mode = cpsr_read_for_spsr_elx(env);
         env->elr_el[new_el] = env->regs[15];
 
         aarch64_sync_32_to_64(env);
 
         env->condexec_bits = 0;
     }
     env->banked_spsr[aarch64_banked_spsr_index(new_el)] = old_mode;
 
     qemu_log_mask(CPU_LOG_INT, "...with ELR 0x%" PRIx64 "\n",
                   env->elr_el[new_el]);
 
     if (cpu_isar_feature(aa64_pan, cpu)) {
         /* The value of PSTATE.PAN is normally preserved, except when ... */
         new_mode |= old_mode & PSTATE_PAN;
         switch (new_el) {
         case 2:
             /* ... the target is EL2 with HCR_EL2.{E2H,TGE} == '11' ...  */
             if ((arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE))
                 != (HCR_E2H | HCR_TGE)) {
                 break;
             }
-            /* fall through */
+            fallthrough;
         case 1:
             /* ... the target is EL1 ... */
             /* ... and SCTLR_ELx.SPAN == 0, then set to 1.  */
             if ((env->cp15.sctlr_el[new_el] & SCTLR_SPAN) == 0) {
                 new_mode |= PSTATE_PAN;
             }
             break;
         }
     }
     if (cpu_isar_feature(aa64_mte, cpu)) {
         new_mode |= PSTATE_TCO;
     }
 
     if (cpu_isar_feature(aa64_ssbs, cpu)) {
         if (env->cp15.sctlr_el[new_el] & SCTLR_DSSBS_64) {
             new_mode |= PSTATE_SSBS;
         } else {
             new_mode &= ~PSTATE_SSBS;
         }
     }
 
     pstate_write(env, PSTATE_DAIF | new_mode);
     env->aarch64 = true;
     aarch64_restore_sp(env, new_el);
 
     if (tcg_enabled()) {
         helper_rebuild_hflags_a64(env, new_el);
     }
 
     env->pc = addr;
 
     qemu_log_mask(CPU_LOG_INT, "...to EL%d PC 0x%" PRIx64 " PSTATE 0x%x\n",
                   new_el, env->pc, pstate_read(env));
 }
 
 /*
  * Do semihosting call and set the appropriate return value. All the
  * permission and validity checks have been done at translate time.
  *
  * We only see semihosting exceptions in TCG only as they are not
  * trapped to the hypervisor in KVM.
  */
 #ifdef CONFIG_TCG
@@ -11909,111 +11911,111 @@ uint32_t HELPER(crc32c)(uint32_t acc, uint32_t val, uint32_t bytes)
 /*
  * Return the exception level to which FP-disabled exceptions should
  * be taken, or 0 if FP is enabled.
  */
 int fp_exception_el(CPUARMState *env, int cur_el)
 {
 #ifndef CONFIG_USER_ONLY
     uint64_t hcr_el2;
 
     /*
      * CPACR and the CPTR registers don't exist before v6, so FP is
      * always accessible
      */
     if (!arm_feature(env, ARM_FEATURE_V6)) {
         return 0;
     }
 
     if (arm_feature(env, ARM_FEATURE_M)) {
         /* CPACR can cause a NOCP UsageFault taken to current security state */
         if (!v7m_cpacr_pass(env, env->v7m.secure, cur_el != 0)) {
             return 1;
         }
 
         if (arm_feature(env, ARM_FEATURE_M_SECURITY) && !env->v7m.secure) {
             if (!extract32(env->v7m.nsacr, 10, 1)) {
                 /* FP insns cause a NOCP UsageFault taken to Secure */
                 return 3;
             }
         }
 
         return 0;
     }
 
     hcr_el2 = arm_hcr_el2_eff(env);
 
     /*
      * The CPACR controls traps to EL1, or PL1 if we're 32 bit:
      * 0, 2 : trap EL0 and EL1/PL1 accesses
      * 1    : trap only EL0 accesses
      * 3    : trap no accesses
      * This register is ignored if E2H+TGE are both set.
      */
     if ((hcr_el2 & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) {
         int fpen = FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, FPEN);
 
         switch (fpen) {
         case 1:
             if (cur_el != 0) {
                 break;
             }
-            /* fall through */
+            fallthrough;
         case 0:
         case 2:
             /* Trap from Secure PL0 or PL1 to Secure PL1. */
             if (!arm_el_is_aa64(env, 3)
                 && (cur_el == 3 || arm_is_secure_below_el3(env))) {
                 return 3;
             }
             if (cur_el <= 1) {
                 return 1;
             }
             break;
         }
     }
 
     /*
      * The NSACR allows A-profile AArch32 EL3 and M-profile secure mode
      * to control non-secure access to the FPU. It doesn't have any
      * effect if EL3 is AArch64 or if EL3 doesn't exist at all.
      */
     if ((arm_feature(env, ARM_FEATURE_EL3) && !arm_el_is_aa64(env, 3) &&
          cur_el <= 2 && !arm_is_secure_below_el3(env))) {
         if (!extract32(env->cp15.nsacr, 10, 1)) {
             /* FP insns act as UNDEF */
             return cur_el == 2 ? 2 : 1;
         }
     }
 
     /*
      * CPTR_EL2 is present in v7VE or v8, and changes format
      * with HCR_EL2.E2H (regardless of TGE).
      */
     if (cur_el <= 2) {
         if (hcr_el2 & HCR_E2H) {
             switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, FPEN)) {
             case 1:
                 if (cur_el != 0 || !(hcr_el2 & HCR_TGE)) {
                     break;
                 }
-                /* fall through */
+                fallthrough;
             case 0:
             case 2:
                 return 2;
             }
         } else if (arm_is_el2_enabled(env)) {
             if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TFP)) {
                 return 2;
             }
         }
     }
 
     /* CPTR_EL3 : present in v8 */
     if (FIELD_EX64(env->cp15.cptr_el[3], CPTR_EL3, TFP)) {
         /* Trap all FP ops to EL3 */
         return 3;
     }
 #endif
     return 0;
 }
 
 /* Return the exception level we're running at if this is our mmu_idx */
target/arm/ptw.c +5 -5
index 95db9ec4c3..3f6783c100 100644
@@ -2240,192 +2240,192 @@ static bool pmsav7_use_background_region(ARMCPU *cpu, ARMMMUIdx mmu_idx,
 static bool get_phys_addr_pmsav7(CPUARMState *env,
                                  S1Translate *ptw,
                                  uint32_t address,
                                  MMUAccessType access_type,
                                  GetPhysAddrResult *result,
                                  ARMMMUFaultInfo *fi)
 {
     ARMCPU *cpu = env_archcpu(env);
     int n;
     ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
     bool is_user = regime_is_user(env, mmu_idx);
     bool secure = arm_space_is_secure(ptw->in_space);
 
     result->f.phys_addr = address;
     result->f.lg_page_size = TARGET_PAGE_BITS;
     result->f.prot = 0;
 
     if (regime_translation_disabled(env, mmu_idx, ptw->in_space) ||
         m_is_ppb_region(env, address)) {
         /*
          * MPU disabled or M profile PPB access: use default memory map.
          * The other case which uses the default memory map in the
          * v7M ARM ARM pseudocode is exception vector reads from the vector
          * table. In QEMU those accesses are done in arm_v7m_load_vector(),
          * which always does a direct read using address_space_ldl(), rather
          * than going via this function, so we don't need to check that here.
          */
         get_phys_addr_pmsav7_default(env, mmu_idx, address, &result->f.prot);
     } else { /* MPU enabled */
         for (n = (int)cpu->pmsav7_dregion - 1; n >= 0; n--) {
             /* region search */
             uint32_t base = env->pmsav7.drbar[n];
             uint32_t rsize = extract32(env->pmsav7.drsr[n], 1, 5);
             uint32_t rmask;
             bool srdis = false;
 
             if (!(env->pmsav7.drsr[n] & 0x1)) {
                 continue;
             }
 
             if (!rsize) {
                 qemu_log_mask(LOG_GUEST_ERROR,
                               "DRSR[%d]: Rsize field cannot be 0\n", n);
                 continue;
             }
             rsize++;
             rmask = (1ull << rsize) - 1;
 
             if (base & rmask) {
                 qemu_log_mask(LOG_GUEST_ERROR,
                               "DRBAR[%d]: 0x%" PRIx32 " misaligned "
                               "to DRSR region size, mask = 0x%" PRIx32 "\n",
                               n, base, rmask);
                 continue;
             }
 
             if (address < base || address > base + rmask) {
                 /*
                  * Address not in this region. We must check whether the
                  * region covers addresses in the same page as our address.
                  * In that case we must not report a size that covers the
                  * whole page for a subsequent hit against a different MPU
                  * region or the background region, because it would result in
                  * incorrect TLB hits for subsequent accesses to addresses that
                  * are in this MPU region.
                  */
                 if (ranges_overlap(base, rmask,
                                    address & TARGET_PAGE_MASK,
                                    TARGET_PAGE_SIZE)) {
                     result->f.lg_page_size = 0;
                 }
                 continue;
             }
 
             /* Region matched */
 
             if (rsize >= 8) { /* no subregions for regions < 256 bytes */
                 int i, snd;
                 uint32_t srdis_mask;
 
                 rsize -= 3; /* sub region size (power of 2) */
                 snd = ((address - base) >> rsize) & 0x7;
                 srdis = extract32(env->pmsav7.drsr[n], snd + 8, 1);
 
                 srdis_mask = srdis ? 0x3 : 0x0;
                 for (i = 2; i <= 8 && rsize < TARGET_PAGE_BITS; i *= 2) {
                     /*
                      * This will check in groups of 2, 4 and then 8, whether
                      * the subregion bits are consistent. rsize is incremented
                      * back up to give the region size, considering consistent
                      * adjacent subregions as one region. Stop testing if rsize
                      * is already big enough for an entire QEMU page.
                      */
                     int snd_rounded = snd & ~(i - 1);
                     uint32_t srdis_multi = extract32(env->pmsav7.drsr[n],
                                                      snd_rounded + 8, i);
                     if (srdis_mask ^ srdis_multi) {
                         break;
                     }
                     srdis_mask = (srdis_mask << i) | srdis_mask;
                     rsize++;
                 }
             }
             if (srdis) {
                 continue;
             }
             if (rsize < TARGET_PAGE_BITS) {
                 result->f.lg_page_size = rsize;
             }
             break;
         }
 
         if (n == -1) { /* no hits */
             if (!pmsav7_use_background_region(cpu, mmu_idx, secure, is_user)) {
                 /* background fault */
                 fi->type = ARMFault_Background;
                 return true;
             }
             get_phys_addr_pmsav7_default(env, mmu_idx, address,
                                          &result->f.prot);
         } else { /* a MPU hit! */
             uint32_t ap = extract32(env->pmsav7.dracr[n], 8, 3);
             uint32_t xn = extract32(env->pmsav7.dracr[n], 12, 1);
 
             if (m_is_system_region(env, address)) {
                 /* System space is always execute never */
                 xn = 1;
             }
 
             if (is_user) { /* User mode AP bit decoding */
                 switch (ap) {
                 case 0:
                 case 1:
                 case 5:
                     break; /* no access */
                 case 3:
                     result->f.prot |= PAGE_WRITE;
-                    /* fall through */
+                    fallthrough;
                 case 2:
                 case 6:
                     result->f.prot |= PAGE_READ | PAGE_EXEC;
                     break;
                 case 7:
                     /* for v7M, same as 6; for R profile a reserved value */
                     if (arm_feature(env, ARM_FEATURE_M)) {
                         result->f.prot |= PAGE_READ | PAGE_EXEC;
                         break;
                     }
-                    /* fall through */
+                    fallthrough;
                 default:
                     qemu_log_mask(LOG_GUEST_ERROR,
                                   "DRACR[%d]: Bad value for AP bits: 0x%"
                                   PRIx32 "\n", n, ap);
                 }
             } else { /* Priv. mode AP bits decoding */
                 switch (ap) {
                 case 0:
                     break; /* no access */
                 case 1:
                 case 2:
                 case 3:
                     result->f.prot |= PAGE_WRITE;
-                    /* fall through */
+                    fallthrough;
                 case 5:
                 case 6:
                     result->f.prot |= PAGE_READ | PAGE_EXEC;
                     break;
                 case 7:
                     /* for v7M, same as 6; for R profile a reserved value */
                     if (arm_feature(env, ARM_FEATURE_M)) {
                         result->f.prot |= PAGE_READ | PAGE_EXEC;
                         break;
                     }
-                    /* fall through */
+                    fallthrough;
                 default:
                     qemu_log_mask(LOG_GUEST_ERROR,
                                   "DRACR[%d]: Bad value for AP bits: 0x%"
                                   PRIx32 "\n", n, ap);
                 }
             }
 
             /* execute never */
             if (xn) {
                 result->f.prot &= ~PAGE_EXEC;
             }
         }
     }
 
     fi->type = ARMFault_Permission;
     fi->level = 1;
     return !(result->f.prot & (1 << access_type));
 }
@@ -3269,136 +3269,136 @@ static bool get_phys_addr_twostage(CPUARMState *env, S1Translate *ptw,
 static bool get_phys_addr_nogpc(CPUARMState *env, S1Translate *ptw,
                                       target_ulong address,
                                       MMUAccessType access_type,
                                       GetPhysAddrResult *result,
                                       ARMMMUFaultInfo *fi)
 {
     ARMMMUIdx mmu_idx = ptw->in_mmu_idx;
     ARMMMUIdx s1_mmu_idx;
 
     /*
      * The page table entries may downgrade Secure to NonSecure, but
      * cannot upgrade a NonSecure translation regime's attributes
      * to Secure or Realm.
      */
     result->f.attrs.space = ptw->in_space;
     result->f.attrs.secure = arm_space_is_secure(ptw->in_space);
 
     switch (mmu_idx) {
     case ARMMMUIdx_Phys_S:
     case ARMMMUIdx_Phys_NS:
     case ARMMMUIdx_Phys_Root:
     case ARMMMUIdx_Phys_Realm:
         /* Checking Phys early avoids special casing later vs regime_el. */
         return get_phys_addr_disabled(env, ptw, address, access_type,
                                       result, fi);
 
     case ARMMMUIdx_Stage1_E0:
     case ARMMMUIdx_Stage1_E1:
     case ARMMMUIdx_Stage1_E1_PAN:
         /*
          * First stage lookup uses second stage for ptw; only
          * Secure has both S and NS IPA and starts with Stage2_S.
          */
         ptw->in_ptw_idx = (ptw->in_space == ARMSS_Secure) ?
             ARMMMUIdx_Stage2_S : ARMMMUIdx_Stage2;
         break;
 
     case ARMMMUIdx_Stage2:
     case ARMMMUIdx_Stage2_S:
         /*
          * Second stage lookup uses physical for ptw; whether this is S or
          * NS may depend on the SW/NSW bits if this is a stage 2 lookup for
          * the Secure EL2&0 regime.
          */
         ptw->in_ptw_idx = ptw_idx_for_stage_2(env, mmu_idx);
         break;
 
     case ARMMMUIdx_E10_0:
         s1_mmu_idx = ARMMMUIdx_Stage1_E0;
         goto do_twostage;
     case ARMMMUIdx_E10_1:
         s1_mmu_idx = ARMMMUIdx_Stage1_E1;
         goto do_twostage;
     case ARMMMUIdx_E10_1_PAN:
         s1_mmu_idx = ARMMMUIdx_Stage1_E1_PAN;
     do_twostage:
         /*
          * Call ourselves recursively to do the stage 1 and then stage 2
          * translations if mmu_idx is a two-stage regime, and EL2 present.
          * Otherwise, a stage1+stage2 translation is just stage 1.
          */
         ptw->in_mmu_idx = mmu_idx = s1_mmu_idx;
         if (arm_feature(env, ARM_FEATURE_EL2) &&
             !regime_translation_disabled(env, ARMMMUIdx_Stage2, ptw->in_space)) {
             return get_phys_addr_twostage(env, ptw, address, access_type,
                                           result, fi);
         }
-        /* fall through */
+        fallthrough;
 
     default:
         /* Single stage uses physical for ptw. */
         ptw->in_ptw_idx = arm_space_to_phys(ptw->in_space);
         break;
     }
 
     result->f.attrs.user = regime_is_user(env, mmu_idx);
 
     /*
      * Fast Context Switch Extension. This doesn't exist at all in v8.
      * In v7 and earlier it affects all stage 1 translations.
      */
     if (address < 0x02000000 && mmu_idx != ARMMMUIdx_Stage2
         && !arm_feature(env, ARM_FEATURE_V8)) {
         if (regime_el(env, mmu_idx) == 3) {
             address += env->cp15.fcseidr_s;
         } else {
             address += env->cp15.fcseidr_ns;
         }
     }
 
     if (arm_feature(env, ARM_FEATURE_PMSA)) {
         bool ret;
         result->f.lg_page_size = TARGET_PAGE_BITS;
 
         if (arm_feature(env, ARM_FEATURE_V8)) {
             /* PMSAv8 */
             ret = get_phys_addr_pmsav8(env, ptw, address, access_type,
                                        result, fi);
         } else if (arm_feature(env, ARM_FEATURE_V7)) {
             /* PMSAv7 */
             ret = get_phys_addr_pmsav7(env, ptw, address, access_type,
                                        result, fi);
         } else {
             /* Pre-v7 MPU */
             ret = get_phys_addr_pmsav5(env, ptw, address, access_type,
                                        result, fi);
         }
         qemu_log_mask(CPU_LOG_MMU, "PMSA MPU lookup for %s at 0x%08" PRIx32
                       " mmu_idx %u -> %s (prot %c%c%c)\n",
                       access_type == MMU_DATA_LOAD ? "reading" :
                       (access_type == MMU_DATA_STORE ? "writing" : "execute"),
                       (uint32_t)address, mmu_idx,
                       ret ? "Miss" : "Hit",
                       result->f.prot & PAGE_READ ? 'r' : '-',
                       result->f.prot & PAGE_WRITE ? 'w' : '-',
                       result->f.prot & PAGE_EXEC ? 'x' : '-');
 
         return ret;
     }
 
     /* Definitely a real MMU, not an MPU */
 
     if (regime_translation_disabled(env, mmu_idx, ptw->in_space)) {
         return get_phys_addr_disabled(env, ptw, address, access_type,
                                       result, fi);
     }
 
     if (regime_using_lpae_format(env, mmu_idx)) {
         return get_phys_addr_lpae(env, ptw, address, access_type, result, fi);
     } else if (arm_feature(env, ARM_FEATURE_V7) ||
                regime_sctlr(env, mmu_idx) & SCTLR_XP) {
         return get_phys_addr_v6(env, ptw, address, access_type, result, fi);
     } else {
         return get_phys_addr_v5(env, ptw, address, access_type, result, fi);
     }
 }
target/arm/tcg/psci.c +1 -1
index 6c1239bb96..dafc39c3d7 100644
@@ -56,152 +56,152 @@ bool arm_is_psci_call(ARMCPU *cpu, int excp_type)
 void arm_handle_psci_call(ARMCPU *cpu)
 {
     /*
      * This function partially implements the logic for dispatching Power State
      * Coordination Interface (PSCI) calls (as described in ARM DEN 0022D.b),
      * to the extent required for bringing up and taking down secondary cores,
      * and for handling reset and poweroff requests.
      * Additional information about the calling convention used is available in
      * the document 'SMC Calling Convention' (ARM DEN 0028)
      */
     CPUARMState *env = &cpu->env;
     uint64_t param[4];
     uint64_t context_id, mpidr;
     target_ulong entry;
     int32_t ret = 0;
     int i;
 
     for (i = 0; i < 4; i++) {
         /*
          * All PSCI functions take explicit 32-bit or native int sized
          * arguments so we can simply zero-extend all arguments regardless
          * of which exact function we are about to call.
          */
         param[i] = is_a64(env) ? env->xregs[i] : env->regs[i];
     }
 
     if ((param[0] & QEMU_PSCI_0_2_64BIT) && !is_a64(env)) {
         ret = QEMU_PSCI_RET_NOT_SUPPORTED;
         goto err;
     }
 
     switch (param[0]) {
         CPUState *target_cpu_state;
         ARMCPU *target_cpu;
 
     case QEMU_PSCI_0_2_FN_PSCI_VERSION:
         ret = QEMU_PSCI_VERSION_1_1;
         break;
     case QEMU_PSCI_0_2_FN_MIGRATE_INFO_TYPE:
         ret = QEMU_PSCI_0_2_RET_TOS_MIGRATION_NOT_REQUIRED; /* No trusted OS */
         break;
     case QEMU_PSCI_0_2_FN_AFFINITY_INFO:
     case QEMU_PSCI_0_2_FN64_AFFINITY_INFO:
         mpidr = param[1];
 
         switch (param[2]) {
         case 0:
             target_cpu_state = arm_get_cpu_by_id(mpidr);
             if (!target_cpu_state) {
                 ret = QEMU_PSCI_RET_INVALID_PARAMS;
                 break;
             }
             target_cpu = ARM_CPU(target_cpu_state);
 
             g_assert(qemu_mutex_iothread_locked());
             ret = target_cpu->power_state;
             break;
         default:
             /* Everything above affinity level 0 is always on. */
             ret = 0;
         }
         break;
     case QEMU_PSCI_0_2_FN_SYSTEM_RESET:
         qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
         /* QEMU reset and shutdown are async requests, but PSCI
          * mandates that we never return from the reset/shutdown
          * call, so power the CPU off now so it doesn't execute
          * anything further.
          */
         goto cpu_off;
     case QEMU_PSCI_0_2_FN_SYSTEM_OFF:
         qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
         goto cpu_off;
     case QEMU_PSCI_0_1_FN_CPU_ON:
     case QEMU_PSCI_0_2_FN_CPU_ON:
     case QEMU_PSCI_0_2_FN64_CPU_ON:
     {
         /* The PSCI spec mandates that newly brought up CPUs start
          * in the highest exception level which exists and is enabled
          * on the calling CPU. Since the QEMU PSCI implementation is
          * acting as a "fake EL3" or "fake EL2" firmware, this for us
          * means that we want to start at the highest NS exception level
          * that we are providing to the guest.
          * The execution mode should be that which is currently in use
          * by the same exception level on the calling CPU.
          * The CPU should be started with the context_id value
          * in x0 (if AArch64) or r0 (if AArch32).
          */
         int target_el = arm_feature(env, ARM_FEATURE_EL2) ? 2 : 1;
         bool target_aarch64 = arm_el_is_aa64(env, target_el);
 
         mpidr = param[1];
         entry = param[2];
         context_id = param[3];
         ret = arm_set_cpu_on(mpidr, entry, context_id,
                              target_el, target_aarch64);
         break;
     }
     case QEMU_PSCI_0_1_FN_CPU_OFF:
     case QEMU_PSCI_0_2_FN_CPU_OFF:
         goto cpu_off;
     case QEMU_PSCI_0_1_FN_CPU_SUSPEND:
     case QEMU_PSCI_0_2_FN_CPU_SUSPEND:
     case QEMU_PSCI_0_2_FN64_CPU_SUSPEND:
         /* Affinity levels are not supported in QEMU */
         if (param[1] & 0xfffe0000) {
             ret = QEMU_PSCI_RET_INVALID_PARAMS;
             break;
         }
         /* Powerdown is not supported, we always go into WFI */
         if (is_a64(env)) {
             env->xregs[0] = 0;
         } else {
             env->regs[0] = 0;
         }
         helper_wfi(env, 4);
         break;
     case QEMU_PSCI_1_0_FN_PSCI_FEATURES:
         switch (param[1]) {
         case QEMU_PSCI_0_2_FN_PSCI_VERSION:
         case QEMU_PSCI_0_2_FN_MIGRATE_INFO_TYPE:
         case QEMU_PSCI_0_2_FN_AFFINITY_INFO:
         case QEMU_PSCI_0_2_FN64_AFFINITY_INFO:
         case QEMU_PSCI_0_2_FN_SYSTEM_RESET:
         case QEMU_PSCI_0_2_FN_SYSTEM_OFF:
         case QEMU_PSCI_0_1_FN_CPU_ON:
         case QEMU_PSCI_0_2_FN_CPU_ON:
         case QEMU_PSCI_0_2_FN64_CPU_ON:
         case QEMU_PSCI_0_1_FN_CPU_OFF:
         case QEMU_PSCI_0_2_FN_CPU_OFF:
         case QEMU_PSCI_0_1_FN_CPU_SUSPEND:
         case QEMU_PSCI_0_2_FN_CPU_SUSPEND:
         case QEMU_PSCI_0_2_FN64_CPU_SUSPEND:
         case QEMU_PSCI_1_0_FN_PSCI_FEATURES:
             if (!(param[1] & QEMU_PSCI_0_2_64BIT) || is_a64(env)) {
                 ret = 0;
                 break;
             }
-            /* fallthrough */
+            fallthrough;
         case QEMU_PSCI_0_1_FN_MIGRATE:
         case QEMU_PSCI_0_2_FN_MIGRATE:
         default:
             ret = QEMU_PSCI_RET_NOT_SUPPORTED;
             break;
         }
         break;
     case QEMU_PSCI_0_1_FN_MIGRATE:
     case QEMU_PSCI_0_2_FN_MIGRATE:
     default:
         ret = QEMU_PSCI_RET_NOT_SUPPORTED;
         break;
     }
target/arm/tcg/translate-a64.c +38 -38

1,392 lines not on this page · raw message

target/arm/tcg/translate-m-nocp.c +1 -1
index f564d06ccf..42d6f516ba 100644

Lines of this file are not shown. View the raw message.

target/arm/tcg/translate-vfp.c +1 -1
index b9af03b7c3..57d3c41596 100644

Lines of this file are not shown. View the raw message.

target/arm/tcg/translate.c +4 -4
index 48927fbb8c..595ef02f0d 100644

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.

#22 lore raw

RFC PATCH v2 13/78 hw/adc: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In 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
index 0d29663129..f9f5f7bb17 100644
@@ -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
index 032e19cbd0..a74de3a4fd 100644
@@ -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
#68 lore raw

RFC PATCH v2 58/78 hw/ppc: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/ppc/pnv_bmc.c      | 2 +-
 hw/ppc/spapr_events.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
hw/ppc/pnv_bmc.c +1 -1
index 99f1e8d7f9..9bff7d03cb 100644
@@ -172,69 +172,69 @@ static int hiomap_erase(PnvPnor *pnor, uint32_t offset, uint32_t size)
 static void hiomap_cmd(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len,
                        RspBuffer *rsp)
 {
     PnvPnor *pnor = PNV_PNOR(object_property_get_link(OBJECT(ibs), "pnor",
                                                       &error_abort));
     uint32_t pnor_size = pnor->size;
     uint32_t pnor_addr = PNOR_SPI_OFFSET;
     bool readonly = false;
 
     rsp_buffer_push(rsp, cmd[2]);
     rsp_buffer_push(rsp, cmd[3]);
 
     switch (cmd[2]) {
     case HIOMAP_C_MARK_DIRTY:
     case HIOMAP_C_FLUSH:
     case HIOMAP_C_ACK:
         break;
 
     case HIOMAP_C_ERASE:
         if (hiomap_erase(pnor, blocks_to_bytes(cmd[5] << 8 | cmd[4]),
                         blocks_to_bytes(cmd[7] << 8 | cmd[6]))) {
             rsp_buffer_set_error(rsp, IPMI_CC_UNSPECIFIED);
         }
         break;
 
     case HIOMAP_C_GET_INFO:
         rsp_buffer_push(rsp, 2);  /* Version 2 */
         rsp_buffer_push(rsp, BLOCK_SHIFT); /* block size */
         rsp_buffer_push(rsp, 0);  /* Timeout */
         rsp_buffer_push(rsp, 0);  /* Timeout */
         break;
 
     case HIOMAP_C_GET_FLASH_INFO:
         rsp_buffer_push(rsp, bytes_to_blocks(pnor_size) & 0xFF);
         rsp_buffer_push(rsp, bytes_to_blocks(pnor_size) >> 8);
         rsp_buffer_push(rsp, 0x01);  /* erase size */
         rsp_buffer_push(rsp, 0x00);  /* erase size */
         break;
 
     case HIOMAP_C_CREATE_READ_WINDOW:
         readonly = true;
-        /* Fall through */
+        fallthrough;
 
     case HIOMAP_C_CREATE_WRITE_WINDOW:
         memory_region_set_readonly(&pnor->mmio, readonly);
         memory_region_set_enabled(&pnor->mmio, true);
 
         rsp_buffer_push(rsp, bytes_to_blocks(pnor_addr) & 0xFF);
         rsp_buffer_push(rsp, bytes_to_blocks(pnor_addr) >> 8);
         rsp_buffer_push(rsp, bytes_to_blocks(pnor_size) & 0xFF);
         rsp_buffer_push(rsp, bytes_to_blocks(pnor_size) >> 8);
         rsp_buffer_push(rsp, 0x00); /* offset */
         rsp_buffer_push(rsp, 0x00); /* offset */
         break;
 
     case HIOMAP_C_CLOSE_WINDOW:
         memory_region_set_enabled(&pnor->mmio, false);
         break;
 
     case HIOMAP_C_DEVICE_NAME:
     case HIOMAP_C_RESET:
     case HIOMAP_C_LOCK:
     default:
         qemu_log_mask(LOG_GUEST_ERROR, "HIOMAP: unknown command %02X\n", cmd[2]);
         break;
     }
 }
 
 #define HIOMAP   0x5a
hw/ppc/spapr_events.c +1 -0
index 4508e40814..9d51746daf 100644
@@ -411,25 +411,26 @@ static const SpaprEventSource *
 rtas_event_log_to_source(SpaprMachineState *spapr, int log_type)
 {
     const SpaprEventSource *source;
 
     g_assert(spapr->event_sources);
 
     switch (log_type) {
     case RTAS_LOG_TYPE_HOTPLUG:
         source = spapr_event_sources_get_source(spapr->event_sources,
                                                 EVENT_CLASS_HOT_PLUG);
         if (spapr_ovec_test(spapr->ov5_cas, OV5_HP_EVT)) {
             g_assert(source->enabled);
             break;
         }
         /* fall through back to epow for legacy hotplug interrupt source */
+        fallthrough;
     case RTAS_LOG_TYPE_EPOW:
         source = spapr_event_sources_get_source(spapr->event_sources,
                                                 EVENT_CLASS_EPOW);
         break;
     default:
         source = NULL;
     }
 
     return source;
 }
Signature · 1 line
2.39.2
#1 lore raw

RFC PATCH v2 1/78 include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough

In reply to Emmanouil Pitsidianakis
---
 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
index 3ce5f6507b..bf26fadb06 100644
@@ -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
index 6f2b2bd45f..545d82ff04 100644
@@ -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
index 1109482a00..959982805d 100644
@@ -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
index 475a1c62ff..8f790f0deb 100644
@@ -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
index 2bea7ca5d5..e01d626b15 100644
@@ -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
index 21f4db6fbd..36fceb1beb 100644
@@ -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
index 3013eb04e6..3da135a353 100644
@@ -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
#20 lore raw

RFC PATCH v2 11/78 hw/timer: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In 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
index 5e959b6d09..b83d51da96 100644
@@ -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
index 72161f07bb..b343b7ab2c 100644
@@ -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
index 43b31213bc..a32521e3c3 100644
@@ -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
index 7788939766..6dbfc2595b 100644
@@ -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
#49 lore raw

RFC PATCH v2 39/78 hw/scsi: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/scsi/esp.c       | 2 +-
 hw/scsi/megasas.c   | 2 +-
 hw/scsi/scsi-bus.c  | 4 ++--
 hw/scsi/scsi-disk.c | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
hw/scsi/esp.c +1 -1
index 9b11d8c573..d6c8298f51 100644
@@ -1022,130 +1022,130 @@ uint64_t esp_reg_read(ESPState *s, uint32_t saddr)
 void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val)
 {
     trace_esp_mem_writeb(saddr, s->wregs[saddr], val);
     switch (saddr) {
     case ESP_TCHI:
         s->tchi_written = true;
-        /* fall through */
+        fallthrough;
     case ESP_TCLO:
     case ESP_TCMID:
         s->rregs[ESP_RSTAT] &= ~STAT_TC;
         break;
     case ESP_FIFO:
         if (s->do_cmd) {
             esp_fifo_push(&s->cmdfifo, val);
 
             /*
              * If any unexpected message out/command phase data is
              * transferred using non-DMA, raise the interrupt
              */
             if (s->rregs[ESP_CMD] == CMD_TI) {
                 s->rregs[ESP_RINTR] |= INTR_BS;
                 esp_raise_irq(s);
             }
         } else {
             esp_fifo_push(&s->fifo, val);
         }
         break;
     case ESP_CMD:
         s->rregs[saddr] = val;
         if (val & CMD_DMA) {
             s->dma = 1;
             /* Reload DMA counter.  */
             if (esp_get_stc(s) == 0) {
                 esp_set_tc(s, 0x10000);
             } else {
                 esp_set_tc(s, esp_get_stc(s));
             }
         } else {
             s->dma = 0;
         }
         switch (val & CMD_CMD) {
         case CMD_NOP:
             trace_esp_mem_writeb_cmd_nop(val);
             break;
         case CMD_FLUSH:
             trace_esp_mem_writeb_cmd_flush(val);
             fifo8_reset(&s->fifo);
             break;
         case CMD_RESET:
             trace_esp_mem_writeb_cmd_reset(val);
             esp_soft_reset(s);
             break;
         case CMD_BUSRESET:
             trace_esp_mem_writeb_cmd_bus_reset(val);
             esp_bus_reset(s);
             if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) {
                 s->rregs[ESP_RINTR] |= INTR_RST;
                 esp_raise_irq(s);
             }
             break;
         case CMD_TI:
             trace_esp_mem_writeb_cmd_ti(val);
             handle_ti(s);
             break;
         case CMD_ICCS:
             trace_esp_mem_writeb_cmd_iccs(val);
             write_response(s);
             s->rregs[ESP_RINTR] |= INTR_FC;
             s->rregs[ESP_RSTAT] |= STAT_MI;
             break;
         case CMD_MSGACC:
             trace_esp_mem_writeb_cmd_msgacc(val);
             s->rregs[ESP_RINTR] |= INTR_DC;
             s->rregs[ESP_RSEQ] = 0;
             s->rregs[ESP_RFLAGS] = 0;
             esp_raise_irq(s);
             break;
         case CMD_PAD:
             trace_esp_mem_writeb_cmd_pad(val);
             s->rregs[ESP_RSTAT] = STAT_TC;
             s->rregs[ESP_RINTR] |= INTR_FC;
             s->rregs[ESP_RSEQ] = 0;
             break;
         case CMD_SATN:
             trace_esp_mem_writeb_cmd_satn(val);
             break;
         case CMD_RSTATN:
             trace_esp_mem_writeb_cmd_rstatn(val);
             break;
         case CMD_SEL:
             trace_esp_mem_writeb_cmd_sel(val);
             handle_s_without_atn(s);
             break;
         case CMD_SELATN:
             trace_esp_mem_writeb_cmd_selatn(val);
             handle_satn(s);
             break;
         case CMD_SELATNS:
             trace_esp_mem_writeb_cmd_selatns(val);
             handle_satn_stop(s);
             break;
         case CMD_ENSEL:
             trace_esp_mem_writeb_cmd_ensel(val);
             s->rregs[ESP_RINTR] = 0;
             break;
         case CMD_DISSEL:
             trace_esp_mem_writeb_cmd_dissel(val);
             s->rregs[ESP_RINTR] = 0;
             esp_raise_irq(s);
             break;
         default:
             trace_esp_error_unhandled_command(val);
             break;
         }
         break;
     case ESP_WBUSID ... ESP_WSYNO:
         break;
     case ESP_CFG1:
     case ESP_CFG2: case ESP_CFG3:
     case ESP_RES3: case ESP_RES4:
         s->rregs[saddr] = val;
         break;
     case ESP_WCCF ... ESP_WTEST:
         break;
     default:
         trace_esp_error_invalid_write(val, saddr);
         return;
     }
     s->wregs[saddr] = val;
 }
hw/scsi/megasas.c +1 -1
index 32c70c9e99..54e4d7c8b6 100644
@@ -2084,113 +2084,113 @@ static int adp_reset_seq[] = {0x00, 0x04, 0x0b, 0x02, 0x07, 0x0d};
 static void megasas_mmio_write(void *opaque, hwaddr addr,
                                uint64_t val, unsigned size)
 {
     MegasasState *s = opaque;
     PCIDevice *pci_dev = PCI_DEVICE(s);
     uint64_t frame_addr;
     uint32_t frame_count;
     int i;
 
     switch (addr) {
     case MFI_IDB:
         trace_megasas_mmio_writel("MFI_IDB", val);
         if (val & MFI_FWINIT_ABORT) {
             /* Abort all pending cmds */
             for (i = 0; i < s->fw_cmds; i++) {
                 megasas_abort_command(&s->frames[i]);
             }
         }
         if (val & MFI_FWINIT_READY) {
             /* move to FW READY */
             megasas_soft_reset(s);
         }
         if (val & MFI_FWINIT_MFIMODE) {
             /* discard MFIs */
         }
         if (val & MFI_FWINIT_STOP_ADP) {
             /* Terminal error, stop processing */
             s->fw_state = MFI_FWSTATE_FAULT;
         }
         break;
     case MFI_OMSK:
         trace_megasas_mmio_writel("MFI_OMSK", val);
         s->intr_mask = val;
         if (!megasas_intr_enabled(s) &&
             !msi_enabled(pci_dev) &&
             !msix_enabled(pci_dev)) {
             trace_megasas_irq_lower();
             pci_irq_deassert(pci_dev);
         }
         if (megasas_intr_enabled(s)) {
             if (msix_enabled(pci_dev)) {
                 trace_megasas_msix_enabled(0);
             } else if (msi_enabled(pci_dev)) {
                 trace_megasas_msi_enabled(0);
             } else {
                 trace_megasas_intr_enabled();
             }
         } else {
             trace_megasas_intr_disabled();
             megasas_soft_reset(s);
         }
         break;
     case MFI_ODCR0:
         trace_megasas_mmio_writel("MFI_ODCR0", val);
         s->doorbell = 0;
         if (megasas_intr_enabled(s)) {
             if (!msix_enabled(pci_dev) && !msi_enabled(pci_dev)) {
                 trace_megasas_irq_lower();
                 pci_irq_deassert(pci_dev);
             }
         }
         break;
     case MFI_IQPH:
         trace_megasas_mmio_writel("MFI_IQPH", val);
         /* Received high 32 bits of a 64 bit MFI frame address */
         s->frame_hi = val;
         break;
     case MFI_IQPL:
         trace_megasas_mmio_writel("MFI_IQPL", val);
         /* Received low 32 bits of a 64 bit MFI frame address */
-        /* Fallthrough */
+        fallthrough;
     case MFI_IQP:
         if (addr == MFI_IQP) {
             trace_megasas_mmio_writel("MFI_IQP", val);
             /* Received 64 bit MFI frame address */
             s->frame_hi = 0;
         }
         frame_addr = (val & ~0x1F);
         /* Add possible 64 bit offset */
         frame_addr |= ((uint64_t)s->frame_hi << 32);
         s->frame_hi = 0;
         frame_count = (val >> 1) & 0xF;
         megasas_handle_frame(s, frame_addr, frame_count);
         break;
     case MFI_SEQ:
         trace_megasas_mmio_writel("MFI_SEQ", val);
         /* Magic sequence to start ADP reset */
         if (adp_reset_seq[s->adp_reset++] == val) {
             if (s->adp_reset == 6) {
                 s->adp_reset = 0;
                 s->diag = MFI_DIAG_WRITE_ENABLE;
             }
         } else {
             s->adp_reset = 0;
             s->diag = 0;
         }
         break;
     case MFI_DIAG:
         trace_megasas_mmio_writel("MFI_DIAG", val);
         /* ADP reset */
         if ((s->diag & MFI_DIAG_WRITE_ENABLE) &&
             (val & MFI_DIAG_RESET_ADP)) {
             s->diag |= MFI_DIAG_RESET_ADP;
             megasas_soft_reset(s);
             s->adp_reset = 0;
             s->diag = 0;
         }
         break;
     default:
         trace_megasas_mmio_invalid_writel(addr, val);
         break;
     }
 }
hw/scsi/scsi-bus.c +2 -2
index fc4b77fdb0..a1c298a92c 100644
@@ -1015,141 +1015,141 @@ static int ata_passthrough_16_xfer(SCSIDevice *dev, uint8_t *buf)
 static int scsi_req_xfer(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf)
 {
     cmd->xfer = scsi_cdb_xfer(buf);
     switch (buf[0]) {
     case TEST_UNIT_READY:
     case REWIND:
     case START_STOP:
     case SET_CAPACITY:
     case WRITE_FILEMARKS:
     case WRITE_FILEMARKS_16:
     case SPACE:
     case RESERVE:
     case RELEASE:
     case ERASE:
     case ALLOW_MEDIUM_REMOVAL:
     case SEEK_10:
     case SYNCHRONIZE_CACHE:
     case SYNCHRONIZE_CACHE_16:
     case LOCATE_16:
     case LOCK_UNLOCK_CACHE:
     case SET_CD_SPEED:
     case SET_LIMITS:
     case WRITE_LONG_10:
     case UPDATE_BLOCK:
     case RESERVE_TRACK:
     case SET_READ_AHEAD:
     case PRE_FETCH:
     case PRE_FETCH_16:
     case ALLOW_OVERWRITE:
         cmd->xfer = 0;
         break;
     case VERIFY_10:
     case VERIFY_12:
     case VERIFY_16:
         if ((buf[1] & 2) == 0) {
             cmd->xfer = 0;
         } else if ((buf[1] & 4) != 0) {
             cmd->xfer = 1;
         }
         cmd->xfer *= dev->blocksize;
         break;
     case MODE_SENSE:
         break;
     case WRITE_SAME_10:
     case WRITE_SAME_16:
         cmd->xfer = buf[1] & 1 ? 0 : dev->blocksize;
         break;
     case READ_CAPACITY_10:
         cmd->xfer = 8;
         break;
     case READ_BLOCK_LIMITS:
         cmd->xfer = 6;
         break;
     case SEND_VOLUME_TAG:
         /* GPCMD_SET_STREAMING from multimedia commands.  */
         if (dev->type == TYPE_ROM) {
             cmd->xfer = buf[10] | (buf[9] << 8);
         } else {
             cmd->xfer = buf[9] | (buf[8] << 8);
         }
         break;
     case WRITE_6:
         /* length 0 means 256 blocks */
         if (cmd->xfer == 0) {
             cmd->xfer = 256;
         }
-        /* fall through */
+        fallthrough;
     case WRITE_10:
     case WRITE_VERIFY_10:
     case WRITE_12:
     case WRITE_VERIFY_12:
     case WRITE_16:
     case WRITE_VERIFY_16:
         cmd->xfer *= dev->blocksize;
         break;
     case READ_6:
     case READ_REVERSE:
         /* length 0 means 256 blocks */
         if (cmd->xfer == 0) {
             cmd->xfer = 256;
         }
-        /* fall through */
+        fallthrough;
     case READ_10:
     case READ_12:
     case READ_16:
         cmd->xfer *= dev->blocksize;
         break;
     case FORMAT_UNIT:
         /* MMC mandates the parameter list to be 12-bytes long.  Parameters
          * for block devices are restricted to the header right now.  */
         if (dev->type == TYPE_ROM && (buf[1] & 16)) {
             cmd->xfer = 12;
         } else {
             cmd->xfer = (buf[1] & 16) == 0 ? 0 : (buf[1] & 32 ? 8 : 4);
         }
         break;
     case INQUIRY:
     case RECEIVE_DIAGNOSTIC:
     case SEND_DIAGNOSTIC:
         cmd->xfer = buf[4] | (buf[3] << 8);
         break;
     case READ_CD:
     case READ_BUFFER:
     case WRITE_BUFFER:
     case SEND_CUE_SHEET:
         cmd->xfer = buf[8] | (buf[7] << 8) | (buf[6] << 16);
         break;
     case PERSISTENT_RESERVE_OUT:
         cmd->xfer = ldl_be_p(&buf[5]) & 0xffffffffULL;
         break;
     case ERASE_12:
         if (dev->type == TYPE_ROM) {
             /* MMC command GET PERFORMANCE.  */
             cmd->xfer = scsi_get_performance_length(buf[9] | (buf[8] << 8),
                                                     buf[10], buf[1] & 0x1f);
         }
         break;
     case MECHANISM_STATUS:
     case READ_DVD_STRUCTURE:
     case SEND_DVD_STRUCTURE:
     case MAINTENANCE_OUT:
     case MAINTENANCE_IN:
         if (dev->type == TYPE_ROM) {
             /* GPCMD_REPORT_KEY and GPCMD_SEND_KEY from multi media commands */
             cmd->xfer = buf[9] | (buf[8] << 8);
         }
         break;
     case ATA_PASSTHROUGH_12:
         if (dev->type == TYPE_ROM) {
             /* BLANK command of MMC */
             cmd->xfer = 0;
         } else {
             cmd->xfer = ata_passthrough_12_xfer(dev, buf);
         }
         break;
     case ATA_PASSTHROUGH_16:
         cmd->xfer = ata_passthrough_16_xfer(dev, buf);
         break;
     }
     return 0;
 }
hw/scsi/scsi-disk.c +1 -1
index 6691f5edb8..6564ca638c 100644
@@ -2256,86 +2256,86 @@ illegal_lba:
 static int32_t scsi_disk_dma_command(SCSIRequest *req, uint8_t *buf)
 {
     SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev);
     SCSIDiskClass *sdc = (SCSIDiskClass *) object_get_class(OBJECT(s));
     uint32_t len;
     uint8_t command;
 
     command = buf[0];
 
     if (!blk_is_available(s->qdev.conf.blk)) {
         scsi_check_condition(r, SENSE_CODE(NO_MEDIUM));
         return 0;
     }
 
     len = scsi_data_cdb_xfer(r->req.cmd.buf);
     switch (command) {
     case READ_6:
     case READ_10:
     case READ_12:
     case READ_16:
         trace_scsi_disk_dma_command_READ(r->req.cmd.lba, len);
         /* Protection information is not supported.  For SCSI versions 2 and
          * older (as determined by snooping the guest's INQUIRY commands),
          * there is no RD/WR/VRPROTECT, so skip this check in these versions.
          */
         if (s->qdev.scsi_version > 2 && (r->req.cmd.buf[1] & 0xe0)) {
             goto illegal_request;
         }
         if (!check_lba_range(s, r->req.cmd.lba, len)) {
             goto illegal_lba;
         }
         r->sector = r->req.cmd.lba * (s->qdev.blocksize / BDRV_SECTOR_SIZE);
         r->sector_count = len * (s->qdev.blocksize / BDRV_SECTOR_SIZE);
         break;
     case WRITE_6:
     case WRITE_10:
     case WRITE_12:
     case WRITE_16:
     case WRITE_VERIFY_10:
     case WRITE_VERIFY_12:
     case WRITE_VERIFY_16:
         if (!blk_is_writable(s->qdev.conf.blk)) {
             scsi_check_condition(r, SENSE_CODE(WRITE_PROTECTED));
             return 0;
         }
         trace_scsi_disk_dma_command_WRITE(
                 (command & 0xe) == 0xe ? "And Verify " : "",
                 r->req.cmd.lba, len);
-        /* fall through */
+        fallthrough;
     case VERIFY_10:
     case VERIFY_12:
     case VERIFY_16:
         /* We get here only for BYTCHK == 0x01 and only for scsi-block.
          * As far as DMA is concerned, we can treat it the same as a write;
          * scsi_block_do_sgio will send VERIFY commands.
          */
         if (s->qdev.scsi_version > 2 && (r->req.cmd.buf[1] & 0xe0)) {
             goto illegal_request;
         }
         if (!check_lba_range(s, r->req.cmd.lba, len)) {
             goto illegal_lba;
         }
         r->sector = r->req.cmd.lba * (s->qdev.blocksize / BDRV_SECTOR_SIZE);
         r->sector_count = len * (s->qdev.blocksize / BDRV_SECTOR_SIZE);
         break;
     default:
         abort();
     illegal_request:
         scsi_check_condition(r, SENSE_CODE(INVALID_FIELD));
         return 0;
     illegal_lba:
         scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE));
         return 0;
     }
     r->need_fua_emulation = sdc->need_fua_emulation(&r->req.cmd);
     if (r->sector_count == 0) {
         scsi_req_complete(&r->req, GOOD);
     }
     assert(r->iov.iov_len == 0);
     if (r->req.cmd.mode == SCSI_XFER_TO_DEV) {
         return -r->sector_count * BDRV_SECTOR_SIZE;
     } else {
         return r->sector_count * BDRV_SECTOR_SIZE;
     }
 }
Signature · 1 line
2.39.2
#91 lore raw

RFC PATCH v2 77/78 tests/unit/test-char.c: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 tests/unit/test-char.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/unit/test-char.c +1 -1
index 649fdf64e1..6f5a2c4108 100644
@@ -56,25 +56,25 @@ static void fe_read(void *opaque, const uint8_t *buf, int size)
 static void fe_event(void *opaque, QEMUChrEvent event)
 {
     FeHandler *h = opaque;
     bool new_open_state;
 
     h->last_event = event;
     switch (event) {
     case CHR_EVENT_BREAK:
         break;
     case CHR_EVENT_OPENED:
     case CHR_EVENT_CLOSED:
         h->openclose_count++;
         new_open_state = (event == CHR_EVENT_OPENED);
         if (h->is_open == new_open_state) {
             h->openclose_mismatch = true;
         }
         h->is_open = new_open_state;
-        /* fallthrough */
+        fallthrough;
     default:
         quit = true;
         break;
     }
 }
 
 #ifdef _WIN32
Signature · 1 line
2.39.2
#30 lore raw

RFC PATCH v2 21/78 target/sparc: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In 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
index 78b03308ae..b233e40da5 100644
@@ -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
index 453498c670..13f0430c5d 100644
@@ -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
index f92ff80ac8..4f179473d7 100644
@@ -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
index 3a7c0ff943..0c54b63938 100644
@@ -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
#33 lore raw

RFC PATCH v2 24/78 target/alpha: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 target/alpha/helper.c    | 6 +++---
 target/alpha/translate.c | 4 +++-
 2 files changed, 6 insertions(+), 4 deletions(-)
target/alpha/helper.c +3 -3
index 970c869771..1afdc1beec 100644
@@ -436,45 +436,45 @@ void alpha_cpu_do_interrupt(CPUState *cs)
 bool alpha_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
 {
     AlphaCPU *cpu = ALPHA_CPU(cs);
     CPUAlphaState *env = &cpu->env;
     int idx = -1;
 
     /* We never take interrupts while in PALmode.  */
     if (env->flags & ENV_FLAG_PAL_MODE) {
         return false;
     }
 
     /* Fall through the switch, collecting the highest priority
        interrupt that isn't masked by the processor status IPL.  */
     /* ??? This hard-codes the OSF/1 interrupt levels.  */
     switch ((env->flags >> ENV_FLAG_PS_SHIFT) & PS_INT_MASK) {
     case 0 ... 3:
         if (interrupt_request & CPU_INTERRUPT_HARD) {
             idx = EXCP_DEV_INTERRUPT;
         }
-        /* FALLTHRU */
+        fallthrough;
     case 4:
         if (interrupt_request & CPU_INTERRUPT_TIMER) {
             idx = EXCP_CLK_INTERRUPT;
         }
-        /* FALLTHRU */
+        fallthrough;
     case 5:
         if (interrupt_request & CPU_INTERRUPT_SMP) {
             idx = EXCP_SMP_INTERRUPT;
         }
-        /* FALLTHRU */
+        fallthrough;
     case 6:
         if (interrupt_request & CPU_INTERRUPT_MCHK) {
             idx = EXCP_MCHK;
         }
     }
     if (idx >= 0) {
         cs->exception_index = idx;
         env->error_code = 0;
         alpha_cpu_do_interrupt(cs);
         return true;
     }
     return false;
 }
 
 #endif /* !CONFIG_USER_ONLY */
target/alpha/translate.c +3 -1
index 32333081d8..19e1d2ed86 100644
@@ -1377,1493 +1377,1493 @@ static DisasJumpType gen_mtpr(DisasContext *ctx, TCGv vb, int regno)
 static DisasJumpType translate_one(DisasContext *ctx, uint32_t insn)
 {
     int32_t disp21, disp16, disp12 __attribute__((unused));
     uint16_t fn11;
     uint8_t opc, ra, rb, rc, fpfn, fn7, lit;
     bool islit, real_islit;
     TCGv va, vb, vc, tmp, tmp2;
     TCGv_i32 t32;
     DisasJumpType ret;
 
     /* Decode all instruction fields */
     opc = extract32(insn, 26, 6);
     ra = extract32(insn, 21, 5);
     rb = extract32(insn, 16, 5);
     rc = extract32(insn, 0, 5);
     real_islit = islit = extract32(insn, 12, 1);
     lit = extract32(insn, 13, 8);
 
     disp21 = sextract32(insn, 0, 21);
     disp16 = sextract32(insn, 0, 16);
     disp12 = sextract32(insn, 0, 12);
 
     fn11 = extract32(insn, 5, 11);
     fpfn = extract32(insn, 5, 6);
     fn7 = extract32(insn, 5, 7);
 
     if (rb == 31 && !islit) {
         islit = true;
         lit = 0;
     }
 
     ret = DISAS_NEXT;
     switch (opc) {
     case 0x00:
         /* CALL_PAL */
         ret = gen_call_pal(ctx, insn & 0x03ffffff);
         break;
     case 0x01:
         /* OPC01 */
         goto invalid_opc;
     case 0x02:
         /* OPC02 */
         goto invalid_opc;
     case 0x03:
         /* OPC03 */
         goto invalid_opc;
     case 0x04:
         /* OPC04 */
         goto invalid_opc;
     case 0x05:
         /* OPC05 */
         goto invalid_opc;
     case 0x06:
         /* OPC06 */
         goto invalid_opc;
     case 0x07:
         /* OPC07 */
         goto invalid_opc;
 
     case 0x09:
         /* LDAH */
         disp16 = (uint32_t)disp16 << 16;
-        /* fall through */
+        fallthrough;
     case 0x08:
         /* LDA */
         va = dest_gpr(ctx, ra);
         /* It's worth special-casing immediate loads.  */
         if (rb == 31) {
             tcg_gen_movi_i64(va, disp16);
         } else {
             tcg_gen_addi_i64(va, load_gpr(ctx, rb), disp16);
         }
         break;
 
     case 0x0A:
         /* LDBU */
         REQUIRE_AMASK(BWX);
         gen_load_int(ctx, ra, rb, disp16, MO_UB, 0, 0);
         break;
     case 0x0B:
         /* LDQ_U */
         gen_load_int(ctx, ra, rb, disp16, MO_LEUQ, 1, 0);
         break;
     case 0x0C:
         /* LDWU */
         REQUIRE_AMASK(BWX);
         gen_load_int(ctx, ra, rb, disp16, MO_LEUW, 0, 0);
         break;
     case 0x0D:
         /* STW */
         REQUIRE_AMASK(BWX);
         gen_store_int(ctx, ra, rb, disp16, MO_LEUW, 0);
         break;
     case 0x0E:
         /* STB */
         REQUIRE_AMASK(BWX);
         gen_store_int(ctx, ra, rb, disp16, MO_UB, 0);
         break;
     case 0x0F:
         /* STQ_U */
         gen_store_int(ctx, ra, rb, disp16, MO_LEUQ, 1);
         break;
 
     case 0x10:
         vc = dest_gpr(ctx, rc);
         vb = load_gpr_lit(ctx, rb, lit, islit);
 
         if (ra == 31) {
             if (fn7 == 0x00) {
                 /* Special case ADDL as SEXTL.  */
                 tcg_gen_ext32s_i64(vc, vb);
                 break;
             }
             if (fn7 == 0x29) {
                 /* Special case SUBQ as NEGQ.  */
                 tcg_gen_neg_i64(vc, vb);
                 break;
             }
         }
 
         va = load_gpr(ctx, ra);
         switch (fn7) {
         case 0x00:
             /* ADDL */
             tcg_gen_add_i64(vc, va, vb);
             tcg_gen_ext32s_i64(vc, vc);
             break;
         case 0x02:
             /* S4ADDL */
             tmp = tcg_temp_new();
             tcg_gen_shli_i64(tmp, va, 2);
             tcg_gen_add_i64(tmp, tmp, vb);
             tcg_gen_ext32s_i64(vc, tmp);
             break;
         case 0x09:
             /* SUBL */
             tcg_gen_sub_i64(vc, va, vb);
             tcg_gen_ext32s_i64(vc, vc);
             break;
         case 0x0B:
             /* S4SUBL */
             tmp = tcg_temp_new();
             tcg_gen_shli_i64(tmp, va, 2);
             tcg_gen_sub_i64(tmp, tmp, vb);
             tcg_gen_ext32s_i64(vc, tmp);
             break;
         case 0x0F:
             /* CMPBGE */
             if (ra == 31) {
                 /* Special case 0 >= X as X == 0.  */
                 gen_helper_cmpbe0(vc, vb);
             } else {
                 gen_helper_cmpbge(vc, va, vb);
             }
             break;
         case 0x12:
             /* S8ADDL */
             tmp = tcg_temp_new();
             tcg_gen_shli_i64(tmp, va, 3);
             tcg_gen_add_i64(tmp, tmp, vb);
             tcg_gen_ext32s_i64(vc, tmp);
             break;
         case 0x1B:
             /* S8SUBL */
             tmp = tcg_temp_new();
             tcg_gen_shli_i64(tmp, va, 3);
             tcg_gen_sub_i64(tmp, tmp, vb);
             tcg_gen_ext32s_i64(vc, tmp);
             break;
         case 0x1D:
             /* CMPULT */
             tcg_gen_setcond_i64(TCG_COND_LTU, vc, va, vb);
             break;
         case 0x20:
             /* ADDQ */
             tcg_gen_add_i64(vc, va, vb);
             break;
         case 0x22:
             /* S4ADDQ */
             tmp = tcg_temp_new();
             tcg_gen_shli_i64(tmp, va, 2);
             tcg_gen_add_i64(vc, tmp, vb);
             break;
         case 0x29:
             /* SUBQ */
             tcg_gen_sub_i64(vc, va, vb);
             break;
         case 0x2B:
             /* S4SUBQ */
             tmp = tcg_temp_new();
             tcg_gen_shli_i64(tmp, va, 2);
             tcg_gen_sub_i64(vc, tmp, vb);
             break;
         case 0x2D:
             /* CMPEQ */
             tcg_gen_setcond_i64(TCG_COND_EQ, vc, va, vb);
             break;
         case 0x32:
             /* S8ADDQ */
             tmp = tcg_temp_new();
             tcg_gen_shli_i64(tmp, va, 3);
             tcg_gen_add_i64(vc, tmp, vb);
             break;
         case 0x3B:
             /* S8SUBQ */
             tmp = tcg_temp_new();
             tcg_gen_shli_i64(tmp, va, 3);
             tcg_gen_sub_i64(vc, tmp, vb);
             break;
         case 0x3D:
             /* CMPULE */
             tcg_gen_setcond_i64(TCG_COND_LEU, vc, va, vb);
             break;
         case 0x40:
             /* ADDL/V */
             tmp = tcg_temp_new();
             tcg_gen_ext32s_i64(tmp, va);
             tcg_gen_ext32s_i64(vc, vb);
             tcg_gen_add_i64(tmp, tmp, vc);
             tcg_gen_ext32s_i64(vc, tmp);
             gen_helper_check_overflow(tcg_env, vc, tmp);
             break;
         case 0x49:
             /* SUBL/V */
             tmp = tcg_temp_new();
             tcg_gen_ext32s_i64(tmp, va);
             tcg_gen_ext32s_i64(vc, vb);
             tcg_gen_sub_i64(tmp, tmp, vc);
             tcg_gen_ext32s_i64(vc, tmp);
             gen_helper_check_overflow(tcg_env, vc, tmp);
             break;
         case 0x4D:
             /* CMPLT */
             tcg_gen_setcond_i64(TCG_COND_LT, vc, va, vb);
             break;
         case 0x60:
             /* ADDQ/V */
             tmp = tcg_temp_new();
             tmp2 = tcg_temp_new();
             tcg_gen_eqv_i64(tmp, va, vb);
             tcg_gen_mov_i64(tmp2, va);
             tcg_gen_add_i64(vc, va, vb);
             tcg_gen_xor_i64(tmp2, tmp2, vc);
             tcg_gen_and_i64(tmp, tmp, tmp2);
             tcg_gen_shri_i64(tmp, tmp, 63);
             tcg_gen_movi_i64(tmp2, 0);
             gen_helper_check_overflow(tcg_env, tmp, tmp2);
             break;
         case 0x69:
             /* SUBQ/V */
             tmp = tcg_temp_new();
             tmp2 = tcg_temp_new();
             tcg_gen_xor_i64(tmp, va, vb);
             tcg_gen_mov_i64(tmp2, va);
             tcg_gen_sub_i64(vc, va, vb);
             tcg_gen_xor_i64(tmp2, tmp2, vc);
             tcg_gen_and_i64(tmp, tmp, tmp2);
             tcg_gen_shri_i64(tmp, tmp, 63);
             tcg_gen_movi_i64(tmp2, 0);
             gen_helper_check_overflow(tcg_env, tmp, tmp2);
             break;
         case 0x6D:
             /* CMPLE */
             tcg_gen_setcond_i64(TCG_COND_LE, vc, va, vb);
             break;
         default:
             goto invalid_opc;
         }
         break;
 
     case 0x11:
         if (fn7 == 0x20) {
             if (rc == 31) {
                 /* Special case BIS as NOP.  */
                 break;
             }
             if (ra == 31) {
                 /* Special case BIS as MOV.  */
                 vc = dest_gpr(ctx, rc);
                 if (islit) {
                     tcg_gen_movi_i64(vc, lit);
                 } else {
                     tcg_gen_mov_i64(vc, load_gpr(ctx, rb));
                 }
                 break;
             }
         }
 
         vc = dest_gpr(ctx, rc);
         vb = load_gpr_lit(ctx, rb, lit, islit);
 
         if (fn7 == 0x28 && ra == 31) {
             /* Special case ORNOT as NOT.  */
             tcg_gen_not_i64(vc, vb);
             break;
         }
 
         va = load_gpr(ctx, ra);
         switch (fn7) {
         case 0x00:
             /* AND */
             tcg_gen_and_i64(vc, va, vb);
             break;
         case 0x08:
             /* BIC */
             tcg_gen_andc_i64(vc, va, vb);
             break;
         case 0x14:
             /* CMOVLBS */
             tmp = tcg_temp_new();
             tcg_gen_andi_i64(tmp, va, 1);
             tcg_gen_movcond_i64(TCG_COND_NE, vc, tmp, load_zero(ctx),
                                 vb, load_gpr(ctx, rc));
             break;
         case 0x16:
             /* CMOVLBC */
             tmp = tcg_temp_new();
             tcg_gen_andi_i64(tmp, va, 1);
             tcg_gen_movcond_i64(TCG_COND_EQ, vc, tmp, load_zero(ctx),
                                 vb, load_gpr(ctx, rc));
             break;
         case 0x20:
             /* BIS */
             tcg_gen_or_i64(vc, va, vb);
             break;
         case 0x24:
             /* CMOVEQ */
             tcg_gen_movcond_i64(TCG_COND_EQ, vc, va, load_zero(ctx),
                                 vb, load_gpr(ctx, rc));
             break;
         case 0x26:
             /* CMOVNE */
             tcg_gen_movcond_i64(TCG_COND_NE, vc, va, load_zero(ctx),
                                 vb, load_gpr(ctx, rc));
             break;
         case 0x28:
             /* ORNOT */
             tcg_gen_orc_i64(vc, va, vb);
             break;
         case 0x40:
             /* XOR */
             tcg_gen_xor_i64(vc, va, vb);
             break;
         case 0x44:
             /* CMOVLT */
             tcg_gen_movcond_i64(TCG_COND_LT, vc, va, load_zero(ctx),
                                 vb, load_gpr(ctx, rc));
             break;
         case 0x46:
             /* CMOVGE */
             tcg_gen_movcond_i64(TCG_COND_GE, vc, va, load_zero(ctx),
                                 vb, load_gpr(ctx, rc));
             break;
         case 0x48:
             /* EQV */
             tcg_gen_eqv_i64(vc, va, vb);
             break;
         case 0x61:
             /* AMASK */
             REQUIRE_REG_31(ra);
             tcg_gen_andi_i64(vc, vb, ~ctx->amask);
             break;
         case 0x64:
             /* CMOVLE */
             tcg_gen_movcond_i64(TCG_COND_LE, vc, va, load_zero(ctx),
                                 vb, load_gpr(ctx, rc));
             break;
         case 0x66:
             /* CMOVGT */
             tcg_gen_movcond_i64(TCG_COND_GT, vc, va, load_zero(ctx),
                                 vb, load_gpr(ctx, rc));
             break;
         case 0x6C:
             /* IMPLVER */
             REQUIRE_REG_31(ra);
             tcg_gen_movi_i64(vc, ctx->implver);
             break;
         default:
             goto invalid_opc;
         }
         break;
 
     case 0x12:
         vc = dest_gpr(ctx, rc);
         va = load_gpr(ctx, ra);
         switch (fn7) {
         case 0x02:
             /* MSKBL */
             gen_msk_l(ctx, vc, va, rb, islit, lit, 0x01);
             break;
         case 0x06:
             /* EXTBL */
             gen_ext_l(ctx, vc, va, rb, islit, lit, 0x01);
             break;
         case 0x0B:
             /* INSBL */
             gen_ins_l(ctx, vc, va, rb, islit, lit, 0x01);
             break;
         case 0x12:
             /* MSKWL */
             gen_msk_l(ctx, vc, va, rb, islit, lit, 0x03);
             break;
         case 0x16:
             /* EXTWL */
             gen_ext_l(ctx, vc, va, rb, islit, lit, 0x03);
             break;
         case 0x1B:
             /* INSWL */
             gen_ins_l(ctx, vc, va, rb, islit, lit, 0x03);
             break;
         case 0x22:
             /* MSKLL */
             gen_msk_l(ctx, vc, va, rb, islit, lit, 0x0f);
             break;
         case 0x26:
             /* EXTLL */
             gen_ext_l(ctx, vc, va, rb, islit, lit, 0x0f);
             break;
         case 0x2B:
             /* INSLL */
             gen_ins_l(ctx, vc, va, rb, islit, lit, 0x0f);
             break;
         case 0x30:
             /* ZAP */
             if (islit) {
                 gen_zapnoti(vc, va, ~lit);
             } else {
                 gen_helper_zap(vc, va, load_gpr(ctx, rb));
             }
             break;
         case 0x31:
             /* ZAPNOT */
             if (islit) {
                 gen_zapnoti(vc, va, lit);
             } else {
                 gen_helper_zapnot(vc, va, load_gpr(ctx, rb));
             }
             break;
         case 0x32:
             /* MSKQL */
             gen_msk_l(ctx, vc, va, rb, islit, lit, 0xff);
             break;
         case 0x34:
             /* SRL */
             if (islit) {
                 tcg_gen_shri_i64(vc, va, lit & 0x3f);
             } else {
                 tmp = tcg_temp_new();
                 vb = load_gpr(ctx, rb);
                 tcg_gen_andi_i64(tmp, vb, 0x3f);
                 tcg_gen_shr_i64(vc, va, tmp);
             }
             break;
         case 0x36:
             /* EXTQL */
             gen_ext_l(ctx, vc, va, rb, islit, lit, 0xff);
             break;
         case 0x39:
             /* SLL */
             if (islit) {
                 tcg_gen_shli_i64(vc, va, lit & 0x3f);
             } else {
                 tmp = tcg_temp_new();
                 vb = load_gpr(ctx, rb);
                 tcg_gen_andi_i64(tmp, vb, 0x3f);
                 tcg_gen_shl_i64(vc, va, tmp);
             }
             break;
         case 0x3B:
             /* INSQL */
             gen_ins_l(ctx, vc, va, rb, islit, lit, 0xff);
             break;
         case 0x3C:
             /* SRA */
             if (islit) {
                 tcg_gen_sari_i64(vc, va, lit & 0x3f);
             } else {
                 tmp = tcg_temp_new();
                 vb = load_gpr(ctx, rb);
                 tcg_gen_andi_i64(tmp, vb, 0x3f);
                 tcg_gen_sar_i64(vc, va, tmp);
             }
             break;
         case 0x52:
             /* MSKWH */
             gen_msk_h(ctx, vc, va, rb, islit, lit, 0x03);
             break;
         case 0x57:
             /* INSWH */
             gen_ins_h(ctx, vc, va, rb, islit, lit, 0x03);
             break;
         case 0x5A:
             /* EXTWH */
             gen_ext_h(ctx, vc, va, rb, islit, lit, 0x03);
             break;
         case 0x62:
             /* MSKLH */
             gen_msk_h(ctx, vc, va, rb, islit, lit, 0x0f);
             break;
         case 0x67:
             /* INSLH */
             gen_ins_h(ctx, vc, va, rb, islit, lit, 0x0f);
             break;
         case 0x6A:
             /* EXTLH */
             gen_ext_h(ctx, vc, va, rb, islit, lit, 0x0f);
             break;
         case 0x72:
             /* MSKQH */
             gen_msk_h(ctx, vc, va, rb, islit, lit, 0xff);
             break;
         case 0x77:
             /* INSQH */
             gen_ins_h(ctx, vc, va, rb, islit, lit, 0xff);
             break;
         case 0x7A:
             /* EXTQH */
             gen_ext_h(ctx, vc, va, rb, islit, lit, 0xff);
             break;
         default:
             goto invalid_opc;
         }
         break;
 
     case 0x13:
         vc = dest_gpr(ctx, rc);
         vb = load_gpr_lit(ctx, rb, lit, islit);
         va = load_gpr(ctx, ra);
         switch (fn7) {
         case 0x00:
             /* MULL */
             tcg_gen_mul_i64(vc, va, vb);
             tcg_gen_ext32s_i64(vc, vc);
             break;
         case 0x20:
             /* MULQ */
             tcg_gen_mul_i64(vc, va, vb);
             break;
         case 0x30:
             /* UMULH */
             tmp = tcg_temp_new();
             tcg_gen_mulu2_i64(tmp, vc, va, vb);
             break;
         case 0x40:
             /* MULL/V */
             tmp = tcg_temp_new();
             tcg_gen_ext32s_i64(tmp, va);
             tcg_gen_ext32s_i64(vc, vb);
             tcg_gen_mul_i64(tmp, tmp, vc);
             tcg_gen_ext32s_i64(vc, tmp);
             gen_helper_check_overflow(tcg_env, vc, tmp);
             break;
         case 0x60:
             /* MULQ/V */
             tmp = tcg_temp_new();
             tmp2 = tcg_temp_new();
             tcg_gen_muls2_i64(vc, tmp, va, vb);
             tcg_gen_sari_i64(tmp2, vc, 63);
             gen_helper_check_overflow(tcg_env, tmp, tmp2);
             break;
         default:
             goto invalid_opc;
         }
         break;
 
     case 0x14:
         REQUIRE_AMASK(FIX);
         vc = dest_fpr(ctx, rc);
         switch (fpfn) { /* fn11 & 0x3F */
         case 0x04:
             /* ITOFS */
             REQUIRE_REG_31(rb);
             REQUIRE_FEN;
             t32 = tcg_temp_new_i32();
             va = load_gpr(ctx, ra);
             tcg_gen_extrl_i64_i32(t32, va);
             gen_helper_memory_to_s(vc, t32);
             break;
         case 0x0A:
             /* SQRTF */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             vb = load_fpr(ctx, rb);
             gen_helper_sqrtf(vc, tcg_env, vb);
             break;
         case 0x0B:
             /* SQRTS */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             gen_sqrts(ctx, rb, rc, fn11);
             break;
         case 0x14:
             /* ITOFF */
             REQUIRE_REG_31(rb);
             REQUIRE_FEN;
             t32 = tcg_temp_new_i32();
             va = load_gpr(ctx, ra);
             tcg_gen_extrl_i64_i32(t32, va);
             gen_helper_memory_to_f(vc, t32);
             break;
         case 0x24:
             /* ITOFT */
             REQUIRE_REG_31(rb);
             REQUIRE_FEN;
             va = load_gpr(ctx, ra);
             tcg_gen_mov_i64(vc, va);
             break;
         case 0x2A:
             /* SQRTG */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             vb = load_fpr(ctx, rb);
             gen_helper_sqrtg(vc, tcg_env, vb);
             break;
         case 0x02B:
             /* SQRTT */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             gen_sqrtt(ctx, rb, rc, fn11);
             break;
         default:
             goto invalid_opc;
         }
         break;
 
     case 0x15:
         /* VAX floating point */
         /* XXX: rounding mode and trap are ignored (!) */
         vc = dest_fpr(ctx, rc);
         vb = load_fpr(ctx, rb);
         va = load_fpr(ctx, ra);
         switch (fpfn) { /* fn11 & 0x3F */
         case 0x00:
             /* ADDF */
             REQUIRE_FEN;
             gen_helper_addf(vc, tcg_env, va, vb);
             break;
         case 0x01:
             /* SUBF */
             REQUIRE_FEN;
             gen_helper_subf(vc, tcg_env, va, vb);
             break;
         case 0x02:
             /* MULF */
             REQUIRE_FEN;
             gen_helper_mulf(vc, tcg_env, va, vb);
             break;
         case 0x03:
             /* DIVF */
             REQUIRE_FEN;
             gen_helper_divf(vc, tcg_env, va, vb);
             break;
         case 0x1E:
             /* CVTDG -- TODO */
             REQUIRE_REG_31(ra);
             goto invalid_opc;
         case 0x20:
             /* ADDG */
             REQUIRE_FEN;
             gen_helper_addg(vc, tcg_env, va, vb);
             break;
         case 0x21:
             /* SUBG */
             REQUIRE_FEN;
             gen_helper_subg(vc, tcg_env, va, vb);
             break;
         case 0x22:
             /* MULG */
             REQUIRE_FEN;
             gen_helper_mulg(vc, tcg_env, va, vb);
             break;
         case 0x23:
             /* DIVG */
             REQUIRE_FEN;
             gen_helper_divg(vc, tcg_env, va, vb);
             break;
         case 0x25:
             /* CMPGEQ */
             REQUIRE_FEN;
             gen_helper_cmpgeq(vc, tcg_env, va, vb);
             break;
         case 0x26:
             /* CMPGLT */
             REQUIRE_FEN;
             gen_helper_cmpglt(vc, tcg_env, va, vb);
             break;
         case 0x27:
             /* CMPGLE */
             REQUIRE_FEN;
             gen_helper_cmpgle(vc, tcg_env, va, vb);
             break;
         case 0x2C:
             /* CVTGF */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             gen_helper_cvtgf(vc, tcg_env, vb);
             break;
         case 0x2D:
             /* CVTGD -- TODO */
             REQUIRE_REG_31(ra);
             goto invalid_opc;
         case 0x2F:
             /* CVTGQ */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             gen_helper_cvtgq(vc, tcg_env, vb);
             break;
         case 0x3C:
             /* CVTQF */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             gen_helper_cvtqf(vc, tcg_env, vb);
             break;
         case 0x3E:
             /* CVTQG */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             gen_helper_cvtqg(vc, tcg_env, vb);
             break;
         default:
             goto invalid_opc;
         }
         break;
 
     case 0x16:
         /* IEEE floating-point */
         switch (fpfn) { /* fn11 & 0x3F */
         case 0x00:
             /* ADDS */
             REQUIRE_FEN;
             gen_adds(ctx, ra, rb, rc, fn11);
             break;
         case 0x01:
             /* SUBS */
             REQUIRE_FEN;
             gen_subs(ctx, ra, rb, rc, fn11);
             break;
         case 0x02:
             /* MULS */
             REQUIRE_FEN;
             gen_muls(ctx, ra, rb, rc, fn11);
             break;
         case 0x03:
             /* DIVS */
             REQUIRE_FEN;
             gen_divs(ctx, ra, rb, rc, fn11);
             break;
         case 0x20:
             /* ADDT */
             REQUIRE_FEN;
             gen_addt(ctx, ra, rb, rc, fn11);
             break;
         case 0x21:
             /* SUBT */
             REQUIRE_FEN;
             gen_subt(ctx, ra, rb, rc, fn11);
             break;
         case 0x22:
             /* MULT */
             REQUIRE_FEN;
             gen_mult(ctx, ra, rb, rc, fn11);
             break;
         case 0x23:
             /* DIVT */
             REQUIRE_FEN;
             gen_divt(ctx, ra, rb, rc, fn11);
             break;
         case 0x24:
             /* CMPTUN */
             REQUIRE_FEN;
             gen_cmptun(ctx, ra, rb, rc, fn11);
             break;
         case 0x25:
             /* CMPTEQ */
             REQUIRE_FEN;
             gen_cmpteq(ctx, ra, rb, rc, fn11);
             break;
         case 0x26:
             /* CMPTLT */
             REQUIRE_FEN;
             gen_cmptlt(ctx, ra, rb, rc, fn11);
             break;
         case 0x27:
             /* CMPTLE */
             REQUIRE_FEN;
             gen_cmptle(ctx, ra, rb, rc, fn11);
             break;
         case 0x2C:
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             if (fn11 == 0x2AC || fn11 == 0x6AC) {
                 /* CVTST */
                 gen_cvtst(ctx, rb, rc, fn11);
             } else {
                 /* CVTTS */
                 gen_cvtts(ctx, rb, rc, fn11);
             }
             break;
         case 0x2F:
             /* CVTTQ */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             gen_cvttq(ctx, rb, rc, fn11);
             break;
         case 0x3C:
             /* CVTQS */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             gen_cvtqs(ctx, rb, rc, fn11);
             break;
         case 0x3E:
             /* CVTQT */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             gen_cvtqt(ctx, rb, rc, fn11);
             break;
         default:
             goto invalid_opc;
         }
         break;
 
     case 0x17:
         switch (fn11) {
         case 0x010:
             /* CVTLQ */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             vc = dest_fpr(ctx, rc);
             vb = load_fpr(ctx, rb);
             gen_cvtlq(vc, vb);
             break;
         case 0x020:
             /* CPYS */
             REQUIRE_FEN;
             if (rc == 31) {
                 /* Special case CPYS as FNOP.  */
             } else {
                 vc = dest_fpr(ctx, rc);
                 va = load_fpr(ctx, ra);
                 if (ra == rb) {
                     /* Special case CPYS as FMOV.  */
                     tcg_gen_mov_i64(vc, va);
                 } else {
                     vb = load_fpr(ctx, rb);
                     gen_cpy_mask(vc, va, vb, 0, 0x8000000000000000ULL);
                 }
             }
             break;
         case 0x021:
             /* CPYSN */
             REQUIRE_FEN;
             vc = dest_fpr(ctx, rc);
             vb = load_fpr(ctx, rb);
             va = load_fpr(ctx, ra);
             gen_cpy_mask(vc, va, vb, 1, 0x8000000000000000ULL);
             break;
         case 0x022:
             /* CPYSE */
             REQUIRE_FEN;
             vc = dest_fpr(ctx, rc);
             vb = load_fpr(ctx, rb);
             va = load_fpr(ctx, ra);
             gen_cpy_mask(vc, va, vb, 0, 0xFFF0000000000000ULL);
             break;
         case 0x024:
             /* MT_FPCR */
             REQUIRE_FEN;
             va = load_fpr(ctx, ra);
             gen_helper_store_fpcr(tcg_env, va);
             if (ctx->tb_rm == QUAL_RM_D) {
                 /* Re-do the copy of the rounding mode to fp_status
                    the next time we use dynamic rounding.  */
                 ctx->tb_rm = -1;
             }
             break;
         case 0x025:
             /* MF_FPCR */
             REQUIRE_FEN;
             va = dest_fpr(ctx, ra);
             gen_helper_load_fpcr(va, tcg_env);
             break;
         case 0x02A:
             /* FCMOVEQ */
             REQUIRE_FEN;
             gen_fcmov(ctx, TCG_COND_EQ, ra, rb, rc);
             break;
         case 0x02B:
             /* FCMOVNE */
             REQUIRE_FEN;
             gen_fcmov(ctx, TCG_COND_NE, ra, rb, rc);
             break;
         case 0x02C:
             /* FCMOVLT */
             REQUIRE_FEN;
             gen_fcmov(ctx, TCG_COND_LT, ra, rb, rc);
             break;
         case 0x02D:
             /* FCMOVGE */
             REQUIRE_FEN;
             gen_fcmov(ctx, TCG_COND_GE, ra, rb, rc);
             break;
         case 0x02E:
             /* FCMOVLE */
             REQUIRE_FEN;
             gen_fcmov(ctx, TCG_COND_LE, ra, rb, rc);
             break;
         case 0x02F:
             /* FCMOVGT */
             REQUIRE_FEN;
             gen_fcmov(ctx, TCG_COND_GT, ra, rb, rc);
             break;
         case 0x030: /* CVTQL */
         case 0x130: /* CVTQL/V */
         case 0x530: /* CVTQL/SV */
             REQUIRE_REG_31(ra);
             REQUIRE_FEN;
             vc = dest_fpr(ctx, rc);
             vb = load_fpr(ctx, rb);
             gen_helper_cvtql(vc, tcg_env, vb);
             gen_fp_exc_raise(rc, fn11);
             break;
         default:
             goto invalid_opc;
         }
         break;
 
     case 0x18:
         switch ((uint16_t)disp16) {
         case 0x0000:
             /* TRAPB */
             /* No-op.  */
             break;
         case 0x0400:
             /* EXCB */
             /* No-op.  */
             break;
         case 0x4000:
             /* MB */
             tcg_gen_mb(TCG_MO_ALL | TCG_BAR_SC);
             break;
         case 0x4400:
             /* WMB */
             tcg_gen_mb(TCG_MO_ST_ST | TCG_BAR_SC);
             break;
         case 0x8000:
             /* FETCH */
             /* No-op */
             break;
         case 0xA000:
             /* FETCH_M */
             /* No-op */
             break;
         case 0xC000:
             /* RPCC */
             va = dest_gpr(ctx, ra);
             if (translator_io_start(&ctx->base)) {
                 ret = DISAS_PC_STALE;
             }
             gen_helper_load_pcc(va, tcg_env);
             break;
         case 0xE000:
             /* RC */
             gen_rx(ctx, ra, 0);
             break;
         case 0xE800:
             /* ECB */
             break;
         case 0xF000:
             /* RS */
             gen_rx(ctx, ra, 1);
             break;
         case 0xF800:
             /* WH64 */
             /* No-op */
             break;
         case 0xFC00:
             /* WH64EN */
             /* No-op */
             break;
         default:
             goto invalid_opc;
         }
         break;
 
     case 0x19:
         /* HW_MFPR (PALcode) */
 #ifndef CONFIG_USER_ONLY
         REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
         va = dest_gpr(ctx, ra);
         ret = gen_mfpr(ctx, va, insn & 0xffff);
         break;
 #else
         goto invalid_opc;
 #endif
 
     case 0x1A:
         /* JMP, JSR, RET, JSR_COROUTINE.  These only differ by the branch
            prediction stack action, which of course we don't implement.  */
         vb = load_gpr(ctx, rb);
         tcg_gen_andi_i64(cpu_pc, vb, ~3);
         if (ra != 31) {
             tcg_gen_movi_i64(ctx->ir[ra], ctx->base.pc_next);
         }
         ret = DISAS_PC_UPDATED;
         break;
 
     case 0x1B:
         /* HW_LD (PALcode) */
 #ifndef CONFIG_USER_ONLY
         REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
         {
             TCGv addr = tcg_temp_new();
             vb = load_gpr(ctx, rb);
             va = dest_gpr(ctx, ra);
 
             tcg_gen_addi_i64(addr, vb, disp12);
             switch ((insn >> 12) & 0xF) {
             case 0x0:
                 /* Longword physical access (hw_ldl/p) */
                 tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LESL | MO_ALIGN);
                 break;
             case 0x1:
                 /* Quadword physical access (hw_ldq/p) */
                 tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LEUQ | MO_ALIGN);
                 break;
             case 0x2:
                 /* Longword physical access with lock (hw_ldl_l/p) */
                 tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LESL | MO_ALIGN);
                 tcg_gen_mov_i64(cpu_lock_addr, addr);
                 tcg_gen_mov_i64(cpu_lock_value, va);
                 break;
             case 0x3:
                 /* Quadword physical access with lock (hw_ldq_l/p) */
                 tcg_gen_qemu_ld_i64(va, addr, MMU_PHYS_IDX, MO_LEUQ | MO_ALIGN);
                 tcg_gen_mov_i64(cpu_lock_addr, addr);
                 tcg_gen_mov_i64(cpu_lock_value, va);
                 break;
             case 0x4:
                 /* Longword virtual PTE fetch (hw_ldl/v) */
                 goto invalid_opc;
             case 0x5:
                 /* Quadword virtual PTE fetch (hw_ldq/v) */
                 goto invalid_opc;
                 break;
             case 0x6:
                 /* Invalid */
                 goto invalid_opc;
             case 0x7:
                 /* Invaliid */
                 goto invalid_opc;
             case 0x8:
                 /* Longword virtual access (hw_ldl) */
                 goto invalid_opc;
             case 0x9:
                 /* Quadword virtual access (hw_ldq) */
                 goto invalid_opc;
             case 0xA:
                 /* Longword virtual access with protection check (hw_ldl/w) */
                 tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX,
                                     MO_LESL | MO_ALIGN);
                 break;
             case 0xB:
                 /* Quadword virtual access with protection check (hw_ldq/w) */
                 tcg_gen_qemu_ld_i64(va, addr, MMU_KERNEL_IDX,
                                     MO_LEUQ | MO_ALIGN);
                 break;
             case 0xC:
                 /* Longword virtual access with alt access mode (hw_ldl/a)*/
                 goto invalid_opc;
             case 0xD:
                 /* Quadword virtual access with alt access mode (hw_ldq/a) */
                 goto invalid_opc;
             case 0xE:
                 /* Longword virtual access with alternate access mode and
                    protection checks (hw_ldl/wa) */
                 tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX,
                                     MO_LESL | MO_ALIGN);
                 break;
             case 0xF:
                 /* Quadword virtual access with alternate access mode and
                    protection checks (hw_ldq/wa) */
                 tcg_gen_qemu_ld_i64(va, addr, MMU_USER_IDX,
                                     MO_LEUQ | MO_ALIGN);
                 break;
             }
             break;
         }
 #else
         goto invalid_opc;
 #endif
 
     case 0x1C:
         vc = dest_gpr(ctx, rc);
         if (fn7 == 0x70) {
             /* FTOIT */
             REQUIRE_AMASK(FIX);
             REQUIRE_REG_31(rb);
             va = load_fpr(ctx, ra);
             tcg_gen_mov_i64(vc, va);
             break;
         } else if (fn7 == 0x78) {
             /* FTOIS */
             REQUIRE_AMASK(FIX);
             REQUIRE_REG_31(rb);
             t32 = tcg_temp_new_i32();
             va = load_fpr(ctx, ra);
             gen_helper_s_to_memory(t32, va);
             tcg_gen_ext_i32_i64(vc, t32);
             break;
         }
 
         vb = load_gpr_lit(ctx, rb, lit, islit);
         switch (fn7) {
         case 0x00:
             /* SEXTB */
             REQUIRE_AMASK(BWX);
             REQUIRE_REG_31(ra);
             tcg_gen_ext8s_i64(vc, vb);
             break;
         case 0x01:
             /* SEXTW */
             REQUIRE_AMASK(BWX);
             REQUIRE_REG_31(ra);
             tcg_gen_ext16s_i64(vc, vb);
             break;
         case 0x30:
             /* CTPOP */
             REQUIRE_AMASK(CIX);
             REQUIRE_REG_31(ra);
             REQUIRE_NO_LIT;
             tcg_gen_ctpop_i64(vc, vb);
             break;
         case 0x31:
             /* PERR */
             REQUIRE_AMASK(MVI);
             REQUIRE_NO_LIT;
             va = load_gpr(ctx, ra);
             gen_helper_perr(vc, va, vb);
             break;
         case 0x32:
             /* CTLZ */
             REQUIRE_AMASK(CIX);
             REQUIRE_REG_31(ra);
             REQUIRE_NO_LIT;
             tcg_gen_clzi_i64(vc, vb, 64);
             break;
         case 0x33:
             /* CTTZ */
             REQUIRE_AMASK(CIX);
             REQUIRE_REG_31(ra);
             REQUIRE_NO_LIT;
             tcg_gen_ctzi_i64(vc, vb, 64);
             break;
         case 0x34:
             /* UNPKBW */
             REQUIRE_AMASK(MVI);
             REQUIRE_REG_31(ra);
             REQUIRE_NO_LIT;
             gen_helper_unpkbw(vc, vb);
             break;
         case 0x35:
             /* UNPKBL */
             REQUIRE_AMASK(MVI);
             REQUIRE_REG_31(ra);
             REQUIRE_NO_LIT;
             gen_helper_unpkbl(vc, vb);
             break;
         case 0x36:
             /* PKWB */
             REQUIRE_AMASK(MVI);
             REQUIRE_REG_31(ra);
             REQUIRE_NO_LIT;
             gen_helper_pkwb(vc, vb);
             break;
         case 0x37:
             /* PKLB */
             REQUIRE_AMASK(MVI);
             REQUIRE_REG_31(ra);
             REQUIRE_NO_LIT;
             gen_helper_pklb(vc, vb);
             break;
         case 0x38:
             /* MINSB8 */
             REQUIRE_AMASK(MVI);
             va = load_gpr(ctx, ra);
             gen_helper_minsb8(vc, va, vb);
             break;
         case 0x39:
             /* MINSW4 */
             REQUIRE_AMASK(MVI);
             va = load_gpr(ctx, ra);
             gen_helper_minsw4(vc, va, vb);
             break;
         case 0x3A:
             /* MINUB8 */
             REQUIRE_AMASK(MVI);
             va = load_gpr(ctx, ra);
             gen_helper_minub8(vc, va, vb);
             break;
         case 0x3B:
             /* MINUW4 */
             REQUIRE_AMASK(MVI);
             va = load_gpr(ctx, ra);
             gen_helper_minuw4(vc, va, vb);
             break;
         case 0x3C:
             /* MAXUB8 */
             REQUIRE_AMASK(MVI);
             va = load_gpr(ctx, ra);
             gen_helper_maxub8(vc, va, vb);
             break;
         case 0x3D:
             /* MAXUW4 */
             REQUIRE_AMASK(MVI);
             va = load_gpr(ctx, ra);
             gen_helper_maxuw4(vc, va, vb);
             break;
         case 0x3E:
             /* MAXSB8 */
             REQUIRE_AMASK(MVI);
             va = load_gpr(ctx, ra);
             gen_helper_maxsb8(vc, va, vb);
             break;
         case 0x3F:
             /* MAXSW4 */
             REQUIRE_AMASK(MVI);
             va = load_gpr(ctx, ra);
             gen_helper_maxsw4(vc, va, vb);
             break;
         default:
             goto invalid_opc;
         }
         break;
 
     case 0x1D:
         /* HW_MTPR (PALcode) */
 #ifndef CONFIG_USER_ONLY
         REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
         vb = load_gpr(ctx, rb);
         ret = gen_mtpr(ctx, vb, insn & 0xffff);
         break;
 #else
         goto invalid_opc;
 #endif
 
     case 0x1E:
         /* HW_RET (PALcode) */
 #ifndef CONFIG_USER_ONLY
         REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
         if (rb == 31) {
             /* Pre-EV6 CPUs interpreted this as HW_REI, loading the return
                address from EXC_ADDR.  This turns out to be useful for our
                emulation PALcode, so continue to accept it.  */
             vb = dest_sink(ctx);
             tcg_gen_ld_i64(vb, tcg_env, offsetof(CPUAlphaState, exc_addr));
         } else {
             vb = load_gpr(ctx, rb);
         }
         tcg_gen_movi_i64(cpu_lock_addr, -1);
         st_flag_byte(load_zero(ctx), ENV_FLAG_RX_SHIFT);
         tmp = tcg_temp_new();
         tcg_gen_andi_i64(tmp, vb, 1);
         st_flag_byte(tmp, ENV_FLAG_PAL_SHIFT);
         tcg_gen_andi_i64(cpu_pc, vb, ~3);
         /* Allow interrupts to be recognized right away.  */
         ret = DISAS_PC_UPDATED_NOCHAIN;
         break;
 #else
         goto invalid_opc;
 #endif
 
     case 0x1F:
         /* HW_ST (PALcode) */
 #ifndef CONFIG_USER_ONLY
         REQUIRE_TB_FLAG(ENV_FLAG_PAL_MODE);
         {
             switch ((insn >> 12) & 0xF) {
             case 0x0:
                 /* Longword physical access */
                 va = load_gpr(ctx, ra);
                 vb = load_gpr(ctx, rb);
                 tmp = tcg_temp_new();
                 tcg_gen_addi_i64(tmp, vb, disp12);
                 tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LESL | MO_ALIGN);
                 break;
             case 0x1:
                 /* Quadword physical access */
                 va = load_gpr(ctx, ra);
                 vb = load_gpr(ctx, rb);
                 tmp = tcg_temp_new();
                 tcg_gen_addi_i64(tmp, vb, disp12);
                 tcg_gen_qemu_st_i64(va, tmp, MMU_PHYS_IDX, MO_LEUQ | MO_ALIGN);
                 break;
             case 0x2:
                 /* Longword physical access with lock */
                 ret = gen_store_conditional(ctx, ra, rb, disp12,
                                             MMU_PHYS_IDX, MO_LESL | MO_ALIGN);
                 break;
             case 0x3:
                 /* Quadword physical access with lock */
                 ret = gen_store_conditional(ctx, ra, rb, disp12,
                                             MMU_PHYS_IDX, MO_LEUQ | MO_ALIGN);
                 break;
             case 0x4:
                 /* Longword virtual access */
                 goto invalid_opc;
             case 0x5:
                 /* Quadword virtual access */
                 goto invalid_opc;
             case 0x6:
                 /* Invalid */
                 goto invalid_opc;
             case 0x7:
                 /* Invalid */
                 goto invalid_opc;
             case 0x8:
                 /* Invalid */
                 goto invalid_opc;
             case 0x9:
                 /* Invalid */
                 goto invalid_opc;
             case 0xA:
                 /* Invalid */
                 goto invalid_opc;
             case 0xB:
                 /* Invalid */
                 goto invalid_opc;
             case 0xC:
                 /* Longword virtual access with alternate access mode */
                 goto invalid_opc;
             case 0xD:
                 /* Quadword virtual access with alternate access mode */
                 goto invalid_opc;
             case 0xE:
                 /* Invalid */
                 goto invalid_opc;
             case 0xF:
                 /* Invalid */
                 goto invalid_opc;
             }
             break;
         }
 #else
         goto invalid_opc;
 #endif
     case 0x20:
         /* LDF */
         REQUIRE_FEN;
         gen_load_fp(ctx, ra, rb, disp16, gen_ldf);
         break;
     case 0x21:
         /* LDG */
         REQUIRE_FEN;
         gen_load_fp(ctx, ra, rb, disp16, gen_ldg);
         break;
     case 0x22:
         /* LDS */
         REQUIRE_FEN;
         gen_load_fp(ctx, ra, rb, disp16, gen_lds);
         break;
     case 0x23:
         /* LDT */
         REQUIRE_FEN;
         gen_load_fp(ctx, ra, rb, disp16, gen_ldt);
         break;
     case 0x24:
         /* STF */
         REQUIRE_FEN;
         gen_store_fp(ctx, ra, rb, disp16, gen_stf);
         break;
     case 0x25:
         /* STG */
         REQUIRE_FEN;
         gen_store_fp(ctx, ra, rb, disp16, gen_stg);
         break;
     case 0x26:
         /* STS */
         REQUIRE_FEN;
         gen_store_fp(ctx, ra, rb, disp16, gen_sts);
         break;
     case 0x27:
         /* STT */
         REQUIRE_FEN;
         gen_store_fp(ctx, ra, rb, disp16, gen_stt);
         break;
     case 0x28:
         /* LDL */
         gen_load_int(ctx, ra, rb, disp16, MO_LESL, 0, 0);
         break;
     case 0x29:
         /* LDQ */
         gen_load_int(ctx, ra, rb, disp16, MO_LEUQ, 0, 0);
         break;
     case 0x2A:
         /* LDL_L */
         gen_load_int(ctx, ra, rb, disp16, MO_LESL | MO_ALIGN, 0, 1);
         break;
     case 0x2B:
         /* LDQ_L */
         gen_load_int(ctx, ra, rb, disp16, MO_LEUQ | MO_ALIGN, 0, 1);
         break;
     case 0x2C:
         /* STL */
         gen_store_int(ctx, ra, rb, disp16, MO_LEUL, 0);
         break;
     case 0x2D:
         /* STQ */
         gen_store_int(ctx, ra, rb, disp16, MO_LEUQ, 0);
         break;
     case 0x2E:
         /* STL_C */
         ret = gen_store_conditional(ctx, ra, rb, disp16,
                                     ctx->mem_idx, MO_LESL | MO_ALIGN);
         break;
     case 0x2F:
         /* STQ_C */
         ret = gen_store_conditional(ctx, ra, rb, disp16,
                                     ctx->mem_idx, MO_LEUQ | MO_ALIGN);
         break;
     case 0x30:
         /* BR */
         ret = gen_bdirect(ctx, ra, disp21);
         break;
     case 0x31: /* FBEQ */
         REQUIRE_FEN;
         ret = gen_fbcond(ctx, TCG_COND_EQ, ra, disp21);
         break;
     case 0x32: /* FBLT */
         REQUIRE_FEN;
         ret = gen_fbcond(ctx, TCG_COND_LT, ra, disp21);
         break;
     case 0x33: /* FBLE */
         REQUIRE_FEN;
         ret = gen_fbcond(ctx, TCG_COND_LE, ra, disp21);
         break;
     case 0x34:
         /* BSR */
         ret = gen_bdirect(ctx, ra, disp21);
         break;
     case 0x35: /* FBNE */
         REQUIRE_FEN;
         ret = gen_fbcond(ctx, TCG_COND_NE, ra, disp21);
         break;
     case 0x36: /* FBGE */
         REQUIRE_FEN;
         ret = gen_fbcond(ctx, TCG_COND_GE, ra, disp21);
         break;
     case 0x37: /* FBGT */
         REQUIRE_FEN;
         ret = gen_fbcond(ctx, TCG_COND_GT, ra, disp21);
         break;
     case 0x38:
         /* BLBC */
         ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 1);
         break;
     case 0x39:
         /* BEQ */
         ret = gen_bcond(ctx, TCG_COND_EQ, ra, disp21, 0);
         break;
     case 0x3A:
         /* BLT */
         ret = gen_bcond(ctx, TCG_COND_LT, ra, disp21, 0);
         break;
     case 0x3B:
         /* BLE */
         ret = gen_bcond(ctx, TCG_COND_LE, ra, disp21, 0);
         break;
     case 0x3C:
         /* BLBS */
         ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 1);
         break;
     case 0x3D:
         /* BNE */
         ret = gen_bcond(ctx, TCG_COND_NE, ra, disp21, 0);
         break;
     case 0x3E:
         /* BGE */
         ret = gen_bcond(ctx, TCG_COND_GE, ra, disp21, 0);
         break;
     case 0x3F:
         /* BGT */
         ret = gen_bcond(ctx, TCG_COND_GT, ra, disp21, 0);
         break;
     invalid_opc:
         ret = gen_invalid(ctx);
         break;
     raise_fen:
         ret = gen_excp(ctx, EXCP_FEN, 0);
         break;
     }
 
     return ret;
 }
@@ -2929,27 +2929,29 @@ static void alpha_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
 static void alpha_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
 {
     DisasContext *ctx = container_of(dcbase, DisasContext, base);
 
     switch (ctx->base.is_jmp) {
     case DISAS_NORETURN:
         break;
     case DISAS_TOO_MANY:
         if (use_goto_tb(ctx, ctx->base.pc_next)) {
             tcg_gen_goto_tb(0);
             tcg_gen_movi_i64(cpu_pc, ctx->base.pc_next);
             tcg_gen_exit_tb(ctx->base.tb, 0);
         }
         /* FALLTHRU */
+        fallthrough;
     case DISAS_PC_STALE:
         tcg_gen_movi_i64(cpu_pc, ctx->base.pc_next);
         /* FALLTHRU */
+        fallthrough;
     case DISAS_PC_UPDATED:
         tcg_gen_lookup_and_goto_ptr();
         break;
     case DISAS_PC_UPDATED_NOCHAIN:
         tcg_gen_exit_tb(NULL, 0);
         break;
     default:
         g_assert_not_reached();
     }
 }
Signature · 1 line
2.39.2
#80 lore raw

RFC PATCH v2 68/78 hw/pci: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/pci/pcie_aer.c | 3 ++-
 hw/pci/pcie_doe.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
hw/pci/pcie_aer.c +2 -1
index b68c7ecb49..c99ecce2a1 100644
@@ -97,71 +97,72 @@ static void aer_log_clear_all_err(PCIEAERLog *aer_log)
 int pcie_aer_init(PCIDevice *dev, uint8_t cap_ver, uint16_t offset,
                   uint16_t size, Error **errp)
 {
     pcie_add_capability(dev, PCI_EXT_CAP_ID_ERR, cap_ver,
                         offset, size);
     dev->exp.aer_cap = offset;
 
     /* clip down the value to avoid unreasonable memory usage */
     if (dev->exp.aer_log.log_max > PCIE_AER_LOG_MAX_LIMIT) {
         error_setg(errp, "Invalid aer_log_max %d. The max number of aer log "
                 "is %d", dev->exp.aer_log.log_max, PCIE_AER_LOG_MAX_LIMIT);
         return -EINVAL;
     }
     dev->exp.aer_log.log = g_malloc0(sizeof dev->exp.aer_log.log[0] *
                                         dev->exp.aer_log.log_max);
 
     pci_set_long(dev->w1cmask + offset + PCI_ERR_UNCOR_STATUS,
                  PCI_ERR_UNC_SUPPORTED);
 
     if (dev->cap_present & QEMU_PCIE_ERR_UNC_MASK) {
         pci_set_long(dev->config + offset + PCI_ERR_UNCOR_MASK,
                      PCI_ERR_UNC_MASK_DEFAULT);
         pci_set_long(dev->wmask + offset + PCI_ERR_UNCOR_MASK,
                      PCI_ERR_UNC_SUPPORTED);
     }
 
     pci_set_long(dev->config + offset + PCI_ERR_UNCOR_SEVER,
                  PCI_ERR_UNC_SEVERITY_DEFAULT);
     pci_set_long(dev->wmask + offset + PCI_ERR_UNCOR_SEVER,
                  PCI_ERR_UNC_SUPPORTED);
 
     pci_long_test_and_set_mask(dev->w1cmask + offset + PCI_ERR_COR_STATUS,
                                PCI_ERR_COR_SUPPORTED);
 
     pci_set_long(dev->config + offset + PCI_ERR_COR_MASK,
                  PCI_ERR_COR_MASK_DEFAULT);
     pci_set_long(dev->wmask + offset + PCI_ERR_COR_MASK,
                  PCI_ERR_COR_SUPPORTED);
 
     /* capabilities and control. multiple header logging is supported */
     if (dev->exp.aer_log.log_max > 0) {
         pci_set_long(dev->config + offset + PCI_ERR_CAP,
                      PCI_ERR_CAP_ECRC_GENC | PCI_ERR_CAP_ECRC_CHKC |
                      PCI_ERR_CAP_MHRC);
         pci_set_long(dev->wmask + offset + PCI_ERR_CAP,
                      PCI_ERR_CAP_ECRC_GENE | PCI_ERR_CAP_ECRC_CHKE |
                      PCI_ERR_CAP_MHRE);
     } else {
         pci_set_long(dev->config + offset + PCI_ERR_CAP,
                      PCI_ERR_CAP_ECRC_GENC | PCI_ERR_CAP_ECRC_CHKC);
         pci_set_long(dev->wmask + offset + PCI_ERR_CAP,
                      PCI_ERR_CAP_ECRC_GENE | PCI_ERR_CAP_ECRC_CHKE);
     }
 
     switch (pcie_cap_get_type(dev)) {
     case PCI_EXP_TYPE_ROOT_PORT:
         /* this case will be set by pcie_aer_root_init() */
-        /* fallthrough */
+        fallthrough;
     case PCI_EXP_TYPE_DOWNSTREAM:
+        fallthrough;
     case PCI_EXP_TYPE_UPSTREAM:
         pci_word_test_and_set_mask(dev->wmask + PCI_BRIDGE_CONTROL,
                                    PCI_BRIDGE_CTL_SERR);
         pci_long_test_and_set_mask(dev->w1cmask + PCI_STATUS,
                                    PCI_SEC_STATUS_RCV_SYSTEM_ERROR);
         break;
     default:
         /* nothing */
         break;
     }
     return 0;
 }
hw/pci/pcie_doe.c +1 -1
index 2210f86968..f04a36e664 100644
@@ -295,73 +295,73 @@ bool pcie_doe_read_config(DOECap *doe_cap, uint32_t addr, int size,
 /*
  * Write to DOE config space.
  * Return if the address not within DOE_CAP range or receives an abort
  */
 void pcie_doe_write_config(DOECap *doe_cap,
                            uint32_t addr, uint32_t val, int size)
 {
     uint16_t doe_offset = doe_cap->offset;
     uint32_t shift;
 
     if (!range_covers_byte(doe_offset + PCI_EXP_DOE_CAP,
                            PCI_DOE_SIZEOF - 4, addr)) {
         return;
     }
 
     /* Process Alignment */
     shift = addr % DWORD_BYTE;
     addr -= (doe_offset + shift);
     val = deposit32(val, shift * 8, size * 8, val);
 
     switch (addr) {
     case PCI_EXP_DOE_CTRL:
         if (FIELD_EX32(val, PCI_DOE_CAP_CONTROL, DOE_ABORT)) {
             pcie_doe_set_ready(doe_cap, 0);
             pcie_doe_set_error(doe_cap, 0);
             pcie_doe_reset_mbox(doe_cap);
             return;
         }
 
         if (FIELD_EX32(val, PCI_DOE_CAP_CONTROL, DOE_GO)) {
             pcie_doe_prepare_rsp(doe_cap);
         }
 
         if (FIELD_EX32(val, PCI_DOE_CAP_CONTROL, DOE_INTR_EN)) {
             doe_cap->ctrl.intr = 1;
         /* Clear interrupt bit located within the first byte */
         } else if (shift == 0) {
             doe_cap->ctrl.intr = 0;
         }
         break;
     case PCI_EXP_DOE_STATUS:
         if (FIELD_EX32(val, PCI_DOE_CAP_STATUS, DOE_INTR_STATUS)) {
             doe_cap->status.intr = 0;
         }
         break;
     case PCI_EXP_DOE_RD_DATA_MBOX:
         /* Mailbox should be DW accessed */
         if (size != DWORD_BYTE) {
             return;
         }
         doe_cap->read_mbox_idx++;
         if (doe_cap->read_mbox_idx == doe_cap->read_mbox_len) {
             pcie_doe_reset_mbox(doe_cap);
             pcie_doe_set_ready(doe_cap, 0);
         } else if (doe_cap->read_mbox_idx > doe_cap->read_mbox_len) {
             /* Underflow */
             pcie_doe_set_error(doe_cap, 1);
         }
         break;
     case PCI_EXP_DOE_WR_DATA_MBOX:
         /* Mailbox should be DW accessed */
         if (size != DWORD_BYTE) {
             return;
         }
         doe_cap->write_mbox[doe_cap->write_mbox_len] = val;
         doe_cap->write_mbox_len++;
         break;
     case PCI_EXP_DOE_CAP:
-        /* fallthrough */
+        fallthrough;
     default:
         break;
     }
 }
Signature · 1 line
2.39.2
#50 lore raw

RFC PATCH v2 40/78 hw/sd/sdhci.c: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/sd/sdhci.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
hw/sd/sdhci.c +4 -4
index 5564765a9b..5c641d24de 100644
@@ -75,138 +75,138 @@ static bool sdhci_check_capab_freq_range(SDHCIState *s, const char *desc,
 static void sdhci_check_capareg(SDHCIState *s, Error **errp)
 {
     uint64_t msk = s->capareg;
     uint32_t val;
     bool y;
 
     switch (s->sd_spec_version) {
     case 4:
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, BUS64BIT_V4);
         trace_sdhci_capareg("64-bit system bus (v4)", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, BUS64BIT_V4, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, UHS_II);
         trace_sdhci_capareg("UHS-II", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, UHS_II, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, ADMA3);
         trace_sdhci_capareg("ADMA3", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, ADMA3, 0);
 
-    /* fallthrough */
+        fallthrough;
     case 3:
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, ASYNC_INT);
         trace_sdhci_capareg("async interrupt", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, ASYNC_INT, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, SLOT_TYPE);
         if (val) {
             error_setg(errp, "slot-type not supported");
             return;
         }
         trace_sdhci_capareg("slot type", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, SLOT_TYPE, 0);
 
         if (val != 2) {
             val = FIELD_EX64(s->capareg, SDHC_CAPAB, EMBEDDED_8BIT);
             trace_sdhci_capareg("8-bit bus", val);
         }
         msk = FIELD_DP64(msk, SDHC_CAPAB, EMBEDDED_8BIT, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, BUS_SPEED);
         trace_sdhci_capareg("bus speed mask", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, BUS_SPEED, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, DRIVER_STRENGTH);
         trace_sdhci_capareg("driver strength mask", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, DRIVER_STRENGTH, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, TIMER_RETUNING);
         trace_sdhci_capareg("timer re-tuning", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, TIMER_RETUNING, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, SDR50_TUNING);
         trace_sdhci_capareg("use SDR50 tuning", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, SDR50_TUNING, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, RETUNING_MODE);
         trace_sdhci_capareg("re-tuning mode", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, RETUNING_MODE, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, CLOCK_MULT);
         trace_sdhci_capareg("clock multiplier", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, CLOCK_MULT, 0);
 
-    /* fallthrough */
+        fallthrough;
     case 2: /* default version */
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, ADMA2);
         trace_sdhci_capareg("ADMA2", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, ADMA2, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, ADMA1);
         trace_sdhci_capareg("ADMA1", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, ADMA1, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, BUS64BIT);
         trace_sdhci_capareg("64-bit system bus (v3)", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, BUS64BIT, 0);
 
-    /* fallthrough */
+        fallthrough;
     case 1:
         y = FIELD_EX64(s->capareg, SDHC_CAPAB, TOUNIT);
         msk = FIELD_DP64(msk, SDHC_CAPAB, TOUNIT, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, TOCLKFREQ);
         trace_sdhci_capareg(y ? "timeout (MHz)" : "Timeout (KHz)", val);
         if (sdhci_check_capab_freq_range(s, "timeout", val, errp)) {
             return;
         }
         msk = FIELD_DP64(msk, SDHC_CAPAB, TOCLKFREQ, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, BASECLKFREQ);
         trace_sdhci_capareg(y ? "base (MHz)" : "Base (KHz)", val);
         if (sdhci_check_capab_freq_range(s, "base", val, errp)) {
             return;
         }
         msk = FIELD_DP64(msk, SDHC_CAPAB, BASECLKFREQ, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, MAXBLOCKLENGTH);
         if (val >= 3) {
             error_setg(errp, "block size can be 512, 1024 or 2048 only");
             return;
         }
         trace_sdhci_capareg("max block length", sdhci_get_fifolen(s));
         msk = FIELD_DP64(msk, SDHC_CAPAB, MAXBLOCKLENGTH, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, HIGHSPEED);
         trace_sdhci_capareg("high speed", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, HIGHSPEED, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, SDMA);
         trace_sdhci_capareg("SDMA", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, SDMA, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, SUSPRESUME);
         trace_sdhci_capareg("suspend/resume", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, SUSPRESUME, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, V33);
         trace_sdhci_capareg("3.3v", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, V33, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, V30);
         trace_sdhci_capareg("3.0v", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, V30, 0);
 
         val = FIELD_EX64(s->capareg, SDHC_CAPAB, V18);
         trace_sdhci_capareg("1.8v", val);
         msk = FIELD_DP64(msk, SDHC_CAPAB, V18, 0);
         break;
 
     default:
         error_setg(errp, "Unsupported spec version: %u", s->sd_spec_version);
     }
     if (msk) {
         qemu_log_mask(LOG_UNIMP,
                       "SDHCI: unknown CAPAB mask: 0x%016" PRIx64 "\n", msk);
     }
 }
@@ -1688,160 +1688,160 @@ static void
 usdhc_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
 {
     SDHCIState *s = SYSBUS_SDHCI(opaque);
     uint8_t hostctl1;
     uint32_t value = (uint32_t)val;
 
     switch (offset) {
     case USDHC_DLL_CTRL:
     case USDHC_TUNE_CTRL_STATUS:
     case USDHC_UNDOCUMENTED_REG27:
     case USDHC_TUNING_CTRL:
     case USDHC_WTMK_LVL:
         break;
 
     case USDHC_VENDOR_SPEC:
         s->vendor_spec = value;
         switch (s->vendor) {
         case SDHCI_VENDOR_IMX:
             if (value & USDHC_IMX_FRC_SDCLK_ON) {
                 s->prnsts &= ~SDHC_IMX_CLOCK_GATE_OFF;
             } else {
                 s->prnsts |= SDHC_IMX_CLOCK_GATE_OFF;
             }
             break;
         default:
             break;
         }
         break;
 
     case SDHC_HOSTCTL:
         /*
          * Here's What ESDHCI has at offset 0x28 (SDHC_HOSTCTL)
          *
          *       7         6     5      4      3      2        1      0
          * |-----------+--------+--------+-----------+----------+---------|
          * | Card      | Card   | Endian | DATA3     | Data     | Led     |
          * | Detect    | Detect | Mode   | as Card   | Transfer | Control |
          * | Signal    | Test   |        | Detection | Width    |         |
          * | Selection | Level  |        | Pin       |          |         |
          * |-----------+--------+--------+-----------+----------+---------|
          *
          * and 0x29
          *
          *  15      10 9    8
          * |----------+------|
          * | Reserved | DMA  |
          * |          | Sel. |
          * |          |      |
          * |----------+------|
          *
          * and here's what SDCHI spec expects those offsets to be:
          *
          * 0x28 (Host Control Register)
          *
          *     7        6         5       4  3      2         1        0
          * |--------+--------+----------+------+--------+----------+---------|
          * | Card   | Card   | Extended | DMA  | High   | Data     | LED     |
          * | Detect | Detect | Data     | Sel. | Speed  | Transfer | Control |
          * | Signal | Test   | Transfer |      | Enable | Width    |         |
          * | Sel.   | Level  | Width    |      |        |          |         |
          * |--------+--------+----------+------+--------+----------+---------|
          *
          * and 0x29 (Power Control Register)
          *
          * |----------------------------------|
          * | Power Control Register           |
          * |                                  |
          * | Description omitted,             |
          * | since it has no analog in ESDHCI |
          * |                                  |
          * |----------------------------------|
          *
          * Since offsets 0x2A and 0x2B should be compatible between
          * both IP specs we only need to reconcile least 16-bit of the
          * word we've been given.
          */
 
         /*
          * First, save bits 7 6 and 0 since they are identical
          */
         hostctl1 = value & (SDHC_CTRL_LED |
                             SDHC_CTRL_CDTEST_INS |
                             SDHC_CTRL_CDTEST_EN);
         /*
          * Second, split "Data Transfer Width" from bits 2 and 1 in to
          * bits 5 and 1
          */
         if (value & USDHC_CTRL_8BITBUS) {
             hostctl1 |= SDHC_CTRL_8BITBUS;
         }
 
         if (value & USDHC_CTRL_4BITBUS) {
             hostctl1 |= USDHC_CTRL_4BITBUS;
         }
 
         /*
          * Third, move DMA select from bits 9 and 8 to bits 4 and 3
          */
         hostctl1 |= SDHC_DMA_TYPE(value >> (8 - 3));
 
         /*
          * Now place the corrected value into low 16-bit of the value
          * we are going to give standard SDHCI write function
          *
          * NOTE: This transformation should be the inverse of what can
          * be found in drivers/mmc/host/sdhci-esdhc-imx.c in Linux
          * kernel
          */
         value &= ~UINT16_MAX;
         value |= hostctl1;
         value |= (uint16_t)s->pwrcon << 8;
 
         sdhci_write(opaque, offset, value, size);
         break;
 
     case USDHC_MIX_CTRL:
         /*
          * So, when SD/MMC stack in Linux tries to write to "Transfer
          * Mode Register", ESDHC i.MX quirk code will translate it
          * into a write to ESDHC_MIX_CTRL, so we do the opposite in
          * order to get where we started
          *
          * Note that Auto CMD23 Enable bit is located in a wrong place
          * on i.MX, but since it is not used by QEMU we do not care.
          *
          * We don't want to call sdhci_write(.., SDHC_TRNMOD, ...)
          * here because it will result in a call to
          * sdhci_send_command(s) which we don't want.
          *
          */
         s->trnmod = value & UINT16_MAX;
         break;
     case SDHC_TRNMOD:
         /*
          * Similar to above, but this time a write to "Command
          * Register" will be translated into a 4-byte write to
          * "Transfer Mode register" where lower 16-bit of value would
          * be set to zero. So what we do is fill those bits with
          * cached value from s->trnmod and let the SDHCI
          * infrastructure handle the rest
          */
         sdhci_write(opaque, offset, val | s->trnmod, size);
         break;
     case SDHC_BLKSIZE:
         /*
          * ESDHCI does not implement "Host SDMA Buffer Boundary", and
          * Linux driver will try to zero this field out which will
          * break the rest of SDHCI emulation.
          *
          * Linux defaults to maximum possible setting (512K boundary)
          * and it seems to be the only option that i.MX IP implements,
          * so we artificially set it to that value.
          */
         val |= 0x7 << 12;
-        /* FALLTHROUGH */
+        fallthrough;
     default:
         sdhci_write(opaque, offset, val, size);
         break;
     }
 }
Signature · 1 line
2.39.2
#0 lore raw

v2 cover Strict disable implicit fallthrough

/* resubmitted because git-send-email crashed with previous attempt */

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:

https://lore.kernel.org/lkml/1d2830aadbe9d8151728a7df5b88528fc72a0095.1564549413.git.joe@perches.com/

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
Reviewed-by on v2 71/78
#84 lore raw

Re: [RFC PATCH v2 71/78] hw/s390x: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis
Quoted 5 lines · Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---

See Rb's on the other two patches I was CCed in v1.

Signature · 3 lines
Cheers,

David / dhildenb
#23 lore raw

RFC PATCH v2 14/78 util/error-report.c: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In 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
index 6e44a55732..acb66420de 100644
@@ -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
#12 lore raw

RFC PATCH v2 4/78 qapi/opts-visitor: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In 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
index 8f1efab8b9..d7376bf239 100644
@@ -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
index 197139c1c0..1ce43da20b 100644
@@ -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
#21 lore raw

RFC PATCH v2 12/78 hw/usb: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In 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
index 1cac1cd435..5cbaabd2b2 100644
@@ -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
index 7177c17f03..bd2a1bae50 100644
@@ -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
index 19b4534c20..e29cc21957 100644
@@ -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
index 4b60114207..3e9b9c62bd 100644
@@ -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
index c9893df867..2531d583ad 100644
@@ -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
index 1dd4071e68..88c736fad2 100644
@@ -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
#75 lore raw

RFC PATCH v2 63/78 hw/ipmi: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/ipmi/ipmi_bmc_extern.c | 2 +-
 hw/ipmi/smbus_ipmi.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
hw/ipmi/ipmi_bmc_extern.c +1 -1
index e232d35ba2..b2ca02b21f 100644
@@ -168,15 +168,15 @@ static void extern_timeout(void *opaque)
 static void addchar(IPMIBmcExtern *ibe, unsigned char ch)
 {
     switch (ch) {
     case VM_MSG_CHAR:
     case VM_CMD_CHAR:
     case VM_ESCAPE_CHAR:
         ibe->outbuf[ibe->outlen] = VM_ESCAPE_CHAR;
         ibe->outlen++;
         ch |= 0x10;
-        /* fall through */
+        fallthrough;
     default:
         ibe->outbuf[ibe->outlen] = ch;
         ibe->outlen++;
     }
 }
hw/ipmi/smbus_ipmi.c +2 -2
index d0991ab7f9..58f5328a19 100644
@@ -207,90 +207,90 @@ static int ipmi_load_readbuf(SMBusIPMIDevice *sid)
 static int ipmi_write_data(SMBusDevice *dev, uint8_t *buf, uint8_t len)
 {
     SMBusIPMIDevice *sid = SMBUS_IPMI(dev);
     bool send = false;
     uint8_t cmd;
     int ret = 0;
 
     /* length is guaranteed to be >= 1. */
     cmd = *buf++;
     len--;
 
     /* Handle read request, which don't have any data in the write part. */
     switch (cmd) {
     case SSIF_IPMI_RESPONSE:
         sid->currblk = 0;
         ret = ipmi_load_readbuf(sid);
         break;
 
     case SSIF_IPMI_MULTI_PART_RESPONSE_MIDDLE:
         sid->currblk++;
         ret = ipmi_load_readbuf(sid);
         break;
 
     case SSIF_IPMI_MULTI_PART_RETRY:
         if (len >= 1) {
             sid->currblk = buf[0];
             ret = ipmi_load_readbuf(sid);
         } else {
             ret = -1;
         }
         break;
 
     default:
         break;
     }
 
     /* This should be a message write, make the length is there and correct. */
     if (len >= 1) {
         if (*buf != len - 1 || *buf > MAX_SSIF_IPMI_MSG_CHUNK) {
             return -1; /* Bogus message */
         }
         buf++;
         len--;
     }
 
     switch (cmd) {
     case SSIF_IPMI_REQUEST:
         send = true;
-        /* FALLTHRU */
+        fallthrough;
     case SSIF_IPMI_MULTI_PART_REQUEST_START:
         if (len < 2) {
             return -1; /* Bogus. */
         }
         memcpy(sid->inmsg, buf, len);
         sid->inlen = len;
         break;
 
     case SSIF_IPMI_MULTI_PART_REQUEST_END:
         send = true;
-        /* FALLTHRU */
+        fallthrough;
     case SSIF_IPMI_MULTI_PART_REQUEST_MIDDLE:
         if (!sid->inlen) {
             return -1; /* Bogus. */
         }
         if (sid->inlen + len > MAX_SSIF_IPMI_MSG_SIZE) {
             sid->inlen = 0; /* Discard the message. */
             return -1; /* Bogus. */
         }
         if (len < 32) {
             /*
              * Special hack, a multi-part middle that is less than 32 bytes
              * marks the end of a message.  The specification is fairly
              * confusing, so some systems to this, even sending a zero
              * length end message to mark the end.
              */
             send = true;
         }
         if (len > 0) {
             memcpy(sid->inmsg + sid->inlen, buf, len);
         }
         sid->inlen += len;
         break;
     }
 
     if (send && sid->inlen) {
         smbus_ipmi_send_msg(sid);
     }
 
     return ret;
 }
Signature · 1 line
2.39.2
#88 lore raw

RFC PATCH v2 75/78 migration: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 migration/migration.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/migration.c +1 -1
index 585d3c8f55..fdad37efbb 100644
@@ -2772,38 +2772,38 @@ static MigIterateState migration_iteration_run(MigrationState *s)
 static void migration_iteration_finish(MigrationState *s)
 {
     /* If we enabled cpu throttling for auto-converge, turn it off. */
     cpu_throttle_stop();
 
     qemu_mutex_lock_iothread();
     switch (s->state) {
     case MIGRATION_STATUS_COMPLETED:
         migration_calculate_complete(s);
         runstate_set(RUN_STATE_POSTMIGRATE);
         break;
     case MIGRATION_STATUS_COLO:
         assert(migrate_colo());
         migrate_start_colo_process(s);
         s->vm_old_state = RUN_STATE_RUNNING;
-        /* Fallthrough */
+        fallthrough;
     case MIGRATION_STATUS_FAILED:
     case MIGRATION_STATUS_CANCELLED:
     case MIGRATION_STATUS_CANCELLING:
         if (s->vm_old_state == RUN_STATE_RUNNING) {
             if (!runstate_check(RUN_STATE_SHUTDOWN)) {
                 vm_start();
             }
         } else {
             if (runstate_check(RUN_STATE_FINISH_MIGRATE)) {
                 runstate_set(s->vm_old_state);
             }
         }
         break;
 
     default:
         /* Should not reach here, but if so, forgive the VM. */
         error_report("%s: Unknown ending state %d", __func__, s->state);
         break;
     }
     migrate_fd_cleanup_schedule(s);
     qemu_mutex_unlock_iothread();
 }
Signature · 1 line
2.39.2
#71 lore raw

RFC PATCH v2 59/78 hw/intc: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/intc/apic.c          |  2 +-
 hw/intc/arm_gicv3_kvm.c | 16 ++++++++--------
 hw/intc/armv7m_nvic.c   | 12 ++++++------
 hw/intc/xilinx_intc.c   |  2 +-
 4 files changed, 16 insertions(+), 16 deletions(-)
hw/intc/apic.c +1 -1
index ac3d47d231..30f341c722 100644
@@ -172,21 +172,21 @@ static void apic_local_deliver(APICCommonState *s, int vector)
 void apic_deliver_pic_intr(DeviceState *dev, int level)
 {
     APICCommonState *s = APIC(dev);
 
     if (level) {
         apic_local_deliver(s, APIC_LVT_LINT0);
     } else {
         uint32_t lvt = s->lvt[APIC_LVT_LINT0];
 
         switch ((lvt >> 8) & 7) {
         case APIC_DM_FIXED:
             if (!(lvt & APIC_LVT_LEVEL_TRIGGER))
                 break;
             apic_reset_bit(s->irr, lvt & 0xff);
-            /* fall through */
+            fallthrough;
         case APIC_DM_EXTINT:
             apic_update_irq(s);
             break;
         }
     }
 }
hw/intc/arm_gicv3_kvm.c +8 -8
index 72ad916d3d..782cef3390 100644
@@ -323,186 +323,186 @@ static void kvm_arm_gicv3_check(GICv3State *s)
 static void kvm_arm_gicv3_put(GICv3State *s)
 {
     uint32_t regl, regh, reg;
     uint64_t reg64, redist_typer;
     int ncpu, i;
 
     kvm_arm_gicv3_check(s);
 
     kvm_gicr_access(s, GICR_TYPER, 0, &regl, false);
     kvm_gicr_access(s, GICR_TYPER + 4, 0, &regh, false);
     redist_typer = ((uint64_t)regh << 32) | regl;
 
     reg = s->gicd_ctlr;
     kvm_gicd_access(s, GICD_CTLR, &reg, true);
 
     if (redist_typer & GICR_TYPER_PLPIS) {
         /*
          * Restore base addresses before LPIs are potentially enabled by
          * GICR_CTLR write
          */
         for (ncpu = 0; ncpu < s->num_cpu; ncpu++) {
             GICv3CPUState *c = &s->cpu[ncpu];
 
             reg64 = c->gicr_propbaser;
             regl = (uint32_t)reg64;
             kvm_gicr_access(s, GICR_PROPBASER, ncpu, &regl, true);
             regh = (uint32_t)(reg64 >> 32);
             kvm_gicr_access(s, GICR_PROPBASER + 4, ncpu, &regh, true);
 
             reg64 = c->gicr_pendbaser;
             regl = (uint32_t)reg64;
             kvm_gicr_access(s, GICR_PENDBASER, ncpu, &regl, true);
             regh = (uint32_t)(reg64 >> 32);
             kvm_gicr_access(s, GICR_PENDBASER + 4, ncpu, &regh, true);
         }
     }
 
     /* Redistributor state (one per CPU) */
 
     for (ncpu = 0; ncpu < s->num_cpu; ncpu++) {
         GICv3CPUState *c = &s->cpu[ncpu];
 
         reg = c->gicr_ctlr;
         kvm_gicr_access(s, GICR_CTLR, ncpu, &reg, true);
 
         reg = c->gicr_statusr[GICV3_NS];
         kvm_gicr_access(s, GICR_STATUSR, ncpu, &reg, true);
 
         reg = c->gicr_waker;
         kvm_gicr_access(s, GICR_WAKER, ncpu, &reg, true);
 
         reg = c->gicr_igroupr0;
         kvm_gicr_access(s, GICR_IGROUPR0, ncpu, &reg, true);
 
         reg = ~0;
         kvm_gicr_access(s, GICR_ICENABLER0, ncpu, &reg, true);
         reg = c->gicr_ienabler0;
         kvm_gicr_access(s, GICR_ISENABLER0, ncpu, &reg, true);
 
         /* Restore config before pending so we treat level/edge correctly */
         reg = half_shuffle32(c->edge_trigger >> 16) << 1;
         kvm_gicr_access(s, GICR_ICFGR1, ncpu, &reg, true);
 
         reg = c->level;
         kvm_gic_line_level_access(s, 0, ncpu, &reg, true);
 
         reg = ~0;
         kvm_gicr_access(s, GICR_ICPENDR0, ncpu, &reg, true);
         reg = c->gicr_ipendr0;
         kvm_gicr_access(s, GICR_ISPENDR0, ncpu, &reg, true);
 
         reg = ~0;
         kvm_gicr_access(s, GICR_ICACTIVER0, ncpu, &reg, true);
         reg = c->gicr_iactiver0;
         kvm_gicr_access(s, GICR_ISACTIVER0, ncpu, &reg, true);
 
         for (i = 0; i < GIC_INTERNAL; i += 4) {
             reg = c->gicr_ipriorityr[i] |
                 (c->gicr_ipriorityr[i + 1] << 8) |
                 (c->gicr_ipriorityr[i + 2] << 16) |
                 (c->gicr_ipriorityr[i + 3] << 24);
             kvm_gicr_access(s, GICR_IPRIORITYR + i, ncpu, &reg, true);
         }
     }
 
     /* Distributor state (shared between all CPUs */
     reg = s->gicd_statusr[GICV3_NS];
     kvm_gicd_access(s, GICD_STATUSR, &reg, true);
 
     /* s->enable bitmap -> GICD_ISENABLERn */
     kvm_dist_putbmp(s, GICD_ISENABLER, GICD_ICENABLER, s->enabled);
 
     /* s->group bitmap -> GICD_IGROUPRn */
     kvm_dist_putbmp(s, GICD_IGROUPR, 0, s->group);
 
     /* Restore targets before pending to ensure the pending state is set on
      * the appropriate CPU interfaces in the kernel
      */
 
     /* s->gicd_irouter[irq] -> GICD_IROUTERn
      * We can't use kvm_dist_put() here because the registers are 64-bit
      */
     for (i = GIC_INTERNAL; i < s->num_irq; i++) {
         uint32_t offset;
 
         offset = GICD_IROUTER + (sizeof(uint32_t) * i);
         reg = (uint32_t)s->gicd_irouter[i];
         kvm_gicd_access(s, offset, &reg, true);
 
         offset = GICD_IROUTER + (sizeof(uint32_t) * i) + 4;
         reg = (uint32_t)(s->gicd_irouter[i] >> 32);
         kvm_gicd_access(s, offset, &reg, true);
     }
 
     /* s->trigger bitmap -> GICD_ICFGRn
      * (restore configuration registers before pending IRQs so we treat
      * level/edge correctly)
      */
     kvm_dist_put_edge_trigger(s, GICD_ICFGR, s->edge_trigger);
 
     /* s->level bitmap ->  line_level */
     kvm_gic_put_line_level_bmp(s, s->level);
 
     /* s->pending bitmap -> GICD_ISPENDRn */
     kvm_dist_putbmp(s, GICD_ISPENDR, GICD_ICPENDR, s->pending);
 
     /* s->active bitmap -> GICD_ISACTIVERn */
     kvm_dist_putbmp(s, GICD_ISACTIVER, GICD_ICACTIVER, s->active);
 
     /* s->gicd_ipriority[] -> GICD_IPRIORITYRn */
     kvm_dist_put_priority(s, GICD_IPRIORITYR, s->gicd_ipriority);
 
     /* CPU Interface state (one per CPU) */
 
     for (ncpu = 0; ncpu < s->num_cpu; ncpu++) {
         GICv3CPUState *c = &s->cpu[ncpu];
         int num_pri_bits;
 
         kvm_gicc_access(s, ICC_SRE_EL1, ncpu, &c->icc_sre_el1, true);
         kvm_gicc_access(s, ICC_CTLR_EL1, ncpu,
                         &c->icc_ctlr_el1[GICV3_NS], true);
         kvm_gicc_access(s, ICC_IGRPEN0_EL1, ncpu,
                         &c->icc_igrpen[GICV3_G0], true);
         kvm_gicc_access(s, ICC_IGRPEN1_EL1, ncpu,
                         &c->icc_igrpen[GICV3_G1NS], true);
         kvm_gicc_access(s, ICC_PMR_EL1, ncpu, &c->icc_pmr_el1, true);
         kvm_gicc_access(s, ICC_BPR0_EL1, ncpu, &c->icc_bpr[GICV3_G0], true);
         kvm_gicc_access(s, ICC_BPR1_EL1, ncpu, &c->icc_bpr[GICV3_G1NS], true);
 
         num_pri_bits = ((c->icc_ctlr_el1[GICV3_NS] &
                         ICC_CTLR_EL1_PRIBITS_MASK) >>
                         ICC_CTLR_EL1_PRIBITS_SHIFT) + 1;
 
         switch (num_pri_bits) {
         case 7:
             reg64 = c->icc_apr[GICV3_G0][3];
             kvm_gicc_access(s, ICC_AP0R_EL1(3), ncpu, &reg64, true);
             reg64 = c->icc_apr[GICV3_G0][2];
             kvm_gicc_access(s, ICC_AP0R_EL1(2), ncpu, &reg64, true);
-            /* fall through */
+            fallthrough;
         case 6:
             reg64 = c->icc_apr[GICV3_G0][1];
             kvm_gicc_access(s, ICC_AP0R_EL1(1), ncpu, &reg64, true);
-            /* fall through */
+            fallthrough;
         default:
             reg64 = c->icc_apr[GICV3_G0][0];
             kvm_gicc_access(s, ICC_AP0R_EL1(0), ncpu, &reg64, true);
         }
 
         switch (num_pri_bits) {
         case 7:
             reg64 = c->icc_apr[GICV3_G1NS][3];
             kvm_gicc_access(s, ICC_AP1R_EL1(3), ncpu, &reg64, true);
             reg64 = c->icc_apr[GICV3_G1NS][2];
             kvm_gicc_access(s, ICC_AP1R_EL1(2), ncpu, &reg64, true);
-            /* fall through */
+            fallthrough;
         case 6:
             reg64 = c->icc_apr[GICV3_G1NS][1];
             kvm_gicc_access(s, ICC_AP1R_EL1(1), ncpu, &reg64, true);
-            /* fall through */
+            fallthrough;
         default:
             reg64 = c->icc_apr[GICV3_G1NS][0];
             kvm_gicc_access(s, ICC_AP1R_EL1(0), ncpu, &reg64, true);
         }
     }
 }
@@ -510,156 +510,156 @@ static void kvm_arm_gicv3_put(GICv3State *s)
 static void kvm_arm_gicv3_get(GICv3State *s)
 {
     uint32_t regl, regh, reg;
     uint64_t reg64, redist_typer;
     int ncpu, i;
 
     kvm_arm_gicv3_check(s);
 
     kvm_gicr_access(s, GICR_TYPER, 0, &regl, false);
     kvm_gicr_access(s, GICR_TYPER + 4, 0, &regh, false);
     redist_typer = ((uint64_t)regh << 32) | regl;
 
     kvm_gicd_access(s, GICD_CTLR, &reg, false);
     s->gicd_ctlr = reg;
 
     /* Redistributor state (one per CPU) */
 
     for (ncpu = 0; ncpu < s->num_cpu; ncpu++) {
         GICv3CPUState *c = &s->cpu[ncpu];
 
         kvm_gicr_access(s, GICR_CTLR, ncpu, &reg, false);
         c->gicr_ctlr = reg;
 
         kvm_gicr_access(s, GICR_STATUSR, ncpu, &reg, false);
         c->gicr_statusr[GICV3_NS] = reg;
 
         kvm_gicr_access(s, GICR_WAKER, ncpu, &reg, false);
         c->gicr_waker = reg;
 
         kvm_gicr_access(s, GICR_IGROUPR0, ncpu, &reg, false);
         c->gicr_igroupr0 = reg;
         kvm_gicr_access(s, GICR_ISENABLER0, ncpu, &reg, false);
         c->gicr_ienabler0 = reg;
         kvm_gicr_access(s, GICR_ICFGR1, ncpu, &reg, false);
         c->edge_trigger = half_unshuffle32(reg >> 1) << 16;
         kvm_gic_line_level_access(s, 0, ncpu, &reg, false);
         c->level = reg;
         kvm_gicr_access(s, GICR_ISPENDR0, ncpu, &reg, false);
         c->gicr_ipendr0 = reg;
         kvm_gicr_access(s, GICR_ISACTIVER0, ncpu, &reg, false);
         c->gicr_iactiver0 = reg;
 
         for (i = 0; i < GIC_INTERNAL; i += 4) {
             kvm_gicr_access(s, GICR_IPRIORITYR + i, ncpu, &reg, false);
             c->gicr_ipriorityr[i] = extract32(reg, 0, 8);
             c->gicr_ipriorityr[i + 1] = extract32(reg, 8, 8);
             c->gicr_ipriorityr[i + 2] = extract32(reg, 16, 8);
             c->gicr_ipriorityr[i + 3] = extract32(reg, 24, 8);
         }
     }
 
     if (redist_typer & GICR_TYPER_PLPIS) {
         for (ncpu = 0; ncpu < s->num_cpu; ncpu++) {
             GICv3CPUState *c = &s->cpu[ncpu];
 
             kvm_gicr_access(s, GICR_PROPBASER, ncpu, &regl, false);
             kvm_gicr_access(s, GICR_PROPBASER + 4, ncpu, &regh, false);
             c->gicr_propbaser = ((uint64_t)regh << 32) | regl;
 
             kvm_gicr_access(s, GICR_PENDBASER, ncpu, &regl, false);
             kvm_gicr_access(s, GICR_PENDBASER + 4, ncpu, &regh, false);
             c->gicr_pendbaser = ((uint64_t)regh << 32) | regl;
         }
     }
 
     /* Distributor state (shared between all CPUs */
 
     kvm_gicd_access(s, GICD_STATUSR, &reg, false);
     s->gicd_statusr[GICV3_NS] = reg;
 
     /* GICD_IGROUPRn -> s->group bitmap */
     kvm_dist_getbmp(s, GICD_IGROUPR, s->group);
 
     /* GICD_ISENABLERn -> s->enabled bitmap */
     kvm_dist_getbmp(s, GICD_ISENABLER, s->enabled);
 
     /* Line level of irq */
     kvm_gic_get_line_level_bmp(s, s->level);
     /* GICD_ISPENDRn -> s->pending bitmap */
     kvm_dist_getbmp(s, GICD_ISPENDR, s->pending);
 
     /* GICD_ISACTIVERn -> s->active bitmap */
     kvm_dist_getbmp(s, GICD_ISACTIVER, s->active);
 
     /* GICD_ICFGRn -> s->trigger bitmap */
     kvm_dist_get_edge_trigger(s, GICD_ICFGR, s->edge_trigger);
 
     /* GICD_IPRIORITYRn -> s->gicd_ipriority[] */
     kvm_dist_get_priority(s, GICD_IPRIORITYR, s->gicd_ipriority);
 
     /* GICD_IROUTERn -> s->gicd_irouter[irq] */
     for (i = GIC_INTERNAL; i < s->num_irq; i++) {
         uint32_t offset;
 
         offset = GICD_IROUTER + (sizeof(uint32_t) * i);
         kvm_gicd_access(s, offset, &regl, false);
         offset = GICD_IROUTER + (sizeof(uint32_t) * i) + 4;
         kvm_gicd_access(s, offset, &regh, false);
         s->gicd_irouter[i] = ((uint64_t)regh << 32) | regl;
     }
 
     /*****************************************************************
      * CPU Interface(s) State
      */
 
     for (ncpu = 0; ncpu < s->num_cpu; ncpu++) {
         GICv3CPUState *c = &s->cpu[ncpu];
         int num_pri_bits;
 
         kvm_gicc_access(s, ICC_SRE_EL1, ncpu, &c->icc_sre_el1, false);
         kvm_gicc_access(s, ICC_CTLR_EL1, ncpu,
                         &c->icc_ctlr_el1[GICV3_NS], false);
         kvm_gicc_access(s, ICC_IGRPEN0_EL1, ncpu,
                         &c->icc_igrpen[GICV3_G0], false);
         kvm_gicc_access(s, ICC_IGRPEN1_EL1, ncpu,
                         &c->icc_igrpen[GICV3_G1NS], false);
         kvm_gicc_access(s, ICC_PMR_EL1, ncpu, &c->icc_pmr_el1, false);
         kvm_gicc_access(s, ICC_BPR0_EL1, ncpu, &c->icc_bpr[GICV3_G0], false);
         kvm_gicc_access(s, ICC_BPR1_EL1, ncpu, &c->icc_bpr[GICV3_G1NS], false);
         num_pri_bits = ((c->icc_ctlr_el1[GICV3_NS] &
                         ICC_CTLR_EL1_PRIBITS_MASK) >>
                         ICC_CTLR_EL1_PRIBITS_SHIFT) + 1;
 
         switch (num_pri_bits) {
         case 7:
             kvm_gicc_access(s, ICC_AP0R_EL1(3), ncpu, &reg64, false);
             c->icc_apr[GICV3_G0][3] = reg64;
             kvm_gicc_access(s, ICC_AP0R_EL1(2), ncpu, &reg64, false);
             c->icc_apr[GICV3_G0][2] = reg64;
-            /* fall through */
+            fallthrough;
         case 6:
             kvm_gicc_access(s, ICC_AP0R_EL1(1), ncpu, &reg64, false);
             c->icc_apr[GICV3_G0][1] = reg64;
-            /* fall through */
+            fallthrough;
         default:
             kvm_gicc_access(s, ICC_AP0R_EL1(0), ncpu, &reg64, false);
             c->icc_apr[GICV3_G0][0] = reg64;
         }
 
         switch (num_pri_bits) {
         case 7:
             kvm_gicc_access(s, ICC_AP1R_EL1(3), ncpu, &reg64, false);
             c->icc_apr[GICV3_G1NS][3] = reg64;
             kvm_gicc_access(s, ICC_AP1R_EL1(2), ncpu, &reg64, false);
             c->icc_apr[GICV3_G1NS][2] = reg64;
-            /* fall through */
+            fallthrough;
         case 6:
             kvm_gicc_access(s, ICC_AP1R_EL1(1), ncpu, &reg64, false);
             c->icc_apr[GICV3_G1NS][1] = reg64;
-            /* fall through */
+            fallthrough;
         default:
             kvm_gicc_access(s, ICC_AP1R_EL1(0), ncpu, &reg64, false);
             c->icc_apr[GICV3_G1NS][0] = reg64;
         }
     }
 }
hw/intc/armv7m_nvic.c +6 -6
index 03b6b8c986..72d3ae985e 100644
@@ -2209,128 +2209,128 @@ static int shpr_bank(NVICState *s, int exc, MemTxAttrs attrs)
 static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
                                     uint64_t *data, unsigned size,
                                     MemTxAttrs attrs)
 {
     NVICState *s = (NVICState *)opaque;
     uint32_t offset = addr;
     unsigned i, startvec, end;
     uint32_t val;
 
     if (attrs.user && !nvic_user_access_ok(s, addr, attrs)) {
         /* Generate BusFault for unprivileged accesses */
         return MEMTX_ERROR;
     }
 
     switch (offset) {
     /* reads of set and clear both return the status */
     case 0x100 ... 0x13f: /* NVIC Set enable */
         offset += 0x80;
-        /* fall through */
+        fallthrough;
     case 0x180 ... 0x1bf: /* NVIC Clear enable */
         val = 0;
         startvec = 8 * (offset - 0x180) + NVIC_FIRST_IRQ; /* vector # */
 
         for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
             if (s->vectors[startvec + i].enabled &&
                 (attrs.secure || s->itns[startvec + i])) {
                 val |= (1 << i);
             }
         }
         break;
     case 0x200 ... 0x23f: /* NVIC Set pend */
         offset += 0x80;
-        /* fall through */
+        fallthrough;
     case 0x280 ... 0x2bf: /* NVIC Clear pend */
         val = 0;
         startvec = 8 * (offset - 0x280) + NVIC_FIRST_IRQ; /* vector # */
         for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
             if (s->vectors[startvec + i].pending &&
                 (attrs.secure || s->itns[startvec + i])) {
                 val |= (1 << i);
             }
         }
         break;
     case 0x300 ... 0x33f: /* NVIC Active */
         val = 0;
 
         if (!arm_feature(&s->cpu->env, ARM_FEATURE_V7)) {
             break;
         }
 
         startvec = 8 * (offset - 0x300) + NVIC_FIRST_IRQ; /* vector # */
 
         for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
             if (s->vectors[startvec + i].active &&
                 (attrs.secure || s->itns[startvec + i])) {
                 val |= (1 << i);
             }
         }
         break;
     case 0x400 ... 0x5ef: /* NVIC Priority */
         val = 0;
         startvec = offset - 0x400 + NVIC_FIRST_IRQ; /* vector # */
 
         for (i = 0; i < size && startvec + i < s->num_irq; i++) {
             if (attrs.secure || s->itns[startvec + i]) {
                 val |= s->vectors[startvec + i].prio << (8 * i);
             }
         }
         break;
     case 0xd18 ... 0xd1b: /* System Handler Priority (SHPR1) */
         if (!arm_feature(&s->cpu->env, ARM_FEATURE_M_MAIN)) {
             val = 0;
             break;
         }
-        /* fall through */
+        fallthrough;
     case 0xd1c ... 0xd23: /* System Handler Priority (SHPR2, SHPR3) */
         val = 0;
         for (i = 0; i < size; i++) {
             unsigned hdlidx = (offset - 0xd14) + i;
             int sbank = shpr_bank(s, hdlidx, attrs);
 
             if (sbank < 0) {
                 continue;
             }
             val = deposit32(val, i * 8, 8, get_prio(s, hdlidx, sbank));
         }
         break;
     case 0xd28 ... 0xd2b: /* Configurable Fault Status (CFSR) */
         if (!arm_feature(&s->cpu->env, ARM_FEATURE_M_MAIN)) {
             val = 0;
             break;
         };
         /*
          * The BFSR bits [15:8] are shared between security states
          * and we store them in the NS copy. They are RAZ/WI for
          * NS code if AIRCR.BFHFNMINS is 0.
          */
         val = s->cpu->env.v7m.cfsr[attrs.secure];
         if (!attrs.secure &&
             !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
             val &= ~R_V7M_CFSR_BFSR_MASK;
         } else {
             val |= s->cpu->env.v7m.cfsr[M_REG_NS] & R_V7M_CFSR_BFSR_MASK;
         }
         val = extract32(val, (offset - 0xd28) * 8, size * 8);
         break;
     case 0xfe0 ... 0xfff: /* ID.  */
         if (offset & 3) {
             val = 0;
         } else {
             val = nvic_id[(offset - 0xfe0) >> 2];
         }
         break;
     default:
         if (size == 4) {
             val = nvic_readl(s, offset, attrs);
         } else {
             qemu_log_mask(LOG_GUEST_ERROR,
                           "NVIC: Bad read of size %d at offset 0x%x\n",
                           size, offset);
             val = 0;
         }
     }
 
     trace_nvic_sysreg_read(addr, val, size);
     *data = val;
     return MEMTX_OK;
 }
@@ -2338,126 +2338,126 @@ static MemTxResult nvic_sysreg_read(void *opaque, hwaddr addr,
 static MemTxResult nvic_sysreg_write(void *opaque, hwaddr addr,
                                      uint64_t value, unsigned size,
                                      MemTxAttrs attrs)
 {
     NVICState *s = (NVICState *)opaque;
     uint32_t offset = addr;
     unsigned i, startvec, end;
     unsigned setval = 0;
 
     trace_nvic_sysreg_write(addr, value, size);
 
     if (attrs.user && !nvic_user_access_ok(s, addr, attrs)) {
         /* Generate BusFault for unprivileged accesses */
         return MEMTX_ERROR;
     }
 
     switch (offset) {
     case 0x100 ... 0x13f: /* NVIC Set enable */
         offset += 0x80;
         setval = 1;
-        /* fall through */
+        fallthrough;
     case 0x180 ... 0x1bf: /* NVIC Clear enable */
         startvec = 8 * (offset - 0x180) + NVIC_FIRST_IRQ;
 
         for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
             if (value & (1 << i) &&
                 (attrs.secure || s->itns[startvec + i])) {
                 s->vectors[startvec + i].enabled = setval;
             }
         }
         nvic_irq_update(s);
         goto exit_ok;
     case 0x200 ... 0x23f: /* NVIC Set pend */
         /* the special logic in armv7m_nvic_set_pending()
          * is not needed since IRQs are never escalated
          */
         offset += 0x80;
         setval = 1;
-        /* fall through */
+        fallthrough;
     case 0x280 ... 0x2bf: /* NVIC Clear pend */
         startvec = 8 * (offset - 0x280) + NVIC_FIRST_IRQ; /* vector # */
 
         for (i = 0, end = size * 8; i < end && startvec + i < s->num_irq; i++) {
             /*
              * Note that if the input line is still held high and the interrupt
              * is not active then rule R_CVJS requires that the Pending state
              * remains set; in that case we mustn't let it be cleared.
              */
             if (value & (1 << i) &&
                 (attrs.secure || s->itns[startvec + i]) &&
                 !(setval == 0 && s->vectors[startvec + i].level &&
                   !s->vectors[startvec + i].active)) {
                 s->vectors[startvec + i].pending = setval;
             }
         }
         nvic_irq_update(s);
         goto exit_ok;
     case 0x300 ... 0x33f: /* NVIC Active */
         goto exit_ok; /* R/O */
     case 0x400 ... 0x5ef: /* NVIC Priority */
         startvec = (offset - 0x400) + NVIC_FIRST_IRQ; /* vector # */
 
         for (i = 0; i < size && startvec + i < s->num_irq; i++) {
             if (attrs.secure || s->itns[startvec + i]) {
                 set_prio(s, startvec + i, false, (value >> (i * 8)) & 0xff);
             }
         }
         nvic_irq_update(s);
         goto exit_ok;
     case 0xd18 ... 0xd1b: /* System Handler Priority (SHPR1) */
         if (!arm_feature(&s->cpu->env, ARM_FEATURE_M_MAIN)) {
             goto exit_ok;
         }
-        /* fall through */
+        fallthrough;
     case 0xd1c ... 0xd23: /* System Handler Priority (SHPR2, SHPR3) */
         for (i = 0; i < size; i++) {
             unsigned hdlidx = (offset - 0xd14) + i;
             int newprio = extract32(value, i * 8, 8);
             int sbank = shpr_bank(s, hdlidx, attrs);
 
             if (sbank < 0) {
                 continue;
             }
             set_prio(s, hdlidx, sbank, newprio);
         }
         nvic_irq_update(s);
         goto exit_ok;
     case 0xd28 ... 0xd2b: /* Configurable Fault Status (CFSR) */
         if (!arm_feature(&s->cpu->env, ARM_FEATURE_M_MAIN)) {
             goto exit_ok;
         }
         /* All bits are W1C, so construct 32 bit value with 0s in
          * the parts not written by the access size
          */
         value <<= ((offset - 0xd28) * 8);
 
         if (!attrs.secure &&
             !(s->cpu->env.v7m.aircr & R_V7M_AIRCR_BFHFNMINS_MASK)) {
             /* BFSR bits are RAZ/WI for NS if BFHFNMINS is set */
             value &= ~R_V7M_CFSR_BFSR_MASK;
         }
 
         s->cpu->env.v7m.cfsr[attrs.secure] &= ~value;
         if (attrs.secure) {
             /* The BFSR bits [15:8] are shared between security states
              * and we store them in the NS copy.
              */
             s->cpu->env.v7m.cfsr[M_REG_NS] &= ~(value & R_V7M_CFSR_BFSR_MASK);
         }
         goto exit_ok;
     }
     if (size == 4) {
         nvic_writel(s, offset, value, attrs);
         goto exit_ok;
     }
     qemu_log_mask(LOG_GUEST_ERROR,
                   "NVIC: Bad write of size %d at offset 0x%x\n", size, offset);
     /* This is UNPREDICTABLE; treat as RAZ/WI */
 
  exit_ok:
     if (tcg_enabled()) {
         /* Ensure any changes made are reflected in the cached hflags. */
         arm_rebuild_hflags(&s->cpu->env);
     }
     return MEMTX_OK;
 }
hw/intc/xilinx_intc.c +1 -1
index 6e5012e66e..245f452898 100644
@@ -108,34 +108,34 @@ static uint64_t pic_read(void *opaque, hwaddr addr, unsigned int size)
 static void pic_write(void *opaque, hwaddr addr,
                       uint64_t val64, unsigned int size)
 {
     XpsIntc *p = opaque;
     uint32_t value = val64;
 
     addr >>= 2;
     D(qemu_log("%s addr=%x val=%x\n", __func__, addr * 4, value));
     switch (addr) 
     {
         case R_IAR:
             p->regs[R_ISR] &= ~value; /* ACK.  */
             break;
         case R_SIE:
             p->regs[R_IER] |= value;  /* Atomic set ie.  */
             break;
         case R_CIE:
             p->regs[R_IER] &= ~value; /* Atomic clear ie.  */
             break;
         case R_MER:
             p->regs[R_MER] = value & 0x3;
             break;
         case R_ISR:
             if ((p->regs[R_MER] & 2)) {
                 break;
             }
-            /* fallthrough */
+            fallthrough;
         default:
             if (addr < ARRAY_SIZE(p->regs))
                 p->regs[addr] = value;
             break;
     }
     update_irq(p);
 }
Signature · 1 line
2.39.2
#52 lore raw

RFC PATCH v2 42/78 hw/i386: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/i386/intel_iommu.c    | 4 ++--
 hw/i386/kvm/xen_evtchn.c | 2 +-
 hw/i386/x86.c            | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
hw/i386/intel_iommu.c +2 -2
index 2c832ab68b..bdb2ea3ac5 100644
@@ -2100,29 +2100,29 @@ static void vtd_context_device_invalidate(IntelIOMMUState *s,
 /* Context-cache invalidation
  * Returns the Context Actual Invalidation Granularity.
  * @val: the content of the CCMD_REG
  */
 static uint64_t vtd_context_cache_invalidate(IntelIOMMUState *s, uint64_t val)
 {
     uint64_t caig;
     uint64_t type = val & VTD_CCMD_CIRG_MASK;
 
     switch (type) {
     case VTD_CCMD_DOMAIN_INVL:
-        /* Fall through */
+        fallthrough;
     case VTD_CCMD_GLOBAL_INVL:
         caig = VTD_CCMD_GLOBAL_INVL_A;
         vtd_context_global_invalidate(s);
         break;
 
     case VTD_CCMD_DEVICE_INVL:
         caig = VTD_CCMD_DEVICE_INVL_A;
         vtd_context_device_invalidate(s, VTD_CCMD_SID(val), VTD_CCMD_FM(val));
         break;
 
     default:
         error_report_once("%s: invalid context: 0x%" PRIx64,
                           __func__, val);
         caig = 0;
     }
     return caig;
 }
@@ -2513,34 +2513,34 @@ static bool vtd_process_wait_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
 static bool vtd_process_context_cache_desc(IntelIOMMUState *s,
                                            VTDInvDesc *inv_desc)
 {
     uint16_t sid, fmask;
 
     if ((inv_desc->lo & VTD_INV_DESC_CC_RSVD) || inv_desc->hi) {
         error_report_once("%s: invalid cc inv desc: hi=%"PRIx64", lo=%"PRIx64
                           " (reserved nonzero)", __func__, inv_desc->hi,
                           inv_desc->lo);
         return false;
     }
     switch (inv_desc->lo & VTD_INV_DESC_CC_G) {
     case VTD_INV_DESC_CC_DOMAIN:
         trace_vtd_inv_desc_cc_domain(
             (uint16_t)VTD_INV_DESC_CC_DID(inv_desc->lo));
-        /* Fall through */
+        fallthrough;
     case VTD_INV_DESC_CC_GLOBAL:
         vtd_context_global_invalidate(s);
         break;
 
     case VTD_INV_DESC_CC_DEVICE:
         sid = VTD_INV_DESC_CC_SID(inv_desc->lo);
         fmask = VTD_INV_DESC_CC_FM(inv_desc->lo);
         vtd_context_device_invalidate(s, sid, fmask);
         break;
 
     default:
         error_report_once("%s: invalid cc inv desc: hi=%"PRIx64", lo=%"PRIx64
                           " (invalid type)", __func__, inv_desc->hi,
                           inv_desc->lo);
         return false;
     }
     return true;
 }
hw/i386/kvm/xen_evtchn.c +1 -1
index a731738411..d15e324f6e 100644
@@ -2028,71 +2028,71 @@ static int find_be_port(XenEvtchnState *s, struct xenevtchn_handle *xc)
 int xen_be_evtchn_bind_interdomain(struct xenevtchn_handle *xc, uint32_t domid,
                                    evtchn_port_t guest_port)
 {
     XenEvtchnState *s = xen_evtchn_singleton;
     XenEvtchnPort *gp;
     uint16_t be_port = 0;
     int ret;
 
     if (!s) {
         return -ENOTSUP;
     }
 
     if (!xc) {
         return -EFAULT;
     }
 
     if (domid != xen_domid) {
         return -ESRCH;
     }
 
     if (!valid_port(guest_port)) {
         return -EINVAL;
     }
 
     qemu_mutex_lock(&s->port_lock);
 
     /* The guest has to have an unbound port waiting for us to bind */
     gp = &s->port_table[guest_port];
 
     switch (gp->type) {
     case EVTCHNSTAT_interdomain:
         /* Allow rebinding after migration, preserve port # if possible */
         be_port = gp->type_val & ~PORT_INFO_TYPEVAL_REMOTE_QEMU;
         assert(be_port != 0);
         if (!s->be_handles[be_port]) {
             s->be_handles[be_port] = xc;
             xc->guest_port = guest_port;
             ret = xc->be_port = be_port;
             if (kvm_xen_has_cap(EVTCHN_SEND)) {
                 assign_kernel_eventfd(gp->type, guest_port, xc->fd);
             }
             break;
         }
-        /* fall through */
+        fallthrough;
 
     case EVTCHNSTAT_unbound:
         be_port = find_be_port(s, xc);
         if (!be_port) {
             ret = -ENOSPC;
             goto out;
         }
 
         gp->type = EVTCHNSTAT_interdomain;
         gp->type_val = be_port | PORT_INFO_TYPEVAL_REMOTE_QEMU;
         xc->guest_port = guest_port;
         if (kvm_xen_has_cap(EVTCHN_SEND)) {
             assign_kernel_eventfd(gp->type, guest_port, xc->fd);
         }
         ret = be_port;
         break;
 
     default:
         ret = -EINVAL;
         break;
     }
 
  out:
     qemu_mutex_unlock(&s->port_lock);
 
     return ret;
 }
hw/i386/x86.c +1 -1
index b3d054889b..c1fd0a966a 100644
@@ -597,32 +597,32 @@ DeviceState *cpu_get_current_apic(void)
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
 
     trace_x86_gsi_interrupt(n, level);
     switch (n) {
     case 0 ... ISA_NUM_IRQS - 1:
         if (s->i8259_irq[n]) {
             /* Under KVM, Kernel will forward to both PIC and IOAPIC */
             qemu_set_irq(s->i8259_irq[n], level);
         }
-        /* fall through */
+        fallthrough;
     case ISA_NUM_IRQS ... IOAPIC_NUM_PINS - 1:
 #ifdef CONFIG_XEN_EMU
         /*
          * Xen delivers the GSI to the Legacy PIC (not that Legacy PIC
          * routing actually works properly under Xen). And then to
          * *either* the PIRQ handling or the I/OAPIC depending on
          * whether the former wants it.
          */
         if (xen_mode == XEN_EMULATE && xen_evtchn_set_gsi(n, level)) {
             break;
         }
 #endif
         qemu_set_irq(s->ioapic_irq[n], level);
         break;
     case IO_APIC_SECONDARY_IRQBASE
         ... IO_APIC_SECONDARY_IRQBASE + IOAPIC_NUM_PINS - 1:
         qemu_set_irq(s->ioapic2_irq[n - IO_APIC_SECONDARY_IRQBASE], level);
         break;
     }
 }
Signature · 1 line
2.39.2
#66 lore raw

RFC PATCH v2 56/78 hw/input: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/input/hid.c     | 3 ++-
 hw/input/tsc2005.c | 4 ++--
 hw/input/tsc210x.c | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
hw/input/hid.c +2 -1
index a9c7dd1ce1..15fffc5dfb 100644
@@ -250,88 +250,89 @@ static void hid_keyboard_event(DeviceState *dev, QemuConsole *src,
 static void hid_keyboard_process_keycode(HIDState *hs)
 {
     uint8_t hid_code, index, key;
     int i, keycode, slot;
 
     if (hs->n == 0) {
         return;
     }
     slot = hs->head & QUEUE_MASK; QUEUE_INCR(hs->head); hs->n--;
     keycode = hs->kbd.keycodes[slot];
 
     if (!hs->n) {
         trace_hid_kbd_queue_empty();
     }
 
     key = keycode & 0x7f;
     index = key | ((hs->kbd.modifiers & (1 << 8)) >> 1);
     hid_code = hid_usage_keys[index];
     hs->kbd.modifiers &= ~(1 << 8);
 
     switch (hid_code) {
     case 0x00:
         return;
 
     case 0xe0:
         assert(key == 0x1d);
         if (hs->kbd.modifiers & (1 << 9)) {
             /* The hid_codes for the 0xe1/0x1d scancode sequence are 0xe9/0xe0.
              * Here we're processing the second hid_code.  By dropping bit 9
              * and setting bit 8, the scancode after 0x1d will access the
              * second half of the table.
              */
             hs->kbd.modifiers ^= (1 << 8) | (1 << 9);
             return;
         }
         /* fall through to process Ctrl_L */
+        fallthrough;
     case 0xe1 ... 0xe7:
         /* Ctrl_L/Ctrl_R, Shift_L/Shift_R, Alt_L/Alt_R, Win_L/Win_R.
          * Handle releases here, or fall through to process presses.
          */
         if (keycode & (1 << 7)) {
             hs->kbd.modifiers &= ~(1 << (hid_code & 0x0f));
             return;
         }
-        /* fall through */
+        fallthrough;
     case 0xe8 ... 0xe9:
         /* USB modifiers are just 1 byte long.  Bits 8 and 9 of
          * hs->kbd.modifiers implement a state machine that detects the
          * 0xe0 and 0xe1/0x1d sequences.  These bits do not follow the
          * usual rules where bit 7 marks released keys; they are cleared
          * elsewhere in the function as the state machine dictates.
          */
         hs->kbd.modifiers |= 1 << (hid_code & 0x0f);
         return;
 
     case 0xea ... 0xef:
         abort();
 
     default:
         break;
     }
 
     if (keycode & (1 << 7)) {
         for (i = hs->kbd.keys - 1; i >= 0; i--) {
             if (hs->kbd.key[i] == hid_code) {
                 hs->kbd.key[i] = hs->kbd.key[-- hs->kbd.keys];
                 hs->kbd.key[hs->kbd.keys] = 0x00;
                 break;
             }
         }
         if (i < 0) {
             return;
         }
     } else {
         for (i = hs->kbd.keys - 1; i >= 0; i--) {
             if (hs->kbd.key[i] == hid_code) {
                 break;
             }
         }
         if (i < 0) {
             if (hs->kbd.keys < sizeof(hs->kbd.key)) {
                 hs->kbd.key[hs->kbd.keys++] = hid_code;
             }
         } else {
             return;
         }
     }
 }
hw/input/tsc2005.c +2 -2
index db2b80e35f..4f3f1d9d12 100644
@@ -234,70 +234,70 @@ static void tsc2005_write(TSC2005State *s, int reg, uint16_t data)
 /* This handles most of the chip's logic.  */
 static void tsc2005_pin_update(TSC2005State *s)
 {
     int64_t expires;
     bool pin_state;
 
     switch (s->pin_func) {
     case 0:
         pin_state = !s->pressure && !!s->dav;
         break;
     case 1:
     case 3:
     default:
         pin_state = !s->dav;
         break;
     case 2:
         pin_state = !s->pressure;
     }
 
     if (pin_state != s->irq) {
         s->irq = pin_state;
         qemu_set_irq(s->pint, s->irq);
     }
 
     switch (s->nextfunction) {
     case TSC_MODE_XYZ_SCAN:
     case TSC_MODE_XY_SCAN:
         if (!s->host_mode && s->dav)
             s->enabled = false;
         if (!s->pressure)
             return;
-        /* Fall through */
+        fallthrough;
     case TSC_MODE_AUX_SCAN:
         break;
 
     case TSC_MODE_X:
     case TSC_MODE_Y:
     case TSC_MODE_Z:
         if (!s->pressure)
             return;
-        /* Fall through */
+        fallthrough;
     case TSC_MODE_AUX:
     case TSC_MODE_TEMP1:
     case TSC_MODE_TEMP2:
     case TSC_MODE_X_TEST:
     case TSC_MODE_Y_TEST:
     case TSC_MODE_TS_TEST:
         if (s->dav)
             s->enabled = false;
         break;
 
     case TSC_MODE_RESERVED:
     case TSC_MODE_XX_DRV:
     case TSC_MODE_YY_DRV:
     case TSC_MODE_YX_DRV:
     default:
         return;
     }
 
     if (!s->enabled || s->busy)
         return;
 
     s->busy = true;
     s->precision = s->nextprecision;
     s->function = s->nextfunction;
     s->pdst = !s->pnd0;	/* Synchronised on internal clock */
     expires = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
         (NANOSECONDS_PER_SECOND >> 7);
     timer_mod(s->timer, expires);
 }
hw/input/tsc210x.c +1 -1
index 950506fb38..9ae426e1a6 100644
@@ -774,70 +774,70 @@ static void tsc2102_audio_register_write(
 /* This handles most of the chip logic.  */
 static void tsc210x_pin_update(TSC210xState *s)
 {
     int64_t expires;
     bool pin_state;
 
     switch (s->pin_func) {
     case 0:
         pin_state = s->pressure;
         break;
     case 1:
         pin_state = !!s->dav;
         break;
     case 2:
     default:
         pin_state = s->pressure && !s->dav;
     }
 
     if (!s->enabled)
         pin_state = false;
 
     if (pin_state != s->irq) {
         s->irq = pin_state;
         qemu_set_irq(s->pint, !s->irq);
     }
 
     switch (s->nextfunction) {
     case TSC_MODE_XY_SCAN:
     case TSC_MODE_XYZ_SCAN:
         if (!s->pressure)
             return;
         break;
 
     case TSC_MODE_X:
     case TSC_MODE_Y:
     case TSC_MODE_Z:
         if (!s->pressure)
             return;
-        /* Fall through */
+        fallthrough;
     case TSC_MODE_BAT1:
     case TSC_MODE_BAT2:
     case TSC_MODE_AUX:
     case TSC_MODE_TEMP1:
     case TSC_MODE_TEMP2:
         if (s->dav)
             s->enabled = false;
         break;
 
     case TSC_MODE_AUX_SCAN:
     case TSC_MODE_PORT_SCAN:
         break;
 
     case TSC_MODE_NO_SCAN:
     case TSC_MODE_XX_DRV:
     case TSC_MODE_YY_DRV:
     case TSC_MODE_YX_DRV:
     default:
         return;
     }
 
     if (!s->enabled || s->busy || s->dav)
         return;
 
     s->busy = true;
     s->precision = s->nextprecision;
     s->function = s->nextfunction;
     expires = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
         (NANOSECONDS_PER_SECOND >> 10);
     timer_mod(s->timer, expires);
 }
Signature · 1 line
2.39.2
#81 lore raw

RFC PATCH v2 69/78 hw/rdma/rdma_backend.c: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/rdma/rdma_backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/rdma/rdma_backend.c +1 -1
index 6dcdfbbbe2..09e5ad961e 100644
@@ -800,50 +800,50 @@ void rdma_backend_destroy_cq(RdmaBackendCQ *cq)
 int rdma_backend_create_qp(RdmaBackendQP *qp, uint8_t qp_type,
                            RdmaBackendPD *pd, RdmaBackendCQ *scq,
                            RdmaBackendCQ *rcq, RdmaBackendSRQ *srq,
                            uint32_t max_send_wr, uint32_t max_recv_wr,
                            uint32_t max_send_sge, uint32_t max_recv_sge)
 {
     struct ibv_qp_init_attr attr = {};
 
     qp->ibqp = 0;
 
     switch (qp_type) {
     case IBV_QPT_GSI:
         return 0;
 
     case IBV_QPT_RC:
-        /* fall through */
+        fallthrough;
     case IBV_QPT_UD:
         /* do nothing */
         break;
 
     default:
         rdma_error_report("Unsupported QP type %d", qp_type);
         return -EIO;
     }
 
     attr.qp_type = qp_type;
     attr.send_cq = scq->ibcq;
     attr.recv_cq = rcq->ibcq;
     attr.cap.max_send_wr = max_send_wr;
     attr.cap.max_recv_wr = max_recv_wr;
     attr.cap.max_send_sge = max_send_sge;
     attr.cap.max_recv_sge = max_recv_sge;
     if (srq) {
         attr.srq = srq->ibsrq;
     }
 
     qp->ibqp = ibv_create_qp(pd->ibpd, &attr);
     if (!qp->ibqp) {
         rdma_error_report("ibv_create_qp fail, errno=%d", errno);
         return -EIO;
     }
 
     rdma_protected_gslist_init(&qp->cqe_ctx_list);
 
     qp->ibpd = pd->ibpd;
 
     /* TODO: Query QP to get max_inline_data and save it to be used in send */
 
     return 0;
 }
Signature · 1 line
2.39.2
#24 lore raw

RFC PATCH v2 15/78 accel/tcg: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In 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
index b8c5e345b8..92b7ab529a 100644
@@ -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
index 1cf5b92166..3752f74214 100644
@@ -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
index d31c9993ea..ba9a8c8789 100644
@@ -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
#77 lore raw

RFC PATCH v2 65/78 hw/nvme: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/nvme/ctrl.c | 24 ++++++++++++------------
 hw/nvme/dif.c  |  4 ++--
 2 files changed, 14 insertions(+), 14 deletions(-)
hw/nvme/ctrl.c +12 -12
index f026245d1e..acb2012fb9 100644
@@ -1912,29 +1912,29 @@ static uint16_t nvme_check_zone_read(NvmeNamespace *ns, uint64_t slba,
 static uint16_t nvme_zrm_finish(NvmeNamespace *ns, NvmeZone *zone)
 {
     switch (nvme_get_zone_state(zone)) {
     case NVME_ZONE_STATE_FULL:
         return NVME_SUCCESS;
 
     case NVME_ZONE_STATE_IMPLICITLY_OPEN:
     case NVME_ZONE_STATE_EXPLICITLY_OPEN:
         nvme_aor_dec_open(ns);
-        /* fallthrough */
+        fallthrough;
     case NVME_ZONE_STATE_CLOSED:
         nvme_aor_dec_active(ns);
 
         if (zone->d.za & NVME_ZA_ZRWA_VALID) {
             zone->d.za &= ~NVME_ZA_ZRWA_VALID;
             if (ns->params.numzrwa) {
                 ns->zns.numzrwa++;
             }
         }
 
-        /* fallthrough */
+        fallthrough;
     case NVME_ZONE_STATE_EMPTY:
         nvme_assign_zone_state(ns, zone, NVME_ZONE_STATE_FULL);
         return NVME_SUCCESS;
 
     default:
         return NVME_ZONE_INVAL_TRANSITION;
     }
 }
@@ -1942,15 +1942,15 @@ static uint16_t nvme_zrm_finish(NvmeNamespace *ns, NvmeZone *zone)
 static uint16_t nvme_zrm_close(NvmeNamespace *ns, NvmeZone *zone)
 {
     switch (nvme_get_zone_state(zone)) {
     case NVME_ZONE_STATE_EXPLICITLY_OPEN:
     case NVME_ZONE_STATE_IMPLICITLY_OPEN:
         nvme_aor_dec_open(ns);
         nvme_assign_zone_state(ns, zone, NVME_ZONE_STATE_CLOSED);
-        /* fall through */
+        fallthrough;
     case NVME_ZONE_STATE_CLOSED:
         return NVME_SUCCESS;
 
     default:
         return NVME_ZONE_INVAL_TRANSITION;
     }
 }
@@ -1958,29 +1958,29 @@ static uint16_t nvme_zrm_close(NvmeNamespace *ns, NvmeZone *zone)
 static uint16_t nvme_zrm_reset(NvmeNamespace *ns, NvmeZone *zone)
 {
     switch (nvme_get_zone_state(zone)) {
     case NVME_ZONE_STATE_EXPLICITLY_OPEN:
     case NVME_ZONE_STATE_IMPLICITLY_OPEN:
         nvme_aor_dec_open(ns);
-        /* fallthrough */
+        fallthrough;
     case NVME_ZONE_STATE_CLOSED:
         nvme_aor_dec_active(ns);
 
         if (zone->d.za & NVME_ZA_ZRWA_VALID) {
             if (ns->params.numzrwa) {
                 ns->zns.numzrwa++;
             }
         }
 
-        /* fallthrough */
+        fallthrough;
     case NVME_ZONE_STATE_FULL:
         zone->w_ptr = zone->d.zslba;
         zone->d.wp = zone->w_ptr;
         nvme_assign_zone_state(ns, zone, NVME_ZONE_STATE_EMPTY);
-        /* fallthrough */
+        fallthrough;
     case NVME_ZONE_STATE_EMPTY:
         return NVME_SUCCESS;
 
     default:
         return NVME_ZONE_INVAL_TRANSITION;
     }
 }
@@ -2010,57 +2010,57 @@ enum {
 static uint16_t nvme_zrm_open_flags(NvmeCtrl *n, NvmeNamespace *ns,
                                     NvmeZone *zone, int flags)
 {
     int act = 0;
     uint16_t status;
 
     switch (nvme_get_zone_state(zone)) {
     case NVME_ZONE_STATE_EMPTY:
         act = 1;
 
-        /* fallthrough */
+        fallthrough;
 
     case NVME_ZONE_STATE_CLOSED:
         if (n->params.auto_transition_zones) {
             nvme_zrm_auto_transition_zone(ns);
         }
         status = nvme_zns_check_resources(ns, act, 1,
                                           (flags & NVME_ZRM_ZRWA) ? 1 : 0);
         if (status) {
             return status;
         }
 
         if (act) {
             nvme_aor_inc_active(ns);
         }
 
         nvme_aor_inc_open(ns);
 
         if (flags & NVME_ZRM_AUTO) {
             nvme_assign_zone_state(ns, zone, NVME_ZONE_STATE_IMPLICITLY_OPEN);
             return NVME_SUCCESS;
         }
 
-        /* fallthrough */
+        fallthrough;
 
     case NVME_ZONE_STATE_IMPLICITLY_OPEN:
         if (flags & NVME_ZRM_AUTO) {
             return NVME_SUCCESS;
         }
 
         nvme_assign_zone_state(ns, zone, NVME_ZONE_STATE_EXPLICITLY_OPEN);
 
-        /* fallthrough */
+        fallthrough;
 
     case NVME_ZONE_STATE_EXPLICITLY_OPEN:
         if (flags & NVME_ZRM_ZRWA) {
             ns->zns.numzrwa--;
 
             zone->d.za |= NVME_ZA_ZRWA_VALID;
         }
 
         return NVME_SUCCESS;
 
     default:
         return NVME_ZONE_INVAL_TRANSITION;
     }
 }
@@ -3508,135 +3508,135 @@ static void nvme_do_write_fdp(NvmeCtrl *n, NvmeRequest *req, uint64_t slba,
 static uint16_t nvme_do_write(NvmeCtrl *n, NvmeRequest *req, bool append,
                               bool wrz)
 {
     NvmeRwCmd *rw = (NvmeRwCmd *)&req->cmd;
     NvmeNamespace *ns = req->ns;
     uint64_t slba = le64_to_cpu(rw->slba);
     uint32_t nlb = (uint32_t)le16_to_cpu(rw->nlb) + 1;
     uint16_t ctrl = le16_to_cpu(rw->control);
     uint8_t prinfo = NVME_RW_PRINFO(ctrl);
     uint64_t data_size = nvme_l2b(ns, nlb);
     uint64_t mapped_size = data_size;
     uint64_t data_offset;
     NvmeZone *zone;
     NvmeZonedResult *res = (NvmeZonedResult *)&req->cqe;
     BlockBackend *blk = ns->blkconf.blk;
     uint16_t status;
 
     if (nvme_ns_ext(ns)) {
         mapped_size += nvme_m2b(ns, nlb);
 
         if (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) {
             bool pract = prinfo & NVME_PRINFO_PRACT;
 
             if (pract && ns->lbaf.ms == nvme_pi_tuple_size(ns)) {
                 mapped_size -= nvme_m2b(ns, nlb);
             }
         }
     }
 
     trace_pci_nvme_write(nvme_cid(req), nvme_io_opc_str(rw->opcode),
                          nvme_nsid(ns), nlb, mapped_size, slba);
 
     if (!wrz) {
         status = nvme_check_mdts(n, mapped_size);
         if (status) {
             goto invalid;
         }
     }
 
     status = nvme_check_bounds(ns, slba, nlb);
     if (status) {
         goto invalid;
     }
 
     if (ns->params.zoned) {
         zone = nvme_get_zone_by_slba(ns, slba);
         assert(zone);
 
         if (append) {
             bool piremap = !!(ctrl & NVME_RW_PIREMAP);
 
             if (unlikely(zone->d.za & NVME_ZA_ZRWA_VALID)) {
                 return NVME_INVALID_ZONE_OP | NVME_DNR;
             }
 
             if (unlikely(slba != zone->d.zslba)) {
                 trace_pci_nvme_err_append_not_at_start(slba, zone->d.zslba);
                 status = NVME_INVALID_FIELD;
                 goto invalid;
             }
 
             if (n->params.zasl &&
                 data_size > (uint64_t)n->page_size << n->params.zasl) {
                 trace_pci_nvme_err_zasl(data_size);
                 return NVME_INVALID_FIELD | NVME_DNR;
             }
 
             slba = zone->w_ptr;
             rw->slba = cpu_to_le64(slba);
             res->slba = cpu_to_le64(slba);
 
             switch (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) {
             case NVME_ID_NS_DPS_TYPE_1:
                 if (!piremap) {
                     return NVME_INVALID_PROT_INFO | NVME_DNR;
                 }
 
-                /* fallthrough */
+                fallthrough;
 
             case NVME_ID_NS_DPS_TYPE_2:
                 if (piremap) {
                     uint32_t reftag = le32_to_cpu(rw->reftag);
                     rw->reftag = cpu_to_le32(reftag + (slba - zone->d.zslba));
                 }
 
                 break;
 
             case NVME_ID_NS_DPS_TYPE_3:
                 if (piremap) {
                     return NVME_INVALID_PROT_INFO | NVME_DNR;
                 }
 
                 break;
             }
         }
 
         status = nvme_check_zone_write(ns, zone, slba, nlb);
         if (status) {
             goto invalid;
         }
 
         status = nvme_zrm_auto(n, ns, zone);
         if (status) {
             goto invalid;
         }
 
         if (!(zone->d.za & NVME_ZA_ZRWA_VALID)) {
             zone->w_ptr += nlb;
         }
     } else if (ns->endgrp && ns->endgrp->fdp.enabled) {
         nvme_do_write_fdp(n, req, slba, nlb);
     }
 
     data_offset = nvme_l2b(ns, slba);
 
     if (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) {
         return nvme_dif_rw(n, req);
     }
 
     if (!wrz) {
         status = nvme_map_data(n, nlb, req);
         if (status) {
             goto invalid;
         }
 
         block_acct_start(blk_get_stats(blk), &req->acct, data_size,
                          BLOCK_ACCT_WRITE);
         nvme_blk_write(blk, data_offset, BDRV_SECTOR_SIZE, nvme_rw_cb, req);
     } else {
         req->aiocb = blk_aio_pwrite_zeroes(blk, data_offset, data_size,
                                            BDRV_REQ_MAY_UNMAP, nvme_rw_cb,
                                            req);
     }
 
     return NVME_NO_COMPLETE;
@@ -3734,13 +3734,13 @@ static uint16_t nvme_finish_zone(NvmeNamespace *ns, NvmeZone *zone,
 static uint16_t nvme_offline_zone(NvmeNamespace *ns, NvmeZone *zone,
                                   NvmeZoneState state, NvmeRequest *req)
 {
     switch (state) {
     case NVME_ZONE_STATE_READ_ONLY:
         nvme_assign_zone_state(ns, zone, NVME_ZONE_STATE_OFFLINE);
-        /* fall through */
+        fallthrough;
     case NVME_ZONE_STATE_OFFLINE:
         return NVME_SUCCESS;
     default:
         return NVME_ZONE_INVAL_TRANSITION;
     }
 }
@@ -4902,39 +4902,39 @@ static uint16_t nvme_changed_nslist(NvmeCtrl *n, uint8_t rae, uint32_t buf_len,
 static uint16_t nvme_cmd_effects(NvmeCtrl *n, uint8_t csi, uint32_t buf_len,
                                  uint64_t off, NvmeRequest *req)
 {
     NvmeEffectsLog log = {};
     const uint32_t *src_iocs = NULL;
     uint32_t trans_len;
 
     if (off >= sizeof(log)) {
         trace_pci_nvme_err_invalid_log_page_offset(off, sizeof(log));
         return NVME_INVALID_FIELD | NVME_DNR;
     }
 
     switch (NVME_CC_CSS(ldl_le_p(&n->bar.cc))) {
     case NVME_CC_CSS_NVM:
         src_iocs = nvme_cse_iocs_nvm;
-        /* fall through */
+        fallthrough;
     case NVME_CC_CSS_ADMIN_ONLY:
         break;
     case NVME_CC_CSS_CSI:
         switch (csi) {
         case NVME_CSI_NVM:
             src_iocs = nvme_cse_iocs_nvm;
             break;
         case NVME_CSI_ZONED:
             src_iocs = nvme_cse_iocs_zoned;
             break;
         }
     }
 
     memcpy(log.acs, nvme_cse_acs, sizeof(nvme_cse_acs));
 
     if (src_iocs) {
         memcpy(log.iocs, src_iocs, sizeof(log.iocs));
     }
 
     trans_len = MIN(sizeof(log) - off, buf_len);
 
     return nvme_c2h(n, ((uint8_t *)&log) + off, trans_len, req);
 }
hw/nvme/dif.c +2 -2
index 01b19c3373..00dd96bdb3 100644
@@ -153,58 +153,58 @@ void nvme_dif_pract_generate_dif(NvmeNamespace *ns, uint8_t *buf, size_t len,
 static uint16_t nvme_dif_prchk_crc16(NvmeNamespace *ns, NvmeDifTuple *dif,
                                      uint8_t *buf, uint8_t *mbuf, size_t pil,
                                      uint8_t prinfo, uint16_t apptag,
                                      uint16_t appmask, uint64_t reftag)
 {
     switch (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) {
     case NVME_ID_NS_DPS_TYPE_3:
         if (be32_to_cpu(dif->g16.reftag) != 0xffffffff) {
             break;
         }
 
-        /* fallthrough */
+        fallthrough;
     case NVME_ID_NS_DPS_TYPE_1:
     case NVME_ID_NS_DPS_TYPE_2:
         if (be16_to_cpu(dif->g16.apptag) != 0xffff) {
             break;
         }
 
         trace_pci_nvme_dif_prchk_disabled_crc16(be16_to_cpu(dif->g16.apptag),
                                                 be32_to_cpu(dif->g16.reftag));
 
         return NVME_SUCCESS;
     }
 
     if (prinfo & NVME_PRINFO_PRCHK_GUARD) {
         uint16_t crc = crc16_t10dif(0x0, buf, ns->lbasz);
 
         if (pil) {
             crc = crc16_t10dif(crc, mbuf, pil);
         }
 
         trace_pci_nvme_dif_prchk_guard_crc16(be16_to_cpu(dif->g16.guard), crc);
 
         if (be16_to_cpu(dif->g16.guard) != crc) {
             return NVME_E2E_GUARD_ERROR;
         }
     }
 
     if (prinfo & NVME_PRINFO_PRCHK_APP) {
         trace_pci_nvme_dif_prchk_apptag(be16_to_cpu(dif->g16.apptag), apptag,
                                         appmask);
 
         if ((be16_to_cpu(dif->g16.apptag) & appmask) != (apptag & appmask)) {
             return NVME_E2E_APP_ERROR;
         }
     }
 
     if (prinfo & NVME_PRINFO_PRCHK_REF) {
         trace_pci_nvme_dif_prchk_reftag_crc16(be32_to_cpu(dif->g16.reftag),
                                               reftag);
 
         if (be32_to_cpu(dif->g16.reftag) != reftag) {
             return NVME_E2E_REF_ERROR;
         }
     }
 
     return NVME_SUCCESS;
 }
@@ -212,66 +212,66 @@ static uint16_t nvme_dif_prchk_crc16(NvmeNamespace *ns, NvmeDifTuple *dif,
 static uint16_t nvme_dif_prchk_crc64(NvmeNamespace *ns, NvmeDifTuple *dif,
                                      uint8_t *buf, uint8_t *mbuf, size_t pil,
                                      uint8_t prinfo, uint16_t apptag,
                                      uint16_t appmask, uint64_t reftag)
 {
     uint64_t r = 0;
 
     r |= (uint64_t)dif->g64.sr[0] << 40;
     r |= (uint64_t)dif->g64.sr[1] << 32;
     r |= (uint64_t)dif->g64.sr[2] << 24;
     r |= (uint64_t)dif->g64.sr[3] << 16;
     r |= (uint64_t)dif->g64.sr[4] << 8;
     r |= (uint64_t)dif->g64.sr[5];
 
     switch (NVME_ID_NS_DPS_TYPE(ns->id_ns.dps)) {
     case NVME_ID_NS_DPS_TYPE_3:
         if (r != 0xffffffffffff) {
             break;
         }
 
-        /* fallthrough */
+        fallthrough;
     case NVME_ID_NS_DPS_TYPE_1:
     case NVME_ID_NS_DPS_TYPE_2:
         if (be16_to_cpu(dif->g64.apptag) != 0xffff) {
             break;
         }
 
         trace_pci_nvme_dif_prchk_disabled_crc64(be16_to_cpu(dif->g16.apptag),
                                                 r);
 
         return NVME_SUCCESS;
     }
 
     if (prinfo & NVME_PRINFO_PRCHK_GUARD) {
         uint64_t crc = crc64_nvme(~0ULL, buf, ns->lbasz);
 
         if (pil) {
             crc = crc64_nvme(~crc, mbuf, pil);
         }
 
         trace_pci_nvme_dif_prchk_guard_crc64(be64_to_cpu(dif->g64.guard), crc);
 
         if (be64_to_cpu(dif->g64.guard) != crc) {
             return NVME_E2E_GUARD_ERROR;
         }
     }
 
     if (prinfo & NVME_PRINFO_PRCHK_APP) {
         trace_pci_nvme_dif_prchk_apptag(be16_to_cpu(dif->g64.apptag), apptag,
                                         appmask);
 
         if ((be16_to_cpu(dif->g64.apptag) & appmask) != (apptag & appmask)) {
             return NVME_E2E_APP_ERROR;
         }
     }
 
     if (prinfo & NVME_PRINFO_PRCHK_REF) {
         trace_pci_nvme_dif_prchk_reftag_crc64(r, reftag);
 
         if (r != reftag) {
             return NVME_E2E_REF_ERROR;
         }
     }
 
     return NVME_SUCCESS;
 }
Signature · 1 line
2.39.2
#45 lore raw

RFC PATCH v2 35/78 target/sh4: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 target/sh4/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/sh4/helper.c +1 -1
index e02e7af607..c1cc5e82f4 100644
@@ -56,131 +56,131 @@ int cpu_sh4_is_cached(CPUSH4State *env, target_ulong addr)
 void superh_cpu_do_interrupt(CPUState *cs)
 {
     SuperHCPU *cpu = SUPERH_CPU(cs);
     CPUSH4State *env = &cpu->env;
     int do_irq = cs->interrupt_request & CPU_INTERRUPT_HARD;
     int do_exp, irq_vector = cs->exception_index;
 
     /* prioritize exceptions over interrupts */
 
     do_exp = cs->exception_index != -1;
     do_irq = do_irq && (cs->exception_index == -1);
 
     if (env->sr & (1u << SR_BL)) {
         if (do_exp && cs->exception_index != 0x1e0) {
             /* In theory a masked exception generates a reset exception,
                which in turn jumps to the reset vector. However this only
                works when using a bootloader. When using a kernel and an
                initrd, they need to be reloaded and the program counter
                should be loaded with the kernel entry point.
                qemu_system_reset_request takes care of that.  */
             qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
             return;
         }
         if (do_irq && !env->in_sleep) {
             return; /* masked */
         }
     }
     env->in_sleep = 0;
 
     if (do_irq) {
         irq_vector = sh_intc_get_pending_vector(env->intc_handle,
 						(env->sr >> 4) & 0xf);
         if (irq_vector == -1) {
             return; /* masked */
 	}
     }
 
     if (qemu_loglevel_mask(CPU_LOG_INT)) {
 	const char *expname;
         switch (cs->exception_index) {
 	case 0x0e0:
 	    expname = "addr_error";
 	    break;
 	case 0x040:
 	    expname = "tlb_miss";
 	    break;
 	case 0x0a0:
 	    expname = "tlb_violation";
 	    break;
 	case 0x180:
 	    expname = "illegal_instruction";
 	    break;
 	case 0x1a0:
 	    expname = "slot_illegal_instruction";
 	    break;
 	case 0x800:
 	    expname = "fpu_disable";
 	    break;
 	case 0x820:
 	    expname = "slot_fpu";
 	    break;
 	case 0x100:
 	    expname = "data_write";
 	    break;
 	case 0x060:
 	    expname = "dtlb_miss_write";
 	    break;
 	case 0x0c0:
 	    expname = "dtlb_violation_write";
 	    break;
 	case 0x120:
 	    expname = "fpu_exception";
 	    break;
 	case 0x080:
 	    expname = "initial_page_write";
 	    break;
 	case 0x160:
 	    expname = "trapa";
 	    break;
 	default:
             expname = do_irq ? "interrupt" : "???";
             break;
 	}
 	qemu_log("exception 0x%03x [%s] raised\n",
 		  irq_vector, expname);
         log_cpu_state(cs, 0);
     }
 
     env->ssr = cpu_read_sr(env);
     env->spc = env->pc;
     env->sgr = env->gregs[15];
     env->sr |= (1u << SR_BL) | (1u << SR_MD) | (1u << SR_RB);
     env->lock_addr = -1;
 
     if (env->flags & TB_FLAG_DELAY_SLOT_MASK) {
         /* Branch instruction should be executed again before delay slot. */
 	env->spc -= 2;
 	/* Clear flags for exception/interrupt routine. */
         env->flags &= ~TB_FLAG_DELAY_SLOT_MASK;
     }
 
     if (do_exp) {
         env->expevt = cs->exception_index;
         switch (cs->exception_index) {
         case 0x000:
         case 0x020:
         case 0x140:
             env->sr &= ~(1u << SR_FD);
             env->sr |= 0xf << 4; /* IMASK */
             env->pc = 0xa0000000;
             break;
         case 0x040:
         case 0x060:
             env->pc = env->vbr + 0x400;
             break;
         case 0x160:
             env->spc += 2; /* special case for TRAPA */
-            /* fall through */
+            fallthrough;
         default:
             env->pc = env->vbr + 0x100;
             break;
         }
         return;
     }
 
     if (do_irq) {
         env->intevt = irq_vector;
         env->pc = env->vbr + 0x600;
         return;
     }
 }
Signature · 1 line
2.39.2
#43 lore raw

RFC PATCH v2 33/78 target/rx: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 target/rx/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/rx/translate.c +1 -1
index f8860830ae..b00c0a21fb 100644
@@ -2232,24 +2232,24 @@ static void rx_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
 static void rx_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
 {
     DisasContext *ctx = container_of(dcbase, DisasContext, base);
 
     switch (ctx->base.is_jmp) {
     case DISAS_NEXT:
     case DISAS_TOO_MANY:
         gen_goto_tb(ctx, 0, dcbase->pc_next);
         break;
     case DISAS_JUMP:
         tcg_gen_lookup_and_goto_ptr();
         break;
     case DISAS_UPDATE:
         tcg_gen_movi_i32(cpu_pc, ctx->base.pc_next);
-        /* fall through */
+        fallthrough;
     case DISAS_EXIT:
         tcg_gen_exit_tb(NULL, 0);
         break;
     case DISAS_NORETURN:
         break;
     default:
         g_assert_not_reached();
     }
 }
Signature · 1 line
2.39.2
#19 lore raw

RFC PATCH v2 10/78 hw/ide/atapi.c: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In 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
index dcc39df9a4..85c74a5ffe 100644
@@ -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
#40 lore raw

RFC PATCH v2 31/78 target/xtensa: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 target/xtensa/op_helper.c | 8 ++++----
 target/xtensa/translate.c | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
target/xtensa/op_helper.c +4 -4
index 7bb8cd6726..69b72f474d 100644
@@ -73,58 +73,58 @@ void HELPER(update_ccompare)(CPUXtensaState *env, uint32_t i)
 /*!
  * Check vaddr accessibility/cache attributes and raise an exception if
  * specified by the ATOMCTL SR.
  *
  * Note: local memory exclusion is not implemented
  */
 void HELPER(check_atomctl)(CPUXtensaState *env, uint32_t pc, uint32_t vaddr)
 {
     uint32_t paddr, page_size, access;
     uint32_t atomctl = env->sregs[ATOMCTL];
     int rc = xtensa_get_physical_addr(env, true, vaddr, 1,
             xtensa_get_cring(env), &paddr, &page_size, &access);
 
     /*
      * s32c1i never causes LOAD_PROHIBITED_CAUSE exceptions,
      * see opcode description in the ISA
      */
     if (rc == 0 &&
             (access & (PAGE_READ | PAGE_WRITE)) != (PAGE_READ | PAGE_WRITE)) {
         rc = STORE_PROHIBITED_CAUSE;
     }
 
     if (rc) {
         HELPER(exception_cause_vaddr)(env, pc, rc, vaddr);
     }
 
     /*
      * When data cache is not configured use ATOMCTL bypass field.
      * See ISA, 4.3.12.4 The Atomic Operation Control Register (ATOMCTL)
      * under the Conditional Store Option.
      */
     if (!xtensa_option_enabled(env->config, XTENSA_OPTION_DCACHE)) {
         access = PAGE_CACHE_BYPASS;
     }
 
     switch (access & PAGE_CACHE_MASK) {
     case PAGE_CACHE_WB:
         atomctl >>= 2;
-        /* fall through */
+        fallthrough;
     case PAGE_CACHE_WT:
         atomctl >>= 2;
-        /* fall through */
+        fallthrough;
     case PAGE_CACHE_BYPASS:
         if ((atomctl & 0x3) == 0) {
             HELPER(exception_cause_vaddr)(env, pc,
                     LOAD_STORE_ERROR_CAUSE, vaddr);
         }
         break;
 
     case PAGE_CACHE_ISOLATE:
         HELPER(exception_cause_vaddr)(env, pc,
                 LOAD_STORE_ERROR_CAUSE, vaddr);
         break;
 
     default:
         break;
     }
 }
@@ -132,41 +132,41 @@ void HELPER(check_atomctl)(CPUXtensaState *env, uint32_t pc, uint32_t vaddr)
 void HELPER(check_exclusive)(CPUXtensaState *env, uint32_t pc, uint32_t vaddr,
                              uint32_t is_write)
 {
     uint32_t paddr, page_size, access;
     uint32_t atomctl = env->sregs[ATOMCTL];
     int rc = xtensa_get_physical_addr(env, true, vaddr, is_write,
                                       xtensa_get_cring(env), &paddr,
                                       &page_size, &access);
 
     if (rc) {
         HELPER(exception_cause_vaddr)(env, pc, rc, vaddr);
     }
 
     /* When data cache is not configured use ATOMCTL bypass field. */
     if (!xtensa_option_enabled(env->config, XTENSA_OPTION_DCACHE)) {
         access = PAGE_CACHE_BYPASS;
     }
 
     switch (access & PAGE_CACHE_MASK) {
     case PAGE_CACHE_WB:
         atomctl >>= 2;
-        /* fall through */
+        fallthrough;
     case PAGE_CACHE_WT:
         atomctl >>= 2;
-        /* fall through */
+        fallthrough;
     case PAGE_CACHE_BYPASS:
         if ((atomctl & 0x3) == 0) {
             HELPER(exception_cause_vaddr)(env, pc,
                                           EXCLUSIVE_ERROR_CAUSE, vaddr);
         }
         break;
 
     case PAGE_CACHE_ISOLATE:
         HELPER(exception_cause_vaddr)(env, pc,
                 LOAD_STORE_ERROR_CAUSE, vaddr);
         break;
 
     default:
         break;
     }
 }
target/xtensa/translate.c +1 -1
index 54bee7ddba..8ef940933c 100644
@@ -795,24 +795,24 @@ again:
 static void opcode_add_resource(struct slot_prop *op,
                                 uint32_t resource, char direction,
                                 int index)
 {
     switch (direction) {
     case 'm':
     case 'i':
         assert(op->n_in < ARRAY_SIZE(op->in));
         op->in[op->n_in].resource = resource;
         op->in[op->n_in].index = index;
         ++op->n_in;
-        /* fall through */
+        fallthrough;
     case 'o':
         if (direction == 'm' || direction == 'o') {
             assert(op->n_out < ARRAY_SIZE(op->out));
             op->out[op->n_out].resource = resource;
             op->out[op->n_out].index = index;
             ++op->n_out;
         }
         break;
     default:
         g_assert_not_reached();
     }
 }
Signature · 1 line
2.39.2
#65 lore raw

RFC PATCH v2 55/78 hw/display: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/display/cg3.c        | 2 +-
 hw/display/cirrus_vga.c | 2 +-
 hw/display/tcx.c        | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)
hw/display/cg3.c +1 -1
index 2e9656ae1c..53eb9831b2 100644
@@ -199,65 +199,65 @@ static uint64_t cg3_reg_read(void *opaque, hwaddr addr, unsigned size)
 static void cg3_reg_write(void *opaque, hwaddr addr, uint64_t val,
                           unsigned size)
 {
     CG3State *s = opaque;
     uint8_t regval;
     int i;
 
     trace_cg3_write(addr, val, size);
     switch (addr) {
     case CG3_REG_BT458_ADDR:
         s->dac_index = val;
         s->dac_state = 0;
         break;
     case CG3_REG_BT458_COLMAP:
         /* This register can be written to as either a long word or a byte */
         if (size == 1) {
             val <<= 24;
         }
 
         for (i = 0; i < size; i++) {
             regval = val >> 24;
 
             switch (s->dac_state) {
             case 0:
                 s->r[s->dac_index] = regval;
                 s->dac_state++;
                 break;
             case 1:
                 s->g[s->dac_index] = regval;
                 s->dac_state++;
                 break;
             case 2:
                 s->b[s->dac_index] = regval;
                 /* Index autoincrement */
                 s->dac_index = (s->dac_index + 1) & 0xff;
-                /* fall through */
+                fallthrough;
             default:
                 s->dac_state = 0;
                 break;
             }
             val <<= 8;
         }
         s->full_update = 1;
         break;
     case CG3_REG_FBC_CTRL:
         s->regs[0] = val;
         break;
     case CG3_REG_FBC_STATUS:
         if (s->regs[1] & CG3_SR_PENDING_INT) {
             /* clear interrupt */
             s->regs[1] &= ~CG3_SR_PENDING_INT;
             qemu_irq_lower(s->irq);
         }
         break;
     case CG3_REG_FBC_CURSTART ... CG3_REG_SIZE - 1:
         s->regs[addr - 0x10] = val;
         break;
     default:
         qemu_log_mask(LOG_UNIMP,
                   "cg3: Unimplemented register write "
                   "reg 0x%" HWADDR_PRIx " size 0x%x value 0x%" PRIx64 "\n",
                   addr, size, val);
         break;
     }
 }
hw/display/cirrus_vga.c +1 -1
index b80f98b6c4..f1513a084c 100644
@@ -1319,97 +1319,97 @@ static int cirrus_vga_read_sr(CirrusVGAState * s)
 static void cirrus_vga_write_sr(CirrusVGAState * s, uint32_t val)
 {
     switch (s->vga.sr_index) {
     case 0x00:                  // Standard VGA
     case 0x01:                  // Standard VGA
     case 0x02:                  // Standard VGA
     case 0x03:                  // Standard VGA
     case 0x04:                  // Standard VGA
         s->vga.sr[s->vga.sr_index] = val & sr_mask[s->vga.sr_index];
         if (s->vga.sr_index == 1)
             s->vga.update_retrace_info(&s->vga);
         break;
     case 0x06:                  // Unlock Cirrus extensions
         val &= 0x17;
         if (val == 0x12) {
             s->vga.sr[s->vga.sr_index] = 0x12;
         } else {
             s->vga.sr[s->vga.sr_index] = 0x0f;
         }
         break;
     case 0x10:
     case 0x30:
     case 0x50:
     case 0x70:                  // Graphics Cursor X
     case 0x90:
     case 0xb0:
     case 0xd0:
     case 0xf0:                  // Graphics Cursor X
         s->vga.sr[0x10] = val;
         s->vga.hw_cursor_x = (val << 3) | (s->vga.sr_index >> 5);
         break;
     case 0x11:
     case 0x31:
     case 0x51:
     case 0x71:                  // Graphics Cursor Y
     case 0x91:
     case 0xb1:
     case 0xd1:
     case 0xf1:                  // Graphics Cursor Y
         s->vga.sr[0x11] = val;
         s->vga.hw_cursor_y = (val << 3) | (s->vga.sr_index >> 5);
         break;
     case 0x07:                  // Extended Sequencer Mode
         cirrus_update_memory_access(s);
-        /* fall through */
+        fallthrough;
     case 0x08:                  // EEPROM Control
     case 0x09:                  // Scratch Register 0
     case 0x0a:                  // Scratch Register 1
     case 0x0b:                  // VCLK 0
     case 0x0c:                  // VCLK 1
     case 0x0d:                  // VCLK 2
     case 0x0e:                  // VCLK 3
     case 0x0f:                  // DRAM Control
     case 0x13:                  // Graphics Cursor Pattern Address
     case 0x14:                  // Scratch Register 2
     case 0x15:                  // Scratch Register 3
     case 0x16:                  // Performance Tuning Register
     case 0x18:                  // Signature Generator Control
     case 0x19:                  // Signature Generator Result
     case 0x1a:                  // Signature Generator Result
     case 0x1b:                  // VCLK 0 Denominator & Post
     case 0x1c:                  // VCLK 1 Denominator & Post
     case 0x1d:                  // VCLK 2 Denominator & Post
     case 0x1e:                  // VCLK 3 Denominator & Post
     case 0x1f:                  // BIOS Write Enable and MCLK select
         s->vga.sr[s->vga.sr_index] = val;
 #ifdef DEBUG_CIRRUS
         printf("cirrus: handled outport sr_index %02x, sr_value %02x\n",
                s->vga.sr_index, val);
 #endif
         break;
     case 0x12:                  // Graphics Cursor Attribute
         s->vga.sr[0x12] = val;
         s->vga.force_shadow = !!(val & CIRRUS_CURSOR_SHOW);
 #ifdef DEBUG_CIRRUS
         printf("cirrus: cursor ctl SR12=%02x (force shadow: %d)\n",
                val, s->vga.force_shadow);
 #endif
         break;
     case 0x17:                  // Configuration Readback and Extended Control
         s->vga.sr[s->vga.sr_index] = (s->vga.sr[s->vga.sr_index] & 0x38)
                                    | (val & 0xc7);
         cirrus_update_memory_access(s);
         break;
     default:
         qemu_log_mask(LOG_GUEST_ERROR,
                       "cirrus: outport sr_index 0x%02x, sr_value 0x%02x\n",
                       s->vga.sr_index, val);
         break;
     }
 }
 
 /***************************************
  *
  *  I/O access at 0x3c6
  *
  ***************************************/
hw/display/tcx.c +2 -2
index 1b27b64f6d..e21450d726 100644
@@ -381,26 +381,26 @@ static void tcx_reset(DeviceState *d)
 static uint64_t tcx_dac_readl(void *opaque, hwaddr addr,
                               unsigned size)
 {
     TCXState *s = opaque;
     uint32_t val = 0;
 
     switch (s->dac_state) {
     case 0:
         val = s->r[s->dac_index] << 24;
         s->dac_state++;
         break;
     case 1:
         val = s->g[s->dac_index] << 24;
         s->dac_state++;
         break;
     case 2:
         val = s->b[s->dac_index] << 24;
         s->dac_index = (s->dac_index + 1) & 0xff; /* Index autoincrement */
-        /* fall through */
+        fallthrough;
     default:
         s->dac_state = 0;
         break;
     }
 
     return val;
 }
@@ -408,43 +408,43 @@ static uint64_t tcx_dac_readl(void *opaque, hwaddr addr,
 static void tcx_dac_writel(void *opaque, hwaddr addr, uint64_t val,
                            unsigned size)
 {
     TCXState *s = opaque;
     unsigned index;
 
     switch (addr) {
     case 0: /* Address */
         s->dac_index = val >> 24;
         s->dac_state = 0;
         break;
     case 4:  /* Pixel colours */
     case 12: /* Overlay (cursor) colours */
         if (addr & 8) {
             index = (s->dac_index & 3) + 256;
         } else {
             index = s->dac_index;
         }
         switch (s->dac_state) {
         case 0:
             s->r[index] = val >> 24;
             update_palette_entries(s, index, index + 1);
             s->dac_state++;
             break;
         case 1:
             s->g[index] = val >> 24;
             update_palette_entries(s, index, index + 1);
             s->dac_state++;
             break;
         case 2:
             s->b[index] = val >> 24;
             update_palette_entries(s, index, index + 1);
             s->dac_index = (s->dac_index + 1) & 0xff; /* Index autoincrement */
-            /* fall through */
+            fallthrough;
         default:
             s->dac_state = 0;
             break;
         }
         break;
     default: /* Control registers */
         break;
     }
 }
Signature · 1 line
2.39.2
#72 lore raw

RFC PATCH v2 60/78 qga: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 qga/main.c                  | 2 +-
 qga/vss-win32/requester.cpp | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
qga/main.c +1 -1
index 8668b9f3d3..40471e8a0b 100644
@@ -644,37 +644,37 @@ end:
 /* false return signals GAChannel to close the current client connection */
 static gboolean channel_event_cb(GIOCondition condition, gpointer data)
 {
     GAState *s = data;
     gchar buf[QGA_READ_COUNT_DEFAULT + 1];
     gsize count;
     GIOStatus status = ga_channel_read(s->channel, buf, QGA_READ_COUNT_DEFAULT, &count);
     switch (status) {
     case G_IO_STATUS_ERROR:
         g_warning("error reading channel");
         stop_agent(s, false);
         return false;
     case G_IO_STATUS_NORMAL:
         buf[count] = 0;
         g_debug("read data, count: %d, data: %s", (int)count, buf);
         json_message_parser_feed(&s->parser, (char *)buf, (int)count);
         break;
     case G_IO_STATUS_EOF:
         g_debug("received EOF");
         if (!s->virtio) {
             return false;
         }
-        /* fall through */
+        fallthrough;
     case G_IO_STATUS_AGAIN:
         /* virtio causes us to spin here when no process is attached to
          * host-side chardev. sleep a bit to mitigate this
          */
         if (s->virtio) {
             g_usleep(G_USEC_PER_SEC / 10);
         }
         return true;
     default:
         g_warning("unknown channel read status, closing");
         return false;
     }
     return true;
 }
qga/vss-win32/requester.cpp +1 -0
index 9884c65e70..36fa4fdf28 100644
@@ -563,72 +563,73 @@ out1:
 void requester_thaw(int *num_vols, void *mountpints, ErrorSet *errset)
 {
     qga_debug_begin;
     COMPointer<IVssAsync> pAsync;
 
     if (!vss_ctx.hEventThaw) {
         /*
          * In this case, DoSnapshotSet is aborted or not started,
          * and no volumes must be frozen. We return without an error.
          */
         *num_vols = 0;
         qga_debug("finished, no volumes were frozen");
 
         return;
     }
 
     /* Tell the provider that the snapshot is finished. */
     SetEvent(vss_ctx.hEventThaw);
 
     assert(vss_ctx.pVssbc);
     assert(vss_ctx.pAsyncSnapshot);
 
     HRESULT hr = WaitForAsync(vss_ctx.pAsyncSnapshot);
     switch (hr) {
     case VSS_S_ASYNC_FINISHED:
         hr = vss_ctx.pVssbc->BackupComplete(pAsync.replace());
         if (SUCCEEDED(hr)) {
             hr = WaitForAsync(pAsync);
         }
         if (FAILED(hr)) {
             err_set(errset, hr, "failed to complete backup");
         }
         break;
 
     case (HRESULT)VSS_E_OBJECT_NOT_FOUND:
         /*
          * On Windows earlier than 2008 SP2 which does not support
          * VSS_VOLSNAP_ATTR_NO_AUTORECOVERY context, the final commit is not
          * skipped and VSS is aborted by VSS_E_OBJECT_NOT_FOUND. However, as
          * the system had been frozen until fsfreeze-thaw command was issued,
          * we ignore this error.
          */
         vss_ctx.pVssbc->AbortBackup();
         break;
 
     case VSS_E_UNEXPECTED_PROVIDER_ERROR:
         if (WaitForSingleObject(vss_ctx.hEventTimeout, 0) != WAIT_OBJECT_0) {
             err_set(errset, hr, "unexpected error in VSS provider");
             break;
         }
         /* fall through if hEventTimeout is signaled */
+        fallthrough;
 
     case (HRESULT)VSS_E_HOLD_WRITES_TIMEOUT:
         err_set(errset, hr, "couldn't hold writes: "
                 "fsfreeze is limited up to 10 seconds");
         break;
 
     default:
         err_set(errset, hr, "failed to do snapshot set");
     }
 
     if (err_is_set(errset)) {
         vss_ctx.pVssbc->AbortBackup();
     }
     *num_vols = vss_ctx.cFrozenVols;
     requester_cleanup();
 
     CoUninitialize();
     StopService();
 
     qga_debug_end;
 }
Signature · 1 line
2.39.2
#55 lore raw

RFC PATCH v2 45/78 hw/dma: add fallthrough pseudo-keyword

In reply to Emmanouil Pitsidianakis

In preparation of raising -Wimplicit-fallthrough to 5, replace all fall-through comments with the fallthrough attribute pseudo-keyword.

---
 hw/dma/omap_dma.c    | 32 ++++++++++++++++----------------
 hw/dma/pxa2xx_dma.c  |  4 ++--
 hw/dma/sparc32_dma.c |  2 +-
 3 files changed, 19 insertions(+), 19 deletions(-)
hw/dma/omap_dma.c +16 -16
index 77797a67b5..dd43dbf3d2 100644
@@ -1457,46 +1457,46 @@ static int omap_dma_sys_read(struct omap_dma_s *s, int offset,
 static uint64_t omap_dma_read(void *opaque, hwaddr addr, unsigned size)
 {
     struct omap_dma_s *s = opaque;
     int reg, ch;
     uint16_t ret;
 
     if (size != 2) {
         return omap_badwidth_read16(opaque, addr);
     }
 
     switch (addr) {
     case 0x300 ... 0x3fe:
         if (s->model <= omap_dma_3_1 || !s->omap_3_1_mapping_disabled) {
             if (omap_dma_3_1_lcd_read(&s->lcd_ch, addr, &ret))
                 break;
             return ret;
         }
-        /* Fall through. */
+        fallthrough;
     case 0x000 ... 0x2fe:
         reg = addr & 0x3f;
         ch = (addr >> 6) & 0x0f;
         if (omap_dma_ch_reg_read(s, &s->ch[ch], reg, &ret))
             break;
         return ret;
 
     case 0x404 ... 0x4fe:
         if (s->model <= omap_dma_3_1)
             break;
-        /* Fall through. */
+        fallthrough;
     case 0x400:
         if (omap_dma_sys_read(s, addr, &ret))
             break;
         return ret;
 
     case 0xb00 ... 0xbfe:
         if (s->model == omap_dma_3_2 && s->omap_3_1_mapping_disabled) {
             if (omap_dma_3_2_lcd_read(&s->lcd_ch, addr, &ret))
                 break;
             return ret;
         }
         break;
     }
 
     OMAP_BAD_REG(addr);
     return 0;
 }
@@ -1504,46 +1504,46 @@ static uint64_t omap_dma_read(void *opaque, hwaddr addr, unsigned size)
 static void omap_dma_write(void *opaque, hwaddr addr,
                            uint64_t value, unsigned size)
 {
     struct omap_dma_s *s = opaque;
     int reg, ch;
 
     if (size != 2) {
         omap_badwidth_write16(opaque, addr, value);
         return;
     }
 
     switch (addr) {
     case 0x300 ... 0x3fe:
         if (s->model <= omap_dma_3_1 || !s->omap_3_1_mapping_disabled) {
             if (omap_dma_3_1_lcd_write(&s->lcd_ch, addr, value))
                 break;
             return;
         }
-        /* Fall through.  */
+        fallthrough;
     case 0x000 ... 0x2fe:
         reg = addr & 0x3f;
         ch = (addr >> 6) & 0x0f;
         if (omap_dma_ch_reg_write(s, &s->ch[ch], reg, value))
             break;
         return;
 
     case 0x404 ... 0x4fe:
         if (s->model <= omap_dma_3_1)
             break;
-        /* fall through */
+        fallthrough;
     case 0x400:
         if (omap_dma_sys_write(s, addr, value))
             break;
         return;
 
     case 0xb00 ... 0xbfe:
         if (s->model == omap_dma_3_2 && s->omap_3_1_mapping_disabled) {
             if (omap_dma_3_2_lcd_write(&s->lcd_ch, addr, value))
                 break;
             return;
         }
         break;
     }
 
     OMAP_BAD_REG(addr);
 }
@@ -1702,155 +1702,155 @@ static void omap_dma_interrupts_4_update(struct omap_dma_s *s)
 static uint64_t omap_dma4_read(void *opaque, hwaddr addr,
                                unsigned size)
 {
     struct omap_dma_s *s = opaque;
     int irqn = 0, chnum;
     struct omap_dma_channel_s *ch;
 
     if (size == 1) {
         return omap_badwidth_read16(opaque, addr);
     }
 
     switch (addr) {
     case 0x00:	/* DMA4_REVISION */
         return 0x40;
 
     case 0x14:	/* DMA4_IRQSTATUS_L3 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x10:	/* DMA4_IRQSTATUS_L2 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x0c:	/* DMA4_IRQSTATUS_L1 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x08:	/* DMA4_IRQSTATUS_L0 */
         return s->irqstat[irqn];
 
     case 0x24:	/* DMA4_IRQENABLE_L3 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x20:	/* DMA4_IRQENABLE_L2 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x1c:	/* DMA4_IRQENABLE_L1 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x18:	/* DMA4_IRQENABLE_L0 */
         return s->irqen[irqn];
 
     case 0x28:	/* DMA4_SYSSTATUS */
         return 1;						/* RESETDONE */
 
     case 0x2c:	/* DMA4_OCP_SYSCONFIG */
         return s->ocp;
 
     case 0x64:	/* DMA4_CAPS_0 */
         return s->caps[0];
     case 0x6c:	/* DMA4_CAPS_2 */
         return s->caps[2];
     case 0x70:	/* DMA4_CAPS_3 */
         return s->caps[3];
     case 0x74:	/* DMA4_CAPS_4 */
         return s->caps[4];
 
     case 0x78:	/* DMA4_GCR */
         return s->gcr;
 
     case 0x80 ... 0xfff:
         addr -= 0x80;
         chnum = addr / 0x60;
         ch = s->ch + chnum;
         addr -= chnum * 0x60;
         break;
 
     default:
         OMAP_BAD_REG(addr);
         return 0;
     }
 
     /* Per-channel registers */
     switch (addr) {
     case 0x00:	/* DMA4_CCR */
         return (ch->buf_disable << 25) |
                 (ch->src_sync << 24) |
                 (ch->prefetch << 23) |
                 ((ch->sync & 0x60) << 14) |
                 (ch->bs << 18) |
                 (ch->transparent_copy << 17) |
                 (ch->constant_fill << 16) |
                 (ch->mode[1] << 14) |
                 (ch->mode[0] << 12) |
                 (0 << 10) | (0 << 9) |
                 (ch->suspend << 8) |
                 (ch->enable << 7) |
                 (ch->priority << 6) |
                 (ch->fs << 5) | (ch->sync & 0x1f);
 
     case 0x04:	/* DMA4_CLNK_CTRL */
         return (ch->link_enabled << 15) | ch->link_next_ch;
 
     case 0x08:	/* DMA4_CICR */
         return ch->interrupts;
 
     case 0x0c:	/* DMA4_CSR */
         return ch->cstatus;
 
     case 0x10:	/* DMA4_CSDP */
         return (ch->endian[0] << 21) |
                 (ch->endian_lock[0] << 20) |
                 (ch->endian[1] << 19) |
                 (ch->endian_lock[1] << 18) |
                 (ch->write_mode << 16) |
                 (ch->burst[1] << 14) |
                 (ch->pack[1] << 13) |
                 (ch->translate[1] << 9) |
                 (ch->burst[0] << 7) |
                 (ch->pack[0] << 6) |
                 (ch->translate[0] << 2) |
                 (ch->data_type >> 1);
 
     case 0x14:	/* DMA4_CEN */
         return ch->elements;
 
     case 0x18:	/* DMA4_CFN */
         return ch->frames;
 
     case 0x1c:	/* DMA4_CSSA */
         return ch->addr[0];
 
     case 0x20:	/* DMA4_CDSA */
         return ch->addr[1];
 
     case 0x24:	/* DMA4_CSEI */
         return ch->element_index[0];
 
     case 0x28:	/* DMA4_CSFI */
         return ch->frame_index[0];
 
     case 0x2c:	/* DMA4_CDEI */
         return ch->element_index[1];
 
     case 0x30:	/* DMA4_CDFI */
         return ch->frame_index[1];
 
     case 0x34:	/* DMA4_CSAC */
         return ch->active_set.src & 0xffff;
 
     case 0x38:	/* DMA4_CDAC */
         return ch->active_set.dest & 0xffff;
 
     case 0x3c:	/* DMA4_CCEN */
         return ch->active_set.element;
 
     case 0x40:	/* DMA4_CCFN */
         return ch->active_set.frame;
 
     case 0x44:	/* DMA4_COLOR */
         /* XXX only in sDMA */
         return ch->color;
 
     default:
         OMAP_BAD_REG(addr);
         return 0;
     }
 }
@@ -1858,213 +1858,213 @@ static uint64_t omap_dma4_read(void *opaque, hwaddr addr,
 static void omap_dma4_write(void *opaque, hwaddr addr,
                             uint64_t value, unsigned size)
 {
     struct omap_dma_s *s = opaque;
     int chnum, irqn = 0;
     struct omap_dma_channel_s *ch;
 
     if (size == 1) {
         omap_badwidth_write16(opaque, addr, value);
         return;
     }
 
     switch (addr) {
     case 0x14:	/* DMA4_IRQSTATUS_L3 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x10:	/* DMA4_IRQSTATUS_L2 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x0c:	/* DMA4_IRQSTATUS_L1 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x08:	/* DMA4_IRQSTATUS_L0 */
         s->irqstat[irqn] &= ~value;
         if (!s->irqstat[irqn])
             qemu_irq_lower(s->irq[irqn]);
         return;
 
     case 0x24:	/* DMA4_IRQENABLE_L3 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x20:	/* DMA4_IRQENABLE_L2 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x1c:	/* DMA4_IRQENABLE_L1 */
         irqn ++;
-        /* fall through */
+        fallthrough;
     case 0x18:	/* DMA4_IRQENABLE_L0 */
         s->irqen[irqn] = value;
         return;
 
     case 0x2c:	/* DMA4_OCP_SYSCONFIG */
         if (value & 2)						/* SOFTRESET */
             omap_dma_reset(s->dma);
         s->ocp = value & 0x3321;
         if (((s->ocp >> 12) & 3) == 3) { /* MIDLEMODE */
             qemu_log_mask(LOG_GUEST_ERROR, "%s: invalid DMA power mode\n",
                           __func__);
         }
         return;
 
     case 0x78:	/* DMA4_GCR */
         s->gcr = value & 0x00ff00ff;
         if ((value & 0xff) == 0x00) { /* MAX_CHANNEL_FIFO_DEPTH */
             qemu_log_mask(LOG_GUEST_ERROR, "%s: wrong FIFO depth in GCR\n",
                           __func__);
         }
         return;
 
     case 0x80 ... 0xfff:
         addr -= 0x80;
         chnum = addr / 0x60;
         ch = s->ch + chnum;
         addr -= chnum * 0x60;
         break;
 
     case 0x00:	/* DMA4_REVISION */
     case 0x28:	/* DMA4_SYSSTATUS */
     case 0x64:	/* DMA4_CAPS_0 */
     case 0x6c:	/* DMA4_CAPS_2 */
     case 0x70:	/* DMA4_CAPS_3 */
     case 0x74:	/* DMA4_CAPS_4 */
         OMAP_RO_REG(addr);
         return;
 
     default:
         OMAP_BAD_REG(addr);
         return;
     }
 
     /* Per-channel registers */
     switch (addr) {
     case 0x00:	/* DMA4_CCR */
         ch->buf_disable = (value >> 25) & 1;
         ch->src_sync = (value >> 24) & 1;	/* XXX For CamDMA must be 1 */
         if (ch->buf_disable && !ch->src_sync) {
             qemu_log_mask(LOG_GUEST_ERROR,
                           "%s: Buffering disable is not allowed in "
                           "destination synchronised mode\n", __func__);
         }
         ch->prefetch = (value >> 23) & 1;
         ch->bs = (value >> 18) & 1;
         ch->transparent_copy = (value >> 17) & 1;
         ch->constant_fill = (value >> 16) & 1;
         ch->mode[1] = (omap_dma_addressing_t) ((value & 0xc000) >> 14);
         ch->mode[0] = (omap_dma_addressing_t) ((value & 0x3000) >> 12);
         ch->suspend = (value & 0x0100) >> 8;
         ch->priority = (value & 0x0040) >> 6;
         ch->fs = (value & 0x0020) >> 5;
         if (ch->fs && ch->bs && ch->mode[0] && ch->mode[1]) {
             qemu_log_mask(LOG_GUEST_ERROR,
                           "%s: For a packet transfer at least one port "
                           "must be constant-addressed\n", __func__);
         }
         ch->sync = (value & 0x001f) | ((value >> 14) & 0x0060);
         /* XXX must be 0x01 for CamDMA */
 
         if (value & 0x0080)
             omap_dma_enable_channel(s, ch);
         else
             omap_dma_disable_channel(s, ch);
 
         break;
 
     case 0x04:	/* DMA4_CLNK_CTRL */
         ch->link_enabled = (value >> 15) & 0x1;
         ch->link_next_ch = value & 0x1f;
         break;
 
     case 0x08:	/* DMA4_CICR */
         ch->interrupts = value & 0x09be;
         break;
 
     case 0x0c:	/* DMA4_CSR */
         ch->cstatus &= ~value;
         break;
 
     case 0x10:	/* DMA4_CSDP */
         ch->endian[0] =(value >> 21) & 1;
         ch->endian_lock[0] =(value >> 20) & 1;
         ch->endian[1] =(value >> 19) & 1;
         ch->endian_lock[1] =(value >> 18) & 1;
         if (ch->endian[0] != ch->endian[1]) {
             qemu_log_mask(LOG_GUEST_ERROR,
                           "%s: DMA endianness conversion enable attempt\n",
                           __func__);
         }
         ch->write_mode = (value >> 16) & 3;
         ch->burst[1] = (value & 0xc000) >> 14;
         ch->pack[1] = (value & 0x2000) >> 13;
         ch->translate[1] = (value & 0x1e00) >> 9;
         ch->burst[0] = (value & 0x0180) >> 7;
         ch->pack[0] = (value & 0x0040) >> 6;
         ch->translate[0] = (value & 0x003c) >> 2;
         if (ch->translate[0] | ch->translate[1]) {
             qemu_log_mask(LOG_GUEST_ERROR,
                           "%s: bad MReqAddressTranslate sideband signal\n",
                           __func__);
         }
         ch->data_type = 1 << (value & 3);
         if ((value & 3) == 3) {
             qemu_log_mask(LOG_GUEST_ERROR,
                           "%s: bad data_type for DMA channel\n", __func__);
             ch->data_type >>= 1;
         }
         break;
 
     case 0x14:	/* DMA4_CEN */
         ch->set_update = 1;
         ch->elements = value & 0xffffff;
         break;
 
     case 0x18:	/* DMA4_CFN */
         ch->frames = value & 0xffff;
         ch->set_update = 1;
         break;
 
     case 0x1c:	/* DMA4_CSSA */
         ch->addr[0] = (hwaddr) (uint32_t) value;
         ch->set_update = 1;
         break;
 
     case 0x20:	/* DMA4_CDSA */
         ch->addr[1] = (hwaddr) (uint32_t) value;
         ch->set_update = 1;
         break;
 
     case 0x24:	/* DMA4_CSEI */
         ch->element_index[0] = (int16_t) value;
         ch->set_update = 1;
         break;
 
     case 0x28:	/* DMA4_CSFI */
         ch->frame_index[0] = (int32_t) value;
         ch->set_update = 1;
         break;
 
     case 0x2c:	/* DMA4_CDEI */
         ch->element_index[1] = (int16_t) value;
         ch->set_update = 1;
         break;
 
     case 0x30:	/* DMA4_CDFI */
         ch->frame_index[1] = (int32_t) value;
         ch->set_update = 1;
         break;
 
     case 0x44:	/* DMA4_COLOR */
         /* XXX only in sDMA */
         ch->color = value;
         break;
 
     case 0x34:	/* DMA4_CSAC */
     case 0x38:	/* DMA4_CDAC */
     case 0x3c:	/* DMA4_CCEN */
     case 0x40:	/* DMA4_CCFN */
         OMAP_RO_REG(addr);
         break;
 
     default:
         OMAP_BAD_REG(addr);
     }
 }
hw/dma/pxa2xx_dma.c +2 -2
index fa896f7edf..ac47256572 100644
@@ -266,59 +266,59 @@ static void pxa2xx_dma_run(PXA2xxDMAState *s)
 static uint64_t pxa2xx_dma_read(void *opaque, hwaddr offset,
                                 unsigned size)
 {
     PXA2xxDMAState *s = (PXA2xxDMAState *) opaque;
     unsigned int channel;
 
     if (size != 4) {
         qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad access width %u\n",
                       __func__, size);
         return 5;
     }
 
     switch (offset) {
     case DRCMR64 ... DRCMR74:
         offset -= DRCMR64 - DRCMR0 - (64 << 2);
-        /* Fall through */
+        fallthrough;
     case DRCMR0 ... DRCMR63:
         channel = (offset - DRCMR0) >> 2;
         return s->req[channel];
 
     case DRQSR0:
     case DRQSR1:
     case DRQSR2:
         return 0;
 
     case DCSR0 ... DCSR31:
         channel = offset >> 2;
         if (s->chan[channel].request)
             return s->chan[channel].state | DCSR_REQPEND;
         return s->chan[channel].state;
 
     case DINT:
         return s->stopintr | s->eorintr | s->rasintr |
                 s->startintr | s->endintr;
 
     case DALGN:
         return s->align;
 
     case DPCSR:
         return s->pio;
     }
 
     if (offset >= D_CH0 && offset < D_CH0 + (s->channels << 4)) {
         channel = (offset - D_CH0) >> 4;
         switch ((offset & 0x0f) >> 2) {
         case DDADR:
             return s->chan[channel].descr;
         case DSADR:
             return s->chan[channel].src;
         case DTADR:
             return s->chan[channel].dest;
         case DCMD:
             return s->chan[channel].cmd;
         }
     }
     qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIX "\n",
                   __func__, offset);
     return 7;
 }
@@ -326,105 +326,105 @@ static uint64_t pxa2xx_dma_read(void *opaque, hwaddr offset,
 static void pxa2xx_dma_write(void *opaque, hwaddr offset,
                              uint64_t value, unsigned size)
 {
     PXA2xxDMAState *s = (PXA2xxDMAState *) opaque;
     unsigned int channel;
 
     if (size != 4) {
         qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad access width %u\n",
                       __func__, size);
         return;
     }
 
     switch (offset) {
     case DRCMR64 ... DRCMR74:
         offset -= DRCMR64 - DRCMR0 - (64 << 2);
-        /* Fall through */
+        fallthrough;
     case DRCMR0 ... DRCMR63:
         channel = (offset - DRCMR0) >> 2;
 
         if (value & DRCMR_MAPVLD)
             if ((value & DRCMR_CHLNUM) > s->channels)
                 hw_error("%s: Bad DMA channel %i\n",
                          __func__, (unsigned)value & DRCMR_CHLNUM);
 
         s->req[channel] = value;
         break;
 
     case DRQSR0:
     case DRQSR1:
     case DRQSR2:
         /* Nothing to do */
         break;
 
     case DCSR0 ... DCSR31:
         channel = offset >> 2;
         s->chan[channel].state &= 0x0000071f & ~(value &
                         (DCSR_EORINT | DCSR_ENDINTR |
                          DCSR_STARTINTR | DCSR_BUSERRINTR));
         s->chan[channel].state |= value & 0xfc800000;
 
         if (s->chan[channel].state & DCSR_STOPIRQEN)
             s->chan[channel].state &= ~DCSR_STOPINTR;
 
         if (value & DCSR_NODESCFETCH) {
             /* No-descriptor-fetch mode */
             if (value & DCSR_RUN) {
                 s->chan[channel].state &= ~DCSR_STOPINTR;
                 pxa2xx_dma_run(s);
             }
         } else {
             /* Descriptor-fetch mode */
             if (value & DCSR_RUN) {
                 s->chan[channel].state &= ~DCSR_STOPINTR;
                 pxa2xx_dma_descriptor_fetch(s, channel);
                 pxa2xx_dma_run(s);
             }
         }
 
         /* Shouldn't matter as our DMA is synchronous.  */
         if (!(value & (DCSR_RUN | DCSR_MASKRUN)))
             s->chan[channel].state |= DCSR_STOPINTR;
 
         if (value & DCSR_CLRCMPST)
             s->chan[channel].state &= ~DCSR_CMPST;
         if (value & DCSR_SETCMPST)
             s->chan[channel].state |= DCSR_CMPST;
 
         pxa2xx_dma_update(s, channel);
         break;
 
     case DALGN:
         s->align = value;
         break;
 
     case DPCSR:
         s->pio = value & 0x80000001;
         break;
 
     default:
         if (offset >= D_CH0 && offset < D_CH0 + (s->channels << 4)) {
             channel = (offset - D_CH0) >> 4;
             switch ((offset & 0x0f) >> 2) {
             case DDADR:
                 s->chan[channel].descr = value;
                 break;
             case DSADR:
                 s->chan[channel].src = value;
                 break;
             case DTADR:
                 s->chan[channel].dest = value;
                 break;
             case DCMD:
                 s->chan[channel].cmd = value;
                 break;
             default:
                 goto fail;
             }
 
             break;
         }
     fail:
         qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%" HWADDR_PRIX "\n",
                       __func__, offset);
     }
 }
hw/dma/sparc32_dma.c +1 -1
index 0ef13c5e9a..c68e068cc9 100644
@@ -180,49 +180,49 @@ static uint64_t dma_mem_read(void *opaque, hwaddr addr,
 static void dma_mem_write(void *opaque, hwaddr addr,
                           uint64_t val, unsigned size)
 {
     DMADeviceState *s = opaque;
     uint32_t saddr;
 
     saddr = (addr & DMA_MASK) >> 2;
     trace_sparc32_dma_mem_writel(addr, s->dmaregs[saddr], val);
     switch (saddr) {
     case 0:
         if (val & DMA_INTREN) {
             if (s->dmaregs[0] & DMA_INTR) {
                 trace_sparc32_dma_set_irq_raise();
                 qemu_irq_raise(s->irq);
             }
         } else {
             if (s->dmaregs[0] & (DMA_INTR | DMA_INTREN)) {
                 trace_sparc32_dma_set_irq_lower();
                 qemu_irq_lower(s->irq);
             }
         }
         if (val & DMA_RESET) {
             qemu_irq_raise(s->gpio[GPIO_RESET]);
             qemu_irq_lower(s->gpio[GPIO_RESET]);
         } else if (val & DMA_DRAIN_FIFO) {
             val &= ~DMA_DRAIN_FIFO;
         } else if (val == 0)
             val = DMA_DRAIN_FIFO;
 
         if (val & DMA_EN && !(s->dmaregs[0] & DMA_EN)) {
             trace_sparc32_dma_enable_raise();
             qemu_irq_raise(s->gpio[GPIO_DMA]);
         } else if (!(val & DMA_EN) && !!(s->dmaregs[0] & DMA_EN)) {
             trace_sparc32_dma_enable_lower();
             qemu_irq_lower(s->gpio[GPIO_DMA]);
         }
 
         val &= ~DMA_CSR_RO_MASK;
         val |= DMA_VER;
         s->dmaregs[0] = (s->dmaregs[0] & DMA_CSR_RO_MASK) | val;
         break;
     case 1:
         s->dmaregs[0] |= DMA_LOADED;
-        /* fall through */
+        fallthrough;
     default:
         s->dmaregs[saddr] = val;
         break;
     }
 }
Signature · 1 line
2.39.2