From patchwork Tue Mar 28 17:31:17 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: 667871 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp1799524wrt; Tue, 28 Mar 2023 10:32:59 -0700 (PDT) X-Google-Smtp-Source: AKy350aNCWXcDuPpFMchw0n9itb8X+me5AV0qWSXh76pMNxU5ZPEB1njxHq0/q7WTem9rH/pOYOx X-Received: by 2002:ac8:5c8e:0:b0:3e4:e79c:55e0 with SMTP id r14-20020ac85c8e000000b003e4e79c55e0mr14551788qta.8.1680024779235; Tue, 28 Mar 2023 10:32:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680024779; cv=none; d=google.com; s=arc-20160816; b=ZsAnFfRU0eQTajbZkk8gK9ZgPO7Ro6iWXBlhQb5ePJ7YDULDQy2WLoBv2w4HKSyyZU aAcLSWOWRVceibwBCPnGI1T9m/mvcCk2MiVpV9H5v05X+gKYFQIIuinbKLiWLtYOpGtP u5eUt3FQSweDgLQTWFvRXS+FgpZLiSn4Z/mqx1CFnrLe164Fiz/e7EMM37rV/oIwrGQU iH1LursHo0ANxpQx3QNFgBEOBTzLJLnEWQkVJgac95F5mMJtWcGWQq5bxrWlhkU+iazX cqLec4E4tfd8dxnIHzY0ajGkeddeKuaUvyqcQecHn3CZpawBOVQf3vqgDvaE4TWK9ZO+ ZWjQ== 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=PXI2uWNckmLJV6rJAgmnWhsNeq3HiYZxv3NWNTngjo8GohkMDARn+JvZOAkbGwN9DZ srLQ3ZMZUHMUlEHcRGzan5kLcygW4hagHvh2TuXdGuLCXNzOz8FcZXXN+A3AdoLy+zHa bVlMibdo3P58GJ/u6Z/dNfoVrIf3yn7NhLbXaQP4dXwa2SAL3GMVW4oKcVptdPTCVHrk 3kGITy+XCu0FUcFv0q+rasxSyvd2APCqOG0z7+Y9hoTxs3+yeiqlfsRy+MBFSFYlLidb RyEla8A3oeNLZpES1Sumj33gMkrCLvEa20o52BEaF7JyknjlHdod25HstgSeGv8/1WH4 YYpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vi8NBOJN; 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 c22-20020ac87dd6000000b003e4eba75ff7si3128599qte.578.2023.03.28.10.32.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Mar 2023 10:32:59 -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=Vi8NBOJN; 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 1phDAf-0004h8-DG; Tue, 28 Mar 2023 13:31:45 -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 1phDAe-0004gO-73 for qemu-devel@nongnu.org; Tue, 28 Mar 2023 13:31:44 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1phDAb-0003SI-DP for qemu-devel@nongnu.org; Tue, 28 Mar 2023 13:31:43 -0400 Received: by mail-wm1-x334.google.com with SMTP id m6-20020a05600c3b0600b003ee6e324b19so8044493wms.1 for ; Tue, 28 Mar 2023 10:31:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680024699; 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=Vi8NBOJNIaL4iwmKYW/PpwzdiWYsFRvUddBLaqryeDI70WY0Oy2d73T0GBar8fT1NB 66DvxYsstnj/vPT+JA6j4E6VyKP0irgJ2/Iy5ci1ndgoiAomaEnQExlQNt644ZApOjSM 5gf0M9tQLUsBOniL4N9ajmop5HVjbUwLVpkn+q2VAZmgnJb7AVenFfmumtwiQITOsfEx t6iYLRcYqbJIfGaFb3NtjMhcApH/+SO/c5MkJFyb8hau3tmKfNx+qt97wNW+SjNkaMCG bsEWeGqllJ7zZKuyYylIGdXnif/MpVMTc7V+uiwStXJ2mx1S9wZRsAJS7VsHHxBCQmJT w8VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680024699; 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=II8RN5W0d8CLHgjdr535bGVIbnIY6d+0QJvpgMkxqmTMnItefQRteveomcC/CeFIhr jna94JO3E3lwAvCLlz07/kw/jYWbiUVRlCuAcsk6lhPqyIAB/exCHtzMZEd462RYL5b2 XeZYf649kcfezToeVrvzjIbDVxyvv9nZBvTfvbasRSApzCYCoLx6evc9Ib9Zk1zhN2tz sqkyWeSqwkETSSodAP5o5X1+sTADD5A4JGZ0G8GfKMO10T33pEHZSdxS6PwxnCAW4AyH 93Lc90VvNbcWqgTNKga/dT44/YvKLoJDpJmUconyoIuB9hBHFr2lsbR3sHn9IAjUNZi9 jtNQ== X-Gm-Message-State: AO0yUKW11x4y1YYHxXr9Mei/3PQBdPX0Y3VI0Ym5ONTd3vRfs1UfESMm +XlaLjvmhG7AmV9ZHXcv4BabjG72lD1KHK0kv9Y= X-Received: by 2002:a05:600c:21d8:b0:3ed:2b49:eefc with SMTP id x24-20020a05600c21d800b003ed2b49eefcmr13475865wmj.3.1680024699656; Tue, 28 Mar 2023 10:31:39 -0700 (PDT) Received: from localhost.localdomain ([176.187.210.212]) by smtp.gmail.com with ESMTPSA id n10-20020a05600c3b8a00b003ede3f5c81fsm13483453wms.41.2023.03.28.10.31.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 28 Mar 2023 10:31:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Halil Pasic , David Gibson , Daniel Henrique Barboza , qemu-ppc@nongnu.org, Yanan Wang , David Hildenbrand , Christian Borntraeger , Eduardo Habkost , Paolo Bonzini , Marcel Apfelbaum , Greg Kurz , kvm@vger.kernel.org, Ilya Leoshkevich , Peter Maydell , Fabiano Rosas , =?utf-8?q?Alex_Benn=C3=A9e?= , Thomas Huth , Richard Henderson , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PATCH-for-8.0 v2 3/3] softmmu: Restore use of CPU watchpoint for all accelerators Date: Tue, 28 Mar 2023 19:31:17 +0200 Message-Id: <20230328173117.15226-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230328173117.15226-1-philmd@linaro.org> References: <20230328173117.15226-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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é Reviewed-by: Fabiano Rosas --- 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(