From nobody Mon Feb 9 14:33:33 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1767741649; cv=none; d=zohomail.com; s=zohoarc; b=luCAx1NITXYJklZYRBETja14bR5AScu6CIb2rOTzju6LzFn0e+Pf8GKtEHzyIjFUMEUUlnPf4uPe65nlr4R/HHPE4G0r94wxVjhy4o7FFjDjJnLPjZ8HecQzEJS+4xBbt7DqBTsmIh4k0rlqHB2QDkIhojY0pQ90B1LIvBjmjRU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767741649; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oG31mHt5hAIZAFs8E2PvTGlNRu+jO6SBveBnHl2PbaQ=; b=XHinQwfBnuGiJlJXdyKzvuGDVpr8RwFnKs626yo1kt8lcM3lTFZhONfCWhPRXqmomU9LNq+GPzeG3g0R3GTvTTIrhi+L7wGDIG46+qH4Oo4eslIUme+1rzor8zyjFpcInxZcSYm58xvBHLs0RnSJ6HO5TrNNwfRnJo/Xa1wpCHE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1767741649474474.1733649027444; Tue, 6 Jan 2026 15:20:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vdGL6-0005UK-7y; Tue, 06 Jan 2026 18:19:48 -0500 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 1vdGL4-0005PG-46 for qemu-devel@nongnu.org; Tue, 06 Jan 2026 18:19:46 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vdGL1-0001ID-2L for qemu-devel@nongnu.org; Tue, 06 Jan 2026 18:19:45 -0500 Received: by mail-wm1-x341.google.com with SMTP id 5b1f17b1804b1-477a219dbcaso12265075e9.3 for ; Tue, 06 Jan 2026 15:19:36 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47d7faedd57sm27435795e9.5.2026.01.06.15.19.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 06 Jan 2026 15:19:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767741575; x=1768346375; 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=oG31mHt5hAIZAFs8E2PvTGlNRu+jO6SBveBnHl2PbaQ=; b=KDsowzACBzNDP1btWKFX6Crj4B+d6KUej2Fw5vX6HeA+oN2wYXFarJhxxXkVJAo86d razN6GdbmJ06zMrXoGs1kdg1ODDPSNfpgsqdO+Ryb1smFjonw/TX97vvGjnDJxL9YCvh FgFZDCHCdQC6r5/QlPtT7Izn+LRi+IoIvbF0hXr9QBTiHDqZvBVuR23x+iDHyUzVds6D ANnTwogi8z7bbir+nFV2o2XZrxZiM9JksPUbGt1A7iAgMiOq7gzCcljMa4tWKrpY+bmk T0alW2+qNgtzVxkHWh0KLAwzJiGEABQclyfbGEwZ7KUflUCiyDvqEIJGev9xv4jNajD9 JEUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767741575; x=1768346375; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=oG31mHt5hAIZAFs8E2PvTGlNRu+jO6SBveBnHl2PbaQ=; b=TPZKTf7U7elDYm7Tzam55RiwuReQkQ6JjbtsR/4b1lxKlGMe2U9BXAsnQQC7EDftUs p9j8sCphG5n10GxLj84e9+9/z27uIuqNfgAqKs5FCVz4I4FlsvZSKAALEU5z+RQMjeBC 1SBpyyiLZskbtzn35Gi6WiIOOLY+UdHZKVhfIGDXJ7ro5DRFS/VcKsMs4TmQviU2j5+R YRosiCDcfz3/dvzfbxfk1LGE7HDZmdFQb3ubDByEHac0fDjEuMeewp6HNdPkTBCqyV5z ys/+x/8PN45nnYwh84pRbTaegeKA2DBuMjrn09UHXeeEPNc8i8QaE3nmhoLYqzns+vCm aP0w== X-Gm-Message-State: AOJu0Yy9v+JYlMeD3BZtvr7P8/U5dZRs8XS5kc9NmOrl9jKnOrLhnYwU +j59DC0od2QMkwe+sYC9BDaoAMPnXW3M8KVCybgBUWzyVNbKWguqleOnoWXPBAN7Z5gLi/s1Q1e OtNb1HYDgxg== X-Gm-Gg: AY/fxX4Gsfe7cIAORwXNDG+qf4wB48egJW3Df63e6ZkcKkj8oGfKWR67kvEFgVw+p25 5NfAVer5sqgJXYU9vesrHB9oLM4229oqvXjlSTyYXudU1SbC2JfFUXZ2XZaHDIiU+Gf8xMrrmOF C7Wka4c/YKbnnlw2WQ9RhjU3dm2VE2a7/Xg8yns1Y71JDULFXVaueUkft1SvTctK/L4RRhOY6gY jPY442BJsbi4hBWTUW5nNFOUjDUBn4XtBAuksWQgsqmJhv2bcVkiz4ALa6AdYJhJQJkuVFEwYfR hjlYNeD8JggRYTtoeTdOEZJUWVEzQc/Q40o0IxUOy+zsqkYXU5hJquTX9UOi2o2DOM3pOHUTgj5 jsJ+s+hPQiumJBnyQ6OsKMD87HVZUW4Vmucltd/vn85wOmE3yCE3ZTu+31Hcz734gBaLMAqo4AF Hw9OtK/DJtFj9G6JDAg6s7ZKAZPF9SHQdOoKY+p4IP7XSbuVmWJpBAk5V3tXBl X-Google-Smtp-Source: AGHT+IGBPiN9OqBj4AH4ZXKOokhRaGavV0ccTGCcgU3wTU3oFvnnQPhzCH6bETDOH9hik64M1OyyWw== X-Received: by 2002:a05:600c:8506:b0:477:9ce2:a0d8 with SMTP id 5b1f17b1804b1-47d849bd201mr4901385e9.0.1767741575049; Tue, 06 Jan 2026 15:19:35 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Richard Henderson , qemu-ppc@nongnu.org, Pierrick Bouvier , qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Thomas Huth , Ilya Leoshkevich , David Hildenbrand Subject: [PATCH 3/5] target/s390x: Restrict WatchPoint API to TCG Date: Wed, 7 Jan 2026 00:19:05 +0100 Message-ID: <20260106231908.16756-4-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260106231908.16756-1-philmd@linaro.org> References: <20260106231908.16756-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::341; envelope-from=philmd@linaro.org; helo=mail-wm1-x341.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=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1767741651468158500 By inverting the 'tcg_enabled()' check in s390_cpu_set_psw() we can let the compiler elide the s390_cpu_recompute_watchpoints() call when TCG is not available. Move it to a TCG specific file to avoid compiling dead code on KVM. This restricts the WatchPoint API calls to TCG. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- target/s390x/s390x-internal.h | 1 - target/s390x/tcg/tcg_s390x.h | 4 +++ target/s390x/cpu.c | 30 ++++++++++---------- target/s390x/helper.c | 38 ------------------------- target/s390x/tcg/debug.c | 53 +++++++++++++++++++++++++++++++++++ target/s390x/tcg/meson.build | 3 ++ 6 files changed, 75 insertions(+), 54 deletions(-) create mode 100644 target/s390x/tcg/debug.c diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h index 9691366ec91..c4cd17d4d7d 100644 --- a/target/s390x/s390x-internal.h +++ b/target/s390x/s390x-internal.h @@ -317,7 +317,6 @@ void s390_cpu_gdb_init(CPUState *cs); void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags); void do_restart_interrupt(CPUS390XState *env); #ifndef CONFIG_USER_ONLY -void s390_cpu_recompute_watchpoints(CPUState *cs); void s390x_tod_timer(void *opaque); void s390x_cpu_timer(void *opaque); void s390_handle_wait(S390CPU *cpu); diff --git a/target/s390x/tcg/tcg_s390x.h b/target/s390x/tcg/tcg_s390x.h index 78558912f99..33f26f26c0f 100644 --- a/target/s390x/tcg/tcg_s390x.h +++ b/target/s390x/tcg/tcg_s390x.h @@ -21,4 +21,8 @@ G_NORETURN void tcg_s390_data_exception(CPUS390XState *en= v, uint32_t dxc, G_NORETURN void tcg_s390_vector_exception(CPUS390XState *env, uint32_t vxc, uintptr_t ra); =20 +#ifndef CONFIG_USER_ONLY +void s390_cpu_recompute_watchpoints(CPUState *cs); +#endif + #endif /* TCG_S390X_H */ diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 6c4198eb1b1..f68b288e364 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -40,6 +40,7 @@ #include "system/reset.h" #endif #include "hw/s390x/cpu-topology.h" +#include "tcg/tcg_s390x.h" =20 #define CR0_RESET 0xE0UL #define CR14_RESET 0xC2000000UL; @@ -74,26 +75,25 @@ void s390_cpu_set_psw(CPUS390XState *env, uint64_t mask= , uint64_t addr) env->psw.mask =3D mask; =20 /* KVM will handle all WAITs and trigger a WAIT exit on disabled_wait = */ - if (!tcg_enabled()) { - return; - } - env->cc_op =3D (mask >> 44) & 3; + if (tcg_enabled()) { + env->cc_op =3D (mask >> 44) & 3; =20 #ifndef CONFIG_USER_ONLY - if (is_early_exception_psw(mask, addr)) { - env->int_pgm_ilen =3D 0; - trigger_pgm_exception(env, PGM_SPECIFICATION); - return; - } + if (is_early_exception_psw(mask, addr)) { + env->int_pgm_ilen =3D 0; + trigger_pgm_exception(env, PGM_SPECIFICATION); + return; + } =20 - if ((old_mask ^ mask) & PSW_MASK_PER) { - s390_cpu_recompute_watchpoints(env_cpu(env)); - } + if ((old_mask ^ mask) & PSW_MASK_PER) { + s390_cpu_recompute_watchpoints(env_cpu(env)); + } =20 - if (mask & PSW_MASK_WAIT) { - s390_handle_wait(env_archcpu(env)); - } + if (mask & PSW_MASK_WAIT) { + s390_handle_wait(env_archcpu(env)); + } #endif + } } =20 uint64_t s390_cpu_get_psw_mask(CPUS390XState *env) diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 184428c6d9d..8d1e03f6768 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -143,41 +143,3 @@ void do_restart_interrupt(CPUS390XState *env) =20 s390_cpu_set_psw(env, mask, addr); } - -void s390_cpu_recompute_watchpoints(CPUState *cs) -{ - const int wp_flags =3D BP_CPU | BP_MEM_WRITE | BP_STOP_BEFORE_ACCESS; - CPUS390XState *env =3D cpu_env(cs); - - /* We are called when the watchpoints have changed. First - remove them all. */ - cpu_watchpoint_remove_all(cs, BP_CPU); - - /* Return if PER is not enabled */ - if (!(env->psw.mask & PSW_MASK_PER)) { - return; - } - - /* Return if storage-alteration event is not enabled. */ - if (!(env->cregs[9] & PER_CR9_EVENT_STORE)) { - return; - } - - if (env->cregs[10] =3D=3D 0 && env->cregs[11] =3D=3D -1LL) { - /* We can't create a watchoint spanning the whole memory range, so - split it in two parts. */ - cpu_watchpoint_insert(cs, 0, 1ULL << 63, wp_flags, NULL); - cpu_watchpoint_insert(cs, 1ULL << 63, 1ULL << 63, wp_flags, NULL); - } else if (env->cregs[10] > env->cregs[11]) { - /* The address range loops, create two watchpoints. */ - cpu_watchpoint_insert(cs, env->cregs[10], -env->cregs[10], - wp_flags, NULL); - cpu_watchpoint_insert(cs, 0, env->cregs[11] + 1, wp_flags, NULL); - - } else { - /* Default case, create a single watchpoint. */ - cpu_watchpoint_insert(cs, env->cregs[10], - env->cregs[11] - env->cregs[10] + 1, - wp_flags, NULL); - } -} diff --git a/target/s390x/tcg/debug.c b/target/s390x/tcg/debug.c new file mode 100644 index 00000000000..12ae95d4fe8 --- /dev/null +++ b/target/s390x/tcg/debug.c @@ -0,0 +1,53 @@ +/* + * QEMU S/390 debug routines + * + * Copyright (c) 2009 Ulrich Hecht + * Copyright (c) 2011 Alexander Graf + * Copyright (c) 2012 SUSE LINUX Products GmbH + * Copyright (c) 2012 IBM Corp. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "exec/watchpoint.h" +#include "target/s390x/cpu.h" +#include "tcg_s390x.h" + +void s390_cpu_recompute_watchpoints(CPUState *cs) +{ + const int wp_flags =3D BP_CPU | BP_MEM_WRITE | BP_STOP_BEFORE_ACCESS; + CPUS390XState *env =3D cpu_env(cs); + + /* We are called when the watchpoints have changed. First + remove them all. */ + cpu_watchpoint_remove_all(cs, BP_CPU); + + /* Return if PER is not enabled */ + if (!(env->psw.mask & PSW_MASK_PER)) { + return; + } + + /* Return if storage-alteration event is not enabled. */ + if (!(env->cregs[9] & PER_CR9_EVENT_STORE)) { + return; + } + + if (env->cregs[10] =3D=3D 0 && env->cregs[11] =3D=3D -1LL) { + /* We can't create a watchoint spanning the whole memory range, so + split it in two parts. */ + cpu_watchpoint_insert(cs, 0, 1ULL << 63, wp_flags, NULL); + cpu_watchpoint_insert(cs, 1ULL << 63, 1ULL << 63, wp_flags, NULL); + } else if (env->cregs[10] > env->cregs[11]) { + /* The address range loops, create two watchpoints. */ + cpu_watchpoint_insert(cs, env->cregs[10], -env->cregs[10], + wp_flags, NULL); + cpu_watchpoint_insert(cs, 0, env->cregs[11] + 1, wp_flags, NULL); + + } else { + /* Default case, create a single watchpoint. */ + cpu_watchpoint_insert(cs, env->cregs[10], + env->cregs[11] - env->cregs[10] + 1, + wp_flags, NULL); + } +} diff --git a/target/s390x/tcg/meson.build b/target/s390x/tcg/meson.build index ee4e8fec77c..515cb8b473d 100644 --- a/target/s390x/tcg/meson.build +++ b/target/s390x/tcg/meson.build @@ -12,3 +12,6 @@ s390x_ss.add(when: 'CONFIG_TCG', if_true: files( 'vec_int_helper.c', 'vec_string_helper.c', )) +s390x_system_ss.add(when: 'CONFIG_TCG', if_true: files( + 'debug.c', +)) --=20 2.52.0