From patchwork Tue Mar 28 16:02:03 2023 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: 667864 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp1743474wrt; Tue, 28 Mar 2023 09:03:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YrPb/Tg+J3xHoKqr+6JKUvCOX1HvZHXNEcpcom+1XBZzl8klH3Kk7UY7cAI4kFwKsW/O/v X-Received: by 2002:a05:6214:20e7:b0:56e:a96b:a3a1 with SMTP id 7-20020a05621420e700b0056ea96ba3a1mr28061729qvk.7.1680019433140; Tue, 28 Mar 2023 09:03:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680019433; cv=none; d=google.com; s=arc-20160816; b=mrHRt1Ir0rQeSx7feQIa1d2qZaByMtnx8WgforvL+GiQ+QyFtYYhkn+O21rM9VDtXB mf7wE8o+EoaaYuOcYum4Kuw8jZ9O8z8p9xTOa+GLxUP1DmGcaZkvbJImhOoPLk1NRbsy V/b9Pi1fMi4ixg8kEMPk0sUpxVlm7Km6ofI8SrWNuhxKyanUKVXqTlj/ovLIZRJoAj8H qhqvy3q52YWIIz3AYRsmijj+Vcnc0Vfhn2XInl3JbTjYJmlWAWKcVUf1Bre6YGX0SsOG wlu063rBr7DfHYNDqWeIl1/EAvIpBVUT4NpNjs9Zq/w2+LRee1bEu2c0nfB/i7csymp1 rgzQ== 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=6MbnN+0f617dsehwYtlh7IWt8dwxE1cjBMBOmowF/jo=; b=O5QemsRGUecDnMr96SmfdTgzlvQuhtnoBlxba9lynL0Z92oTA0ps5kcHkoF9t8dcYV 9Hj53GrPiuV3339t7vBKMEOwBUT0c5qcz2vGS/u4yy8kuoPE3KSsUZIPykQ41teEJMqM wHpINdjgdbAwVjxr1zLDwYATJD7oOTtsADzt71FLR+MhYd7TYEoaUwvP47QfPaYa+nre PIeZflK8p2l/9j+Pi5vKGl86TSNE71JGNLaQW9EOiFdBgqHxqm0MQij8xh3RWVGZe1x5 Jft/POcAy46Um3EmVxAF3vEouqfUpFvzhZ6iHxfUFdLSRgXd62jDYlK5UyHeV6Ppx6YG 502g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VJZ0iiE8; 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 y8-20020a0cec08000000b0057249ef802dsi20187164qvo.328.2023.03.28.09.03.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Mar 2023 09:03:53 -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=VJZ0iiE8; 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 1phBmL-0000AD-SV; Tue, 28 Mar 2023 12:02:33 -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 1phBmI-00008d-Tj for qemu-devel@nongnu.org; Tue, 28 Mar 2023 12:02:30 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1phBmG-0004Ha-EI for qemu-devel@nongnu.org; Tue, 28 Mar 2023 12:02:30 -0400 Received: by mail-wr1-x42d.google.com with SMTP id e18so12764247wra.9 for ; Tue, 28 Mar 2023 09:02:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680019347; 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=6MbnN+0f617dsehwYtlh7IWt8dwxE1cjBMBOmowF/jo=; b=VJZ0iiE81gahmAHh33wdnxu9f+fm7PWswjCh7eESenZk4qw+MBxuSDrdCRJA0VrjEI +C7aKvPD13wY3jABL63HkqOa9uMkiu9Mbn2+aR07oiNg+xMVJQrsjvj4hLMsKVcydEBY nwiqU5BDc6N6afTuF03JZqD8tCyzkYo3IEfdUUPofFV4GZMfjkRzf6rM6AHXt6J9wY2r HMQigzyW+2RXu4nay6XAGfMfQXkEWxNc2j8yR2sEAbCMcg6+rBtCdJvepi60ZidtWN9n c0gEDCsuxeLXDQAbKpXAHz6BYiGfYjVotey3OfXSQsTFqFBrXE/2h/6xbGPnvH2z/hHT 0Cpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680019347; 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=6MbnN+0f617dsehwYtlh7IWt8dwxE1cjBMBOmowF/jo=; b=bIz2wdAgqn7NF8vDh0uxunPmXB79SH205WlM7gRk1ie9gepsqlctAohD9L2JvwyoCg ZyKuqbJo+1o+QEqjYt6Hd51WVHk4llvfV9t241+aa0zt7Sj+dM+SorrALkqYEBq0KUAJ W8XX+dvtLR1HbG50kT599TXkrIRD00kSfOrYYQ0H6Pt5ZyAyQX/NvrdwpxNkJElOEEEJ 76jxWIZC7PzYHx/7I4UGjPwPUCI3np2eV0ddZPIj7rtxxuolU6kPH2KG5nQQskqzowsg Vh6nF2WSqhZ0rRbqOHqFzqLHtR0723u77HqKyKmNNUKtizZcqyCLY5mDgMNOQNIr8w9C xHJg== X-Gm-Message-State: AAQBX9fh5YBgPvjp1djw+P4CA9apE6DINPyVen/VszNnY/bgImy7TGg2 8R1t59C9uq3513/aJ2kuo4+e6vT/vRGxz2i1t84= X-Received: by 2002:adf:f4c2:0:b0:2ce:ad40:7705 with SMTP id h2-20020adff4c2000000b002cead407705mr13934370wrp.25.1680019346740; Tue, 28 Mar 2023 09:02:26 -0700 (PDT) Received: from localhost.localdomain ([176.187.210.212]) by smtp.gmail.com with ESMTPSA id f11-20020a5d4dcb000000b002cfe3f842c8sm27713200wru.56.2023.03.28.09.02.24 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Mar 2023 09:02:26 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Eduardo Habkost , kvm@vger.kernel.org, qemu-s390x@nongnu.org, Fabiano Rosas , David Hildenbrand , Marcel Apfelbaum , Paolo Bonzini , Greg Kurz , Christian Borntraeger , Thomas Huth , Peter Maydell , Richard Henderson , Ilya Leoshkevich , Halil Pasic , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Yanan Wang , qemu-ppc@nongnu.org, =?utf-8?q?Alex_Be?= =?utf-8?q?nn=C3=A9e?= , qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-8.0 3/3] softmmu: Restore use of CPU watchpoint for all accelerators Date: Tue, 28 Mar 2023 18:02:03 +0200 Message-Id: <20230328160203.13510-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230328160203.13510-1-philmd@linaro.org> References: <20230328160203.13510-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org CPU watchpoints can be use by non-TCG accelerators. KVM uses them: $ git grep CPUWatchpoint|fgrep kvm target/arm/kvm64.c:1558: CPUWatchpoint *wp = find_hw_watchpoint(cs, debug_exit->far); target/i386/kvm/kvm.c:5216:static CPUWatchpoint hw_watchpoint; target/ppc/kvm.c:443:static CPUWatchpoint hw_watchpoint; target/s390x/kvm/kvm.c:139:static CPUWatchpoint hw_watchpoint; See for example commit e4482ab7e3 ("target-arm: kvm - add support for HW assisted debug"): This adds basic support for HW assisted debug. The ioctl interface to KVM allows us to pass an implementation defined number of break and watch point registers. [...] This partially reverts commit 2609ec2868e6c286e755a73b4504714a0296a. Fixes: 2609ec2868 ("softmmu: Extract watchpoint API from physmem.c") Signed-off-by: Philippe Mathieu-Daudé --- include/hw/core/cpu.h | 2 +- softmmu/watchpoint.c | 4 ++++ softmmu/meson.build | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index ce312745d5..397fd3ac68 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -949,7 +949,7 @@ static inline bool cpu_breakpoint_test(CPUState *cpu, vaddr pc, int mask) return false; } -#if !defined(CONFIG_TCG) || defined(CONFIG_USER_ONLY) +#if defined(CONFIG_USER_ONLY) static inline int cpu_watchpoint_insert(CPUState *cpu, vaddr addr, vaddr len, int flags, CPUWatchpoint **watchpoint) { diff --git a/softmmu/watchpoint.c b/softmmu/watchpoint.c index 9d6ae68499..5350163385 100644 --- a/softmmu/watchpoint.c +++ b/softmmu/watchpoint.c @@ -104,6 +104,8 @@ void cpu_watchpoint_remove_all(CPUState *cpu, int mask) } } +#ifdef CONFIG_TCG + /* * Return true if this watchpoint address matches the specified * access (ie the address range covered by the watchpoint overlaps @@ -220,3 +222,5 @@ void cpu_check_watchpoint(CPUState *cpu, vaddr addr, vaddr len, } } } + +#endif /* CONFIG_TCG */ diff --git a/softmmu/meson.build b/softmmu/meson.build index 0180577517..1a7c7ac089 100644 --- a/softmmu/meson.build +++ b/softmmu/meson.build @@ -5,11 +5,11 @@ specific_ss.add(when: 'CONFIG_SOFTMMU', if_true: [files( 'physmem.c', 'qtest.c', 'dirtylimit.c', + 'watchpoint.c', )]) specific_ss.add(when: ['CONFIG_SOFTMMU', 'CONFIG_TCG'], if_true: [files( 'icount.c', - 'watchpoint.c', )]) softmmu_ss.add(files(