From patchwork Tue Mar 7 21:21:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 659873 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2609180wrb; Tue, 7 Mar 2023 13:32:36 -0800 (PST) X-Google-Smtp-Source: AK7set+r3Le0JmXJOrdXcuIH/ZEKqmFcUdvYNogq4MU8ANPptRE5PulnxvMNyy07I6t3qwnfcDSy X-Received: by 2002:a05:6214:2583:b0:570:bf43:491 with SMTP id fq3-20020a056214258300b00570bf430491mr30143353qvb.5.1678224756523; Tue, 07 Mar 2023 13:32:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678224756; cv=none; d=google.com; s=arc-20160816; b=O7s/cpFvWjkifD9eciCnZVL3w+osobqZzyFIFXB9lg6C72MDqfed3B2e13AltcIxIt wyh1f2MX6N2GroQe5NsIGI1woPVo5ZGQwj8BH5d0d5mpC58E479JQ62D0mptvt4sOEzc euIdqJ1fhH/2dSfrZeFYfTILLcY7UNpLNUF+EZsbTuTOnSelIdKHO4P5z1PLjhIkJgK7 uRb/iWidK3oF1/LWnr162PPtwlluiQdpMPAiJTrUMWxQlgEJSi5j65mpKWiCODc9yNMo rHTU44Gu8oND1GoCe+je9gHyWLKibC4NWlajecWJLVp0UsFzqXaEPhvMhWNyQsto+wc7 j8Xw== 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=az0WJvPDNNwX+FS1YDgiZdT4GlD39LjQSPuXXv/AFss=; b=q/OMz9gPvG3+9KP6sLRpzvqD5lUTRAriQi9hjgr2fS29FdO/q6MsV44WOdS7mlAiJq WrcLwiF7ICaERiTBwneI2wrxyOdOh4vhXi3TLyPK2bAmT3N4HhxFgZtdox6yVneoUkV6 IPNOmOTbvKi14Ylv2HT0hIaEKDdOcUliVezPR4KvHO+jjImr4JOmM8XdiSG0dFGfP5mS QPCES9YeqRnEmumA3wjwV3DU703jL6Jfrsds6KVry8OjXAOPODypQYel0zm83DEEclQL g/ExcufJxj6fNr2A5iFIUUB2o5tVT/U509eb3xfg6bQaE6PKLEbGbUNW8G6SZ1G8V+AM dF4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X8/+OESF"; 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 i10-20020a0cf48a000000b0056ef8dad683si10061687qvm.290.2023.03.07.13.32.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Mar 2023 13:32:36 -0800 (PST) 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="X8/+OESF"; 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 1pZesE-0004kI-6t; Tue, 07 Mar 2023 16:29:30 -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 1pZesC-0004jd-IP for qemu-devel@nongnu.org; Tue, 07 Mar 2023 16:29:28 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZes9-0000w0-0X for qemu-devel@nongnu.org; Tue, 07 Mar 2023 16:29:28 -0500 Received: by mail-wm1-x331.google.com with SMTP id m25-20020a7bcb99000000b003e7842b75f2so14608wmi.3 for ; Tue, 07 Mar 2023 13:29:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678224563; 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=az0WJvPDNNwX+FS1YDgiZdT4GlD39LjQSPuXXv/AFss=; b=X8/+OESFJ/59vp1KnCfhSQMVc4y9MfHJ1PtgU66865g0nHK5+V1HlHQWYRwvlAdvcE CP3sl3WusiFeZY3OxBbRItGbi6k3Q0AskfAQfRPe3QqAvorGatbKxLHuM1RIiCuINrt9 FPCAJexAAuIlWTIf0mCZea+BZVx89Z07Suc5PxUAdC/6kw/a6bZJwqMe9v7VD042ITif atC4tOTXbLf5D8To5/EB3/guJ7AioWcw7XgLwP8Pffx4dUjKe4U2T4C3i/Le850+fwJq wvLYP3/qbHBzZwAF4QZd4WWz2y2kcFjn+p2M6Y5Zgw8VoZHFCIAMDPPz/NGPny8QSN+x iT/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678224563; 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=az0WJvPDNNwX+FS1YDgiZdT4GlD39LjQSPuXXv/AFss=; b=ZafzawERooDi1LTUOigX3nkQ8LdEu4JrVdVCBKHCHRHlg6iyHPY9xv3uxFa1bm7w4v eE+sduU2KaM9Md+HuWLsSAqgVYGRuyrZ4twxIUIzsJ8sI/pTohqQ5TdDioKaZv2TDjBt F60T/yTxnC4bsNMI16DRRoX46xo8lI4L4SXPO5DVwNvnDiwA2IyhZOCts2+TVW2bBpa/ fjJRHx5pXx9A5xSK9CgxG5ACJ27jSC+fuEs99Z+NCq76uMsXPv0glcVdaJQwsYhbDWxV BsdlY+JwbCB/fPpA9KHlPpuJRriN8DB4Fn8CpxgTM5FZNGPrV2lmHcr0PZSV05hy6yTe JOnQ== X-Gm-Message-State: AO0yUKWyrE8wudnJNGksJDqLUUlooBGCpMMFeSk9B3ngupqJQjOnO9lo 20XD8oDtnpCEd9T91DGZNZqANMxdzFlTP+Sw8mU= X-Received: by 2002:a05:600c:470b:b0:3e0:98c:dd93 with SMTP id v11-20020a05600c470b00b003e0098cdd93mr14730509wmo.29.1678224563728; Tue, 07 Mar 2023 13:29:23 -0800 (PST) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id h19-20020a05600c30d300b003db06224953sm13475987wmn.41.2023.03.07.13.29.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Mar 2023 13:29:22 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 75A4D1FFDA; Tue, 7 Mar 2023 21:21:43 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, Mads Ynddal , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , Paolo Bonzini , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang , Richard Henderson , kvm@vger.kernel.org (open list:Overall KVM CPUs) Subject: [PULL 30/30] gdbstub: move update guest debug to accel ops Date: Tue, 7 Mar 2023 21:21:39 +0000 Message-Id: <20230307212139.883112-31-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307212139.883112-1-alex.bennee@linaro.org> References: <20230307212139.883112-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.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 From: Mads Ynddal Continuing the refactor of a48e7d9e52 (gdbstub: move guest debug support check to ops) by removing hardcoded kvm_enabled() from generic cpu.c code, and replace it with a property of AccelOpsClass. Signed-off-by: Mads Ynddal Reviewed-by: Philippe Mathieu-Daudé Message-Id: <20230207131721.49233-1-mads@ynddal.dk> [AJB: add ifdef around update_guest_debug_ops, fix brace] Signed-off-by: Alex Bennée Message-Id: <20230302190846.2593720-27-alex.bennee@linaro.org> Message-Id: <20230303025805.625589-30-richard.henderson@linaro.org> diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h index 30690c71bd..3c1fab4b1e 100644 --- a/include/sysemu/accel-ops.h +++ b/include/sysemu/accel-ops.h @@ -48,6 +48,7 @@ struct AccelOpsClass { /* gdbstub hooks */ bool (*supports_guest_debug)(void); + int (*update_guest_debug)(CPUState *cpu); int (*insert_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len); int (*remove_breakpoint)(CPUState *cpu, int type, vaddr addr, vaddr len); void (*remove_all_breakpoints)(CPUState *cpu); diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index fbf4fe3497..457eafa380 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -86,6 +86,13 @@ static bool kvm_cpus_are_resettable(void) return !kvm_enabled() || kvm_cpu_check_are_resettable(); } +#ifdef KVM_CAP_SET_GUEST_DEBUG +static int kvm_update_guest_debug_ops(CPUState *cpu) +{ + return kvm_update_guest_debug(cpu, 0); +} +#endif + static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) { AccelOpsClass *ops = ACCEL_OPS_CLASS(oc); @@ -99,6 +106,7 @@ static void kvm_accel_ops_class_init(ObjectClass *oc, void *data) ops->synchronize_pre_loadvm = kvm_cpu_synchronize_pre_loadvm; #ifdef KVM_CAP_SET_GUEST_DEBUG + ops->update_guest_debug = kvm_update_guest_debug_ops; ops->supports_guest_debug = kvm_supports_guest_debug; ops->insert_breakpoint = kvm_insert_breakpoint; ops->remove_breakpoint = kvm_remove_breakpoint; diff --git a/cpu.c b/cpu.c index e6abc6c76c..567b23af46 100644 --- a/cpu.c +++ b/cpu.c @@ -31,8 +31,8 @@ #include "hw/core/sysemu-cpu-ops.h" #include "exec/address-spaces.h" #endif +#include "sysemu/cpus.h" #include "sysemu/tcg.h" -#include "sysemu/kvm.h" #include "exec/replay-core.h" #include "exec/cpu-common.h" #include "exec/exec-all.h" @@ -326,9 +326,14 @@ void cpu_single_step(CPUState *cpu, int enabled) { if (cpu->singlestep_enabled != enabled) { cpu->singlestep_enabled = enabled; - if (kvm_enabled()) { - kvm_update_guest_debug(cpu, 0); + +#if !defined(CONFIG_USER_ONLY) + const AccelOpsClass *ops = cpus_get_accel(); + if (ops->update_guest_debug) { + ops->update_guest_debug(cpu); } +#endif + trace_breakpoint_singlestep(cpu->cpu_index, enabled); } }