From patchwork Fri Oct 13 07:47:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manos Pitsidianakis X-Patchwork-Id: 1848063 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=gbokYzF5; 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 4S6KQ30bwDz1yqn for ; Fri, 13 Oct 2023 19:27:54 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qrCyA-00026U-To; Fri, 13 Oct 2023 03:52:27 -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 1qrCxL-00070N-8B for qemu-devel@nongnu.org; Fri, 13 Oct 2023 03:51:37 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qrCwy-00050D-JI for qemu-devel@nongnu.org; Fri, 13 Oct 2023 03:51:34 -0400 Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-3226cc3e324so1720635f8f.3 for ; Fri, 13 Oct 2023 00:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697183470; x=1697788270; 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=fHcUXIeVYL2J2IaeiQjIW4srz6zzb+o5NuSL2EwrB8I=; b=gbokYzF59VkVY+gvtFuqzRYFWudyqcG3wFlh871s6i/BrYS1IXhEYblHcGuCnp/F6F py7NCdCgXO80SQUAFBjfFy/xoNGnvsr+SQ9J5nadOKy1rvDpb3zRw2oUlJ5b/y4vG81A mrIu02oQyd25C8+H4BZBkblARRRVewodahFCFN9GKAoU1OxDQKw2Pb0LLykTkhiZjyYg CNk4PlYPC5tl1qZL3EBduz1AAb0TOWDbccjt9NAR5SmAW3JQbqnYPETsH01S/qTHv1cv yCh5O7KZf8Pi/YFhSg6iIGHn0rjKF+7ldfLsIWXacb+6qu4cZFs52DtaomkoiM/P6ZEG 4fFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697183470; x=1697788270; 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=fHcUXIeVYL2J2IaeiQjIW4srz6zzb+o5NuSL2EwrB8I=; b=ZZHNOws3HB9cMr6w1z5mX6WkY14EE3y3Obn8yzwakuxSNhyUIk4rkpCIEEt95xYie2 PTIPMxxwpUMP46LWgpu2VX5DwCGu5CoJ1gBzJgPLzxIPkpHQI6EM36XhxLHascOXE291 M3Syu7jqph9WXgtv53x2OMQs2l4Pg7J/N9iwZq6BEtaU1HgqGzT/IrlRo3EzFW1huVbE 7nXuA3bfGsyPPW3/WldzqTax6SWkNUBFwPYDf3a0cSD5qTTPj+aesYk1D1+UpA6t7VQE 0eOPfGmfqWVLrU2ctZ/F9L53y3kvKkGrhuHf2+/pI8tUWYV13sbKORyKTZqjIuXNJdW5 /eSg== X-Gm-Message-State: AOJu0Yzca4igwpcAwVxdPjO9M+trJSMdsj9XwzMgZBpV61CmPkCkKDqT vi+0gVBZxWiJ9+j+N8SQysdJ8BCCP8NKOvySLsc= X-Google-Smtp-Source: AGHT+IEGeI8Ba0GUqC20BulsgSjxRITpV4ajjKzrPDQcfX8yxG7ZWFzkoR5wttusF5Xb9TkF/nFVZw== X-Received: by 2002:a5d:6a01:0:b0:317:727f:3bc7 with SMTP id m1-20020a5d6a01000000b00317727f3bc7mr22625918wru.17.1697183470156; Fri, 13 Oct 2023 00:51:10 -0700 (PDT) Received: from localhost.localdomain (adsl-170.109.242.226.tellas.gr. [109.242.226.170]) by smtp.gmail.com with ESMTPSA id m8-20020adfa3c8000000b0032d7fde2d3csm7990663wrb.79.2023.10.13.00.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 00:51:09 -0700 (PDT) From: Emmanouil Pitsidianakis To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, qemu-block@nongnu.org Cc: Emmanouil Pitsidianakis , Laurent Vivier Subject: [RFC PATCH 40/75] linux-user: add fallthrough pseudo-keyword Date: Fri, 13 Oct 2023 10:47:48 +0300 Message-Id: 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::432; envelope-from=manos.pitsidianakis@linaro.org; helo=mail-wr1-x432.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 --- linux-user/mips/cpu_loop.c | 8 ++++---- linux-user/mmap.c | 2 +- linux-user/syscall.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c index 8735e58bad..38ddcadfc6 100644 --- a/linux-user/mips/cpu_loop.c +++ b/linux-user/mips/cpu_loop.c @@ -63,68 +63,68 @@ static void do_tr_or_bp(CPUMIPSState *env, unsigned int code, bool trap) void cpu_loop(CPUMIPSState *env) { CPUState *cs = env_cpu(env); int trapnr, si_code; unsigned int code; abi_long ret; # ifdef TARGET_ABI_MIPSO32 unsigned int syscall_num; # endif for(;;) { cpu_exec_start(cs); trapnr = cpu_exec(cs); cpu_exec_end(cs); process_queued_cpu_work(cs); switch(trapnr) { case EXCP_SYSCALL: env->active_tc.PC += 4; # ifdef TARGET_ABI_MIPSO32 syscall_num = env->active_tc.gpr[2] - 4000; if (syscall_num >= sizeof(mips_syscall_args)) { /* syscall_num is larger that any defined for MIPS O32 */ ret = -TARGET_ENOSYS; } else if (mips_syscall_args[syscall_num] == MIPS_SYSCALL_NUMBER_UNUSED) { /* syscall_num belongs to the range not defined for MIPS O32 */ ret = -TARGET_ENOSYS; } else { /* syscall_num is valid */ int nb_args; abi_ulong sp_reg; abi_ulong arg5 = 0, arg6 = 0, arg7 = 0, arg8 = 0; nb_args = mips_syscall_args[syscall_num]; sp_reg = env->active_tc.gpr[29]; switch (nb_args) { /* these arguments are taken from the stack */ case 8: if ((ret = get_user_ual(arg8, sp_reg + 28)) != 0) { goto done_syscall; } - /* fall through */ + fallthrough; case 7: if ((ret = get_user_ual(arg7, sp_reg + 24)) != 0) { goto done_syscall; } - /* fall through */ + fallthrough; case 6: if ((ret = get_user_ual(arg6, sp_reg + 20)) != 0) { goto done_syscall; } - /* fall through */ + fallthrough; case 5: if ((ret = get_user_ual(arg5, sp_reg + 16)) != 0) { goto done_syscall; } - /* fall through */ + fallthrough; default: break; } ret = do_syscall(env, env->active_tc.gpr[2], env->active_tc.gpr[4], env->active_tc.gpr[5], env->active_tc.gpr[6], env->active_tc.gpr[7], arg5, arg6, arg7, arg8); } diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 8ccaab7859..ff33b4ccf6 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -960,84 +960,84 @@ abi_long target_mremap(abi_ulong old_addr, abi_ulong old_size, abi_long target_madvise(abi_ulong start, abi_ulong len_in, int advice) { abi_ulong len; int ret = 0; if (start & ~TARGET_PAGE_MASK) { return -TARGET_EINVAL; } if (len_in == 0) { return 0; } len = TARGET_PAGE_ALIGN(len_in); if (len == 0 || !guest_range_valid_untagged(start, len)) { return -TARGET_EINVAL; } /* Translate for some architectures which have different MADV_xxx values */ switch (advice) { case TARGET_MADV_DONTNEED: /* alpha */ advice = MADV_DONTNEED; break; case TARGET_MADV_WIPEONFORK: /* parisc */ advice = MADV_WIPEONFORK; break; case TARGET_MADV_KEEPONFORK: /* parisc */ advice = MADV_KEEPONFORK; break; /* we do not care about the other MADV_xxx values yet */ } /* * Most advice values are hints, so ignoring and returning success is ok. * * However, some advice values such as MADV_DONTNEED, MADV_WIPEONFORK and * MADV_KEEPONFORK are not hints and need to be emulated. * * A straight passthrough for those may not be safe because qemu sometimes * turns private file-backed mappings into anonymous mappings. * If all guest pages have PAGE_PASSTHROUGH set, mappings have the * same semantics for the host as for the guest. * * We pass through MADV_WIPEONFORK and MADV_KEEPONFORK if possible and * return failure if not. * * MADV_DONTNEED is passed through as well, if possible. * If passthrough isn't possible, we nevertheless (wrongly!) return * success, which is broken but some userspace programs fail to work * otherwise. Completely implementing such emulation is quite complicated * though. */ mmap_lock(); switch (advice) { case MADV_WIPEONFORK: case MADV_KEEPONFORK: ret = -EINVAL; - /* fall through */ + fallthrough; case MADV_DONTNEED: if (page_check_range(start, len, PAGE_PASSTHROUGH)) { ret = get_errno(madvise(g2h_untagged(start), len, advice)); if ((advice == MADV_DONTNEED) && (ret == 0)) { page_reset_target_data(start, start + len - 1); } } } mmap_unlock(); return ret; } #ifndef TARGET_FORCE_SHMLBA /* * For most architectures, SHMLBA is the same as the page size; * some architectures have larger values, in which case they should * define TARGET_FORCE_SHMLBA and provide a target_shmlba() function. * This corresponds to the kernel arch code defining __ARCH_FORCE_SHMLBA * and defining its own value for SHMLBA. * * The kernel also permits SHMLBA to be set by the architecture to a * value larger than the page size without setting __ARCH_FORCE_SHMLBA; * this means that addresses are rounded to the large size if * SHM_RND is set but addresses not aligned to that size are not rejected * as long as they are at least page-aligned. Since the only architecture * which uses this is ia64 this code doesn't provide for that oddity. */ diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d49cd314a2..d15817846c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7740,74 +7740,74 @@ static int do_safe_futex(int *uaddr, int op, int val, /* ??? Using host futex calls even when target atomic operations are not really atomic probably breaks things. However implementing futexes locally would make futexes shared between multiple processes tricky. However they're probably useless because guest atomic operations won't work either. */ #if defined(TARGET_NR_futex) || defined(TARGET_NR_futex_time64) static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr, int op, int val, target_ulong timeout, target_ulong uaddr2, int val3) { struct timespec ts, *pts = NULL; void *haddr2 = NULL; int base_op; /* We assume FUTEX_* constants are the same on both host and target. */ #ifdef FUTEX_CMD_MASK base_op = op & FUTEX_CMD_MASK; #else base_op = op; #endif switch (base_op) { case FUTEX_WAIT: case FUTEX_WAIT_BITSET: val = tswap32(val); break; case FUTEX_WAIT_REQUEUE_PI: val = tswap32(val); haddr2 = g2h(cpu, uaddr2); break; case FUTEX_LOCK_PI: case FUTEX_LOCK_PI2: break; case FUTEX_WAKE: case FUTEX_WAKE_BITSET: case FUTEX_TRYLOCK_PI: case FUTEX_UNLOCK_PI: timeout = 0; break; case FUTEX_FD: val = target_to_host_signal(val); timeout = 0; break; case FUTEX_CMP_REQUEUE: case FUTEX_CMP_REQUEUE_PI: val3 = tswap32(val3); - /* fall through */ + fallthrough; case FUTEX_REQUEUE: case FUTEX_WAKE_OP: /* * For these, the 4th argument is not TIMEOUT, but VAL2. * But the prototype of do_safe_futex takes a pointer, so * insert casts to satisfy the compiler. We do not need * to tswap VAL2 since it's not compared to guest memory. */ pts = (struct timespec *)(uintptr_t)timeout; timeout = 0; haddr2 = g2h(cpu, uaddr2); break; default: return -TARGET_ENOSYS; } if (timeout) { pts = &ts; if (time64 ? target_to_host_timespec64(pts, timeout) : target_to_host_timespec(pts, timeout)) { return -TARGET_EFAULT; } } return do_safe_futex(g2h(cpu, uaddr), op, val, pts, haddr2, val3); } #endif #if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)