From patchwork Fri Oct 13 07:56:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manos Pitsidianakis X-Patchwork-Id: 1847940 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=EqpNV0IO; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S6Jqd6D0bz1yqj for ; Fri, 13 Oct 2023 19:01:33 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qrD3e-0006Tz-Bp; Fri, 13 Oct 2023 03:58:06 -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 1qrD3b-00064o-MG for qemu-devel@nongnu.org; Fri, 13 Oct 2023 03:58:03 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrD3X-0006hl-OU for qemu-devel@nongnu.org; Fri, 13 Oct 2023 03:58:03 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-32157c8e4c7so1713738f8f.1 for ; Fri, 13 Oct 2023 00:57:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697183878; x=1697788678; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WLlr5rM7K7HFMOYaMZw1hwvaelBo6N2zKwQvcIMTzLA=; b=EqpNV0IOMpevn0k4fs+m4b7uO+D6EIE9+Js+S6qxmdtZJFvxROxzZwfas+2BHSphJp AOFG4qwx4rTHt1LysNkl/FqZK+PP5Fc1QvqD7Njabi8un7jKqQMiGJ8322wLKT8j01JZ Oa/eSqKjxg+3X2wgfCAbDJSQ72lJyhoMHR9DKbPyddJpQjXxqB9Wh+Q6tvRkYUr9dQYD +0ulbZoBwi7GxH8i8vQzU3Z9m2nYWHEeOZPf0iJcF12Hysvko0wvg0DplP2Nf3jdetiq J8f5zY7JCxmArmRHvoCYtMRE9d/4pnWx3p5Qk/m0b6CUVBA1tPvcCkgdY7ervBcwkNrj fgdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697183878; x=1697788678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WLlr5rM7K7HFMOYaMZw1hwvaelBo6N2zKwQvcIMTzLA=; b=MujzwdNJNAtHv8yxS2ThcFn1l+F+S9qBSu8sdjXbV+8obESb9XkY0kztOPnxpnpkLv 6K6PKCF1gmP+jHp7vdrkbLTvsFAkLhDPeOlg27iWqNfAftD0VHg+Mgnw5SmQT0KqmlHm Zsz37/tsy4sRZJV1oFv4ZPI0DjY0HgOepp7YAvn3/DIQjJMEQCAHvYpeH/rcrTOXfZzr 4+eZ56oVEnDAQgXzh+d4t7xr2GDj5bkM45SuIDJeukEhRq/0Hh1X2AJY1YJXdYyk8Yhh mFukiv4NHNWFi2zjkjn56mxcjxuuAVKWovJrp5JigW9kDWzODfbLEQg5TJLXvGHn75Tt wPQg== X-Gm-Message-State: AOJu0YwQjKgX/rKsL/bLx/gox465iMEDZPB+Eo+DHkcZIPXEMC3b61On r+9g3RrenkpG0eHR6fhskHKTT8hBcmCs9/5euho= X-Google-Smtp-Source: AGHT+IHchwvy/rd0Ea7Bn5Bwm/JnwU53pH4h9d+J+KpD1DYW5u7WCQRS4kIi1S3/w2QC+su7V3PxbA== X-Received: by 2002:adf:ed8c:0:b0:31f:9a0d:167f with SMTP id c12-20020adfed8c000000b0031f9a0d167fmr21287566wro.50.1697183877698; Fri, 13 Oct 2023 00:57:57 -0700 (PDT) Received: from localhost.localdomain (adsl-26.37.6.0.tellas.gr. [37.6.0.26]) by smtp.gmail.com with ESMTPSA id a10-20020a05600c224a00b003fe23b10fdfsm1798183wmm.36.2023.10.13.00.57.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 00:57:57 -0700 (PDT) From: Emmanouil Pitsidianakis To: qemu-devel@nongnu.org Cc: Emmanouil Pitsidianakis , Gerd Hoffmann , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Eric Auger , Peter Maydell , Song Gao , Xiaojuan Yang , Richard Henderson , qemu-arm@nongnu.org (open list:ARM SMMU) Subject: [RFC PATCH v2 01/78] include/qemu/compiler.h: replace QEMU_FALLTHROUGH with fallthrough Date: Fri, 13 Oct 2023 10:56:28 +0300 Message-Id: <2e08cff874b2f9fc4143bdcde87ebba9b70b356c.1697183699.git.manos.pitsidianakis@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wr1-x42c.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Emmanouil Pitsidianakis Acked-by: Eric Blake --- 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(-) 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