From patchwork Tue Apr 30 12:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 793316 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp231499wrf; Tue, 30 Apr 2024 05:30:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWeTdc71hGPyfqi4gbrGR1bWIAK2DafWr0+UGUkm4Nj2CfQwOJXf9DPgobgyT5cfBAc3IUEc+k8HV5GWZwbveJU X-Google-Smtp-Source: AGHT+IEP4Gbm+pZF2nuiXFYXX3J0rMOdzkdine7v2VFDvcF/gr9Y2lT0MPFOnPD60zJIdZZ7Ee6B X-Received: by 2002:ae9:f20b:0:b0:789:f0c6:a938 with SMTP id m11-20020ae9f20b000000b00789f0c6a938mr3616775qkg.15.1714480252629; Tue, 30 Apr 2024 05:30:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714480252; cv=none; d=google.com; s=arc-20160816; b=avERWa/ijvurJsSbYRHATe81TQI6L4uZcFm5qHO3csAUqPgrb7iTVoLXqbxUppp39d anzq5WtC3eVRJ55aMIOjz4IcbWgrYOq6LXw/Hj2YoAZiz1KBn/8BhG5tGsOCc2S/DhV4 s9ei4QpDS8Hh6r8qB7KCLEu/JxuE4WgWnw/fEKJA/CMwyXqTSAAD5GA11E81cQ6dpaIK r5AvRCnspOyoFK74KXPec6W6CvqCAUZdgbvAi+1plLgKY1QH1T9h89xkbtdgnrite0T6 Mgi61t/W2J1J9T1tLlcQUccRpzlWXHhxMr9aU3pMz8sPHV2Qyfv93ZYTwpJ6J7U2WLr9 AVSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9yEYkKsw4zhtRR56kF5ijigZ4qIRFvAlOOJdkN8sEkM=; fh=FpicyC1Jz/v4a6LtO5q/pqWquDN+5u5L8HIupeq3rHw=; b=0E65JaX7Uihb+Ii0wGm+gVETFw1qrWvtB48T0v0CopsFuTips/CfzfjWKGn3GFLPjc 7tIpLJ76HNgTMNEtmxcYs2b/X1HTDSaxeaa7fxcrW2F4UWgFXpa8G0ghTinFVwm5ksBr k5YjGeUAfwKtLCCMnxfVLLxwXgQK609hYGvOtdKqAMTJZC2dB44tdp4OgC/Iu77LI9Z7 NqpEDuAMB6mdSSsPMW4lC4OBeVDtN4OXAsjoRDJnn6fiDgs74JMBVkERqTtkQACHEo6T H6ySJqFCabsQ5WZqHEwJ5Zx2slR2rqam9qrY+BWLAHr2CdhFCr3Hpw5kgBksMjALZ2Ge cYgg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FDsdpwYu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i18-20020a05620a145200b0078d760dfcf0si28559195qkl.578.2024.04.30.05.30.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Apr 2024 05:30:52 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FDsdpwYu; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s1mbE-0006G0-36; Tue, 30 Apr 2024 08:28:44 -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 1s1mbC-0006FW-G2 for qemu-devel@nongnu.org; Tue, 30 Apr 2024 08:28:42 -0400 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1mbA-0001mI-Oa for qemu-devel@nongnu.org; Tue, 30 Apr 2024 08:28:42 -0400 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-56e1bbdb362so6035640a12.1 for ; Tue, 30 Apr 2024 05:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714480119; x=1715084919; 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=9yEYkKsw4zhtRR56kF5ijigZ4qIRFvAlOOJdkN8sEkM=; b=FDsdpwYuc1ksLXcUu5WAgZxg8FYVYXgioenZoKRWSWvm+BXIdYUiUaxs1oIBFI6h3r j6Xjzmn9z/nv5pn9m+p+IyhH8fjPSw8bEG1MtRfZQ7rIo1z40eWOQBrrojmeaUqkD3Wm bKdHw/K+wGqfbtAxBNKgndYhfit8fHqWZSED7tNQ5SbwbJ856Os57BRySmD6jgrEUtOL W4YkqZFz3pERrbJzl+yVcGqwIZ1mSJ+XCFZmMQlQHEEw7JQNaQqBVhDAx+s4dogpAn5a i0YgYVs+8T8UXZ1gT86Uf3CUxel2QE//vmUZfCJIcqLpp3LyEvVhwydPoS9NLsfnJABk miXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714480119; x=1715084919; 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=9yEYkKsw4zhtRR56kF5ijigZ4qIRFvAlOOJdkN8sEkM=; b=s8Szr1TFtQa49eQNyBzSqlQavLKW9nmu5JYWvB8qtcy5hwWJZxT2OmNXus1IFM438x MeD0+FysmGNTmWeISHE4qwysL9VuBQ8CB63xQq0dC9OxkKXLbJkqW3FHZBvek1XhWJaQ Yo4tw4CqXwDVHbcCxtfYGVwTVRdDvHMcvhIvLY59QWuMm/EX0r2+1n2e6FBj5x/opD08 pwqZ3CLjQ9lyCzY1HyGLRPfJucdS2qCMvzw3Eo96JKb9/IIemLjnLFiDZH1PSo0hBBiq 8NDVdUpG0aZMLdacsJMkapq/Gm6FboKOoc769DS+PssSK6UQFIzQDkSw0G/JtIhDxw9J 0YtA== X-Gm-Message-State: AOJu0YyHnKEJnEwfvHtSYNENlgJkUlsIzdHun9uZZtqt3RjonIBdBk7s JvyPT6PGeoyRSY3U/nOL14zwDM+xnsBRd2YjNLXHeBgFaBVOq+jmhAbp2zNLXO4AW25dfbDQh8d C X-Received: by 2002:a17:906:2318:b0:a59:2e36:16ce with SMTP id l24-20020a170906231800b00a592e3616cemr1330654eja.34.1714480119016; Tue, 30 Apr 2024 05:28:39 -0700 (PDT) Received: from m1x-phil.lan (mab78-h01-176-184-55-179.dsl.sta.abo.bbox.fr. [176.184.55.179]) by smtp.gmail.com with ESMTPSA id ku2-20020a170907788200b00a58c0c48756sm5674974ejc.32.2024.04.30.05.28.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 30 Apr 2024 05:28:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Anton Johansson , Ilya Leoshkevich , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH v3 05/13] accel/tcg: Restrict cpu_loop_exit_requested() to TCG Date: Tue, 30 Apr 2024 14:27:59 +0200 Message-ID: <20240430122808.72025-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240430122808.72025-1-philmd@linaro.org> References: <20240430122808.72025-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=philmd@linaro.org; helo=mail-ed1-x530.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Next commit will restrict IcountDecr to TCG, so the inlined cpu_loop_exit_requested(), which is specific to TCG, won't compile when TCG is disabled. Move it to the new "exec/cpu-loop.h" header. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20240428221450.26460-12-philmd@linaro.org> --- include/exec/cpu-loop.h | 35 +++++++++++++++++++++++++++++++++++ include/exec/exec-all.h | 17 ----------------- accel/tcg/cpu-exec.c | 1 + target/arm/tcg/helper-a64.c | 1 + target/s390x/tcg/mem_helper.c | 1 + 5 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 include/exec/cpu-loop.h diff --git a/include/exec/cpu-loop.h b/include/exec/cpu-loop.h new file mode 100644 index 0000000000..36ce4064fd --- /dev/null +++ b/include/exec/cpu-loop.h @@ -0,0 +1,35 @@ +/* + * Translation CPU loop (target agnostic) + * + * Copyright (c) 2003 Fabrice Bellard + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ +#ifndef TRANSLATION_CPU_LOOP_H +#define TRANSLATION_CPU_LOOP_H + +#ifndef CONFIG_TCG +#error Can only include this header with TCG +#endif + +#include "qemu/atomic.h" +#include "hw/core/cpu.h" + +/** + * cpu_loop_exit_requested: + * @cpu: The CPU state to be tested + * + * Indicate if somebody asked for a return of the CPU to the main loop + * (e.g., via cpu_exit() or cpu_interrupt()). + * + * This is helpful for architectures that support interruptible + * instructions. After writing back all state to registers/memory, this + * call can be used to check if it makes sense to return to the main loop + * or to continue executing the interruptible instruction. + */ +static inline bool cpu_loop_exit_requested(CPUState *cpu) +{ + return (int32_t)qatomic_read(&cpu->neg.icount_decr.u32) < 0; +} + +#endif diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 2cd7b8f61b..544e35dd24 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -29,23 +29,6 @@ #include "exec/translation-block.h" #include "qemu/clang-tsa.h" -/** - * cpu_loop_exit_requested: - * @cpu: The CPU state to be tested - * - * Indicate if somebody asked for a return of the CPU to the main loop - * (e.g., via cpu_exit() or cpu_interrupt()). - * - * This is helpful for architectures that support interruptible - * instructions. After writing back all state to registers/memory, this - * call can be used to check if it makes sense to return to the main loop - * or to continue executing the interruptible instruction. - */ -static inline bool cpu_loop_exit_requested(CPUState *cpu) -{ - return (int32_t)qatomic_read(&cpu->neg.icount_decr.u32) < 0; -} - #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG) /* cputlb.c */ /** diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 9af66bc191..eedba056ba 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -32,6 +32,7 @@ #include "qemu/main-loop.h" #include "sysemu/cpus.h" #include "exec/cpu-all.h" +#include "exec/cpu-loop.h" #include "sysemu/cpu-timers.h" #include "exec/replay-core.h" #include "sysemu/tcg.h" diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c index 0ea8668ab4..b294f6bfd0 100644 --- a/target/arm/tcg/helper-a64.c +++ b/target/arm/tcg/helper-a64.c @@ -29,6 +29,7 @@ #include "internals.h" #include "qemu/crc32c.h" #include "exec/exec-all.h" +#include "exec/cpu-loop.h" #include "exec/cpu_ldst.h" #include "qemu/int128.h" #include "qemu/atomic128.h" diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c index 6a308c5553..8435825fa5 100644 --- a/target/s390x/tcg/mem_helper.c +++ b/target/s390x/tcg/mem_helper.c @@ -26,6 +26,7 @@ #include "exec/helper-proto.h" #include "exec/exec-all.h" #include "exec/page-protection.h" +#include "exec/cpu-loop.h" #include "exec/cpu_ldst.h" #include "hw/core/tcg-cpu-ops.h" #include "qemu/int128.h"