From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6082ECDB482 for ; Fri, 13 Oct 2023 08:17:50 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qrDM4-0007B8-GC; Fri, 13 Oct 2023 04:17:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrDM3-000754-HE for qemu-devel@nongnu.org; Fri, 13 Oct 2023 04:17:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrDLy-0003HV-VH for qemu-devel@nongnu.org; Fri, 13 Oct 2023 04:17:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697185022; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=oZ+9BpEWe8kUM7nH7oDN+XJUYz+GIWx+MJDnPBDvgQo=; b=UTZnL8OVRSkAVJB2IY54xyRMtc4M98m+ltWzWycQj0N6TrL17QHX5Jc5BP8I79adzBxI2i gGXvkE3KnpHkkGgXLPuKtZ3gyb63jSDLBUpLONAin1uS7fryMBw2G/d4E4fqSkBXw0VYwo PJS3a8vnEHmGuHyTT/dJM94p+EMndk0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-672-x-nDDDzVO5KuB_SQ1OtkQQ-1; Fri, 13 Oct 2023 04:16:48 -0400 X-MC-Unique: x-nDDDzVO5KuB_SQ1OtkQQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A86E0185A797; Fri, 13 Oct 2023 08:16:47 +0000 (UTC) Received: from redhat.com (unknown [10.42.28.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A12325C1; Fri, 13 Oct 2023 08:16:44 +0000 (UTC) Date: Fri, 13 Oct 2023 09:16:43 +0100 From: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= To: Emmanouil Pitsidianakis Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org, Gerd Hoffmann , =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , Eric Auger , Peter Maydell , Song Gao , Xiaojuan Yang , Richard Henderson Subject: Re: [RFC PATCH 01/78] include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough Message-ID: References: <2e08cff874b2f9fc4143bdcde87ebba9b70b356c.1697183082.git.manos.pitsidianakis@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2e08cff874b2f9fc4143bdcde87ebba9b70b356c.1697183082.git.manos.pitsidianakis@linaro.org> User-Agent: Mutt/2.2.9 (2022-11-12) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 Received-SPF: pass client-ip=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Fri, Oct 13, 2023 at 10:47:05AM +0300, Emmanouil Pitsidianakis wrote: > Signed-off-by: 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(-) This patch (and all the others in the series) have a ridiculously large context either side of the change. It makes this horrible to review as it requires wading through pages of pre-existing code trying to spot the change. Please send patches with the default git context lines setting. > > diff --git a/audio/pwaudio.c b/audio/pwaudio.c > index 3ce5f6507b..bf26fadb06 100644 > --- a/audio/pwaudio.c > +++ b/audio/pwaudio.c > @@ -1,29 +1,29 @@ > /* > * QEMU PipeWire audio driver > * > * Copyright (c) 2023 Red Hat Inc. > * > * Author: Dorinda Bassey > * > * SPDX-License-Identifier: GPL-2.0-or-later > */ > > +#include > +#include > +#include > +#include > #include "qemu/osdep.h" > #include "qemu/module.h" > #include "audio.h" > #include > #include "qemu/error-report.h" > #include "qapi/error.h" > -#include > -#include > -#include > -#include > > #include > #include "trace.h" > > #define AUDIO_CAP "pipewire" > #define RINGBUFFER_SIZE (1u << 22) > #define RINGBUFFER_MASK (RINGBUFFER_SIZE - 1) > > #include "audio_int.h" > diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c > index 6f2b2bd45f..545d82ff04 100644 > --- a/hw/arm/smmuv3.c > +++ b/hw/arm/smmuv3.c > @@ -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; > } > diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h > index 1109482a00..959982805d 100644 > --- a/include/qemu/compiler.h > +++ b/include/qemu/compiler.h > @@ -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