From patchwork Tue Apr 30 12:28:02 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: 793317 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp231542wrf; Tue, 30 Apr 2024 05:30:59 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVKn/L05RRMivxmQRQa+YkcNAAS2NZ+cXldR+ElrO+ZyQUfzJNk4/yvgGpw9d4pS1u8zO8EY1x6F7EOQE7i2hpD X-Google-Smtp-Source: AGHT+IE6K6yAHfA8xQ5Ao7eXXLH9CRqMrhYSsZwTq3Fa5Akh8AM3uEEke2hFq0yrKqnogwRP+BjF X-Received: by 2002:ac8:7d07:0:b0:43a:d0f1:9c60 with SMTP id g7-20020ac87d07000000b0043ad0f19c60mr4852007qtb.6.1714480258913; Tue, 30 Apr 2024 05:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714480258; cv=none; d=google.com; s=arc-20160816; b=lbf8OKaCNHi+Uq3u5eY0s5CTa3s2ejMzBZaRZSBIftsftv3WZVcOKJSa8O5ozhz6x/ 7cAhC3heRVgvhnaO3O95t1LnwxbTz2+SRQ/n0tffmYBX2uuC0/UE2cAS0ZHxvpEyZ/CI TdVT6wrUQcpOyyuHqUmvKinWZuPzVGGs3CcrFv8rULkHu7ItfZRCVaXwSRKnDllV8qbc 17zpvnIrav0i6CO2EsyvFsM1Xd6k9iK+PQYbOIqpQhPrUFVd29Ln7U/PYOsm3HTDCJI2 JW5gZKQkadAa7koFMIj2aEPhpkfibKZUDp4xIFsi/h9oDNSWZMRmweieOw0Eu+ZGEAJx KOMQ== 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=Y/XVft3u1TnXcfWULCA1fWxoECDnyMfyO72+jOrBPL4=; fh=FpicyC1Jz/v4a6LtO5q/pqWquDN+5u5L8HIupeq3rHw=; b=sP7v0veZ7x6Qfc9JwTABp0Oh7XZT1jBjEZengwQ0z+KvUNfX+6x9jWDxaY9xUmfgIl vPxUerxOpfnlvjOJY1mLDv2eXRZ81fQ0WFvJ0at8rs6ez8yCDkp0u60okYUWRukLoTep Zr/nsAUJkQwNR2I/Zj+5KSKLxOBkj+6kgRKZMBgmhLOd5PEwMhnRZq6h9PdhbM8DcNfm 8gQX1yOLGftnEryj9NbbRnkFKRKZwVmQVMgsvnwrBxNrKWV/8VP4rcEdDS4gZCNue42w qMDQxLDF+KsA5+/+I07IlRuOAUihrfntbt54f/45xBcEnsi4olX3E6rnzr4F0Vf3DB8P +ecg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="FLcKm/y5"; 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 t20-20020a05622a149400b0043ad0f21d07si5966822qtx.424.2024.04.30.05.30.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Apr 2024 05:30:58 -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="FLcKm/y5"; 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 1s1mbl-0006r9-Cl; Tue, 30 Apr 2024 08:29:17 -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 1s1mbT-0006ij-ST for qemu-devel@nongnu.org; Tue, 30 Apr 2024 08:29:01 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1mbR-0001oL-Og for qemu-devel@nongnu.org; Tue, 30 Apr 2024 08:28:59 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-51b526f0fc4so7069691e87.1 for ; Tue, 30 Apr 2024 05:28:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714480135; x=1715084935; 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=Y/XVft3u1TnXcfWULCA1fWxoECDnyMfyO72+jOrBPL4=; b=FLcKm/y5sS1wVYDhI6NyD3FR/EuSIeaT+NKRJL7g7gtZZLtdfsZ8kyIqnodOQ/vVwS fq52cMEvDGz/NUUKjlyZhs2qLRrQS2tWpu638FeJeKULZuBfxx00XcactMNrODwK5b9V wpm3xYWfMxxvFZ3OMly4h1ttX1PO9uHf+KJoFAoMuxp862CESH0vSsGyeA8SzaQIuTKL IZ8vFW79O8LpQ9F6EPnBpoEK2sOJyWBvu/DNkNOipn/i0ruw3BC4F+jDrNhmau9OGUk+ ntWIL7jyE/5lgffyxQv9kVg6uWyNleadmgmD/KvzPjTjt2sjERzpl096VGGxXp/kU3gB F/lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714480135; x=1715084935; 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=Y/XVft3u1TnXcfWULCA1fWxoECDnyMfyO72+jOrBPL4=; b=FeguuF2EAXDc/bydnlO16FYievyZBQjw9+aD+u9BKoG/qvgSysf2oxqlTXDP5N+StB RGx7ggS5XGOsXk8u7UUGgm4MoUSu6Bt6ZXsCcBo3/0xOWmlEzVaDIBBIiSg3HyaVvbds x/4NG+IKaBfFBD5qYu4evlQqoODfI90YNKsrOKN8r6LxBmxQXds1v+n3QAatlG2oC7jY +hGqyA8CouYhYoNELuY3ZlDoLv65mLD/FdVkLxuYF2r2Q35eieV56Wc1XtvZ4PVpMuOf tZsGOC7snyQyD6Sv89mZ74zQOCP4xBm5wVQXvKWmo2cVGHL1D9w5fSfiMR5KQUW2PHi0 Z1Cg== X-Gm-Message-State: AOJu0Yz5lh7eaJQaqGFwLoIyzkOodJYdKERFvigLfV0QtiAkELXb/hCq oGLgXT+bv2Vy3BTTeXwrHsenQv03wd5LcqLT0pwio/mZe2NrGqoS2gN1cw496OWmB0h5C5+KneD L X-Received: by 2002:a19:ad0b:0:b0:516:d448:b42a with SMTP id t11-20020a19ad0b000000b00516d448b42amr1657561lfc.26.1714480135516; Tue, 30 Apr 2024 05:28:55 -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 mc11-20020a170906eb4b00b00a5256d8c956sm14996887ejb.61.2024.04.30.05.28.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 30 Apr 2024 05:28:55 -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 08/13] accel/tcg: Move @cflags_next_tb from CPUState to TCG AccelCPUState Date: Tue, 30 Apr 2024 14:28:02 +0200 Message-ID: <20240430122808.72025-9-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::132; envelope-from=philmd@linaro.org; helo=mail-lf1-x132.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 @cflags_next_tb is specific to TCG accelerator, move it to its AccelCPUState. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20240428221450.26460-19-philmd@linaro.org> --- accel/tcg/vcpu-state.h | 2 ++ include/hw/core/cpu.h | 1 - accel/tcg/cpu-exec.c | 12 ++++++------ accel/tcg/tb-maint.c | 4 ++-- accel/tcg/tcg-accel-ops.c | 1 + accel/tcg/translate-all.c | 2 +- accel/tcg/watchpoint.c | 5 +++-- hw/core/cpu-common.c | 1 - 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/accel/tcg/vcpu-state.h b/accel/tcg/vcpu-state.h index 3a0ea2d47a..5b09279140 100644 --- a/accel/tcg/vcpu-state.h +++ b/accel/tcg/vcpu-state.h @@ -13,6 +13,8 @@ * @plugin_state: per-CPU plugin state */ struct AccelCPUState { + uint32_t cflags_next_tb; + sigjmp_buf jmp_env; #ifdef CONFIG_USER_ONLY diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index f1fe43dbea..97a0baf874 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -468,7 +468,6 @@ struct CPUState { bool crash_occurred; bool exit_request; int exclusive_context_count; - uint32_t cflags_next_tb; /* updates protected by BQL */ uint32_t interrupt_request; int singlestep_enabled; diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 443b688c01..2edfad78b3 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -721,7 +721,7 @@ static inline bool cpu_handle_exception(CPUState *cpu, int *ret) if (replay_has_exception() && cpu->neg.icount_decr.u16.low + cpu->icount_extra == 0) { /* Execute just one insn to trigger exception pending in the log */ - cpu->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT) + cpu->accel->cflags_next_tb = (curr_cflags(cpu) & ~CF_USE_ICOUNT) | CF_NOIRQ | 1; } #endif @@ -784,7 +784,7 @@ static inline bool icount_exit_request(CPUState *cpu) if (!icount_enabled()) { return false; } - if (cpu->cflags_next_tb != -1 && !(cpu->cflags_next_tb & CF_USE_ICOUNT)) { + if (!(cpu->accel->cflags_next_tb == -1 || cpu->accel->cflags_next_tb & CF_USE_ICOUNT)) { return false; } return cpu->neg.icount_decr.u16.low + cpu->icount_extra == 0; @@ -798,7 +798,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, * skip checking here. Any pending interrupts will get picked up * by the next TB we execute under normal cflags. */ - if (cpu->cflags_next_tb != -1 && cpu->cflags_next_tb & CF_NOIRQ) { + if (cpu->accel->cflags_next_tb != -1 && cpu->accel->cflags_next_tb & CF_NOIRQ) { return false; } @@ -948,7 +948,7 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, if (insns_left > 0 && insns_left < tb->icount) { assert(insns_left <= CF_COUNT_MASK); assert(cpu->icount_extra == 0); - cpu->cflags_next_tb = (tb->cflags & ~CF_COUNT_MASK) | insns_left; + cpu->accel->cflags_next_tb = (tb->cflags & ~CF_COUNT_MASK) | insns_left; } #endif } @@ -980,11 +980,11 @@ cpu_exec_loop(CPUState *cpu, SyncClocks *sc) * have CF_INVALID set, -1 is a convenient invalid value that * does not require tcg headers for cpu_common_reset. */ - cflags = cpu->cflags_next_tb; + cflags = cpu->accel->cflags_next_tb; if (cflags == -1) { cflags = curr_cflags(cpu); } else { - cpu->cflags_next_tb = -1; + cpu->accel->cflags_next_tb = -1; } if (check_for_breakpoints(cpu, pc, &cflags)) { diff --git a/accel/tcg/tb-maint.c b/accel/tcg/tb-maint.c index 19ae6793f3..2d5faca9fd 100644 --- a/accel/tcg/tb-maint.c +++ b/accel/tcg/tb-maint.c @@ -1084,7 +1084,7 @@ bool tb_invalidate_phys_page_unwind(tb_page_addr_t addr, uintptr_t pc) if (current_tb_modified) { /* Force execution of one insn next time. */ CPUState *cpu = current_cpu; - cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); + cpu->accel->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); return true; } return false; @@ -1154,7 +1154,7 @@ tb_invalidate_phys_page_range__locked(struct page_collection *pages, if (current_tb_modified) { page_collection_unlock(pages); /* Force execution of one insn next time. */ - current_cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); + current_cpu->accel->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(current_cpu); mmap_unlock(); cpu_loop_exit_noexc(current_cpu); } diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 56bbad9fcd..d9132a5835 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -89,6 +89,7 @@ static void tcg_cpu_reset_hold(CPUState *cpu) qatomic_set(&cpu->neg.icount_decr.u32, 0); cpu->neg.can_do_io = true; + cpu->accel->cflags_next_tb = -1; } /* mask must never be zero, except for A20 change call */ diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index b67adce20e..3a8199a761 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -631,7 +631,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retaddr) * operations only (which execute after completion) so we don't * double instrument the instruction. */ - cpu->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | n; + cpu->accel->cflags_next_tb = curr_cflags(cpu) | CF_MEMI_ONLY | n; if (qemu_loglevel_mask(CPU_LOG_EXEC)) { vaddr pc = cpu->cc->get_pc(cpu); diff --git a/accel/tcg/watchpoint.c b/accel/tcg/watchpoint.c index d3aab11458..0a40bfdc85 100644 --- a/accel/tcg/watchpoint.c +++ b/accel/tcg/watchpoint.c @@ -26,6 +26,7 @@ #include "sysemu/replay.h" #include "hw/core/tcg-cpu-ops.h" #include "hw/core/cpu.h" +#include "accel/tcg/vcpu-state.h" /* * Return true if this watchpoint address matches the specified @@ -100,7 +101,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, */ if (!cpu->neg.can_do_io) { /* Force execution of one insn next time. */ - cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(cpu); + cpu->accel->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(cpu); cpu_loop_exit_restore(cpu, ra); } /* @@ -132,7 +133,7 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, cpu_loop_exit(cpu); } else { /* Force execution of one insn next time. */ - cpu->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(cpu); + cpu->accel->cflags_next_tb = 1 | CF_NOIRQ | curr_cflags(cpu); mmap_unlock(); cpu_loop_exit_noexc(cpu); } diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index ea342213d6..b6631b6245 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -124,7 +124,6 @@ static void cpu_common_reset_hold(Object *obj, ResetType type) cpu->icount_extra = 0; cpu->exception_index = -1; cpu->crash_occurred = false; - cpu->cflags_next_tb = -1; cpu_exec_reset_hold(cpu); }