From patchwork Tue Sep 27 14:15:03 2022 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: 609613 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp429907pvb; Tue, 27 Sep 2022 08:54:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/J7IQqqdtVkpc4RNt6uEnTxkFrQ90gxtU3mIvN5IvMSN9IDK+pRWOaMovDdLWi727y55J X-Received: by 2002:a05:6214:4017:b0:4ac:6db5:66f0 with SMTP id kd23-20020a056214401700b004ac6db566f0mr22416341qvb.105.1664294061850; Tue, 27 Sep 2022 08:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664294061; cv=none; d=google.com; s=arc-20160816; b=ZycIld+dhqjzMGDt7lgJ+9aQl+X2dCGmy4ZWmt8xu1vceI+oJ5FSDoN524iKL0Rt77 vsCMngB2Cd/AcMqsUbvx8BrhUPRuFbCNAeHE9NZIReoTRPgmFYI3taxOAi8b3Jbwnu6j QDr+m9UWEzzUkWSwY+7IVji8wv0RzpX+oQjN5txHcCjG2VKooxBQin9GgoRIBicVd4mK O/EkF2EMQ7+A2eI13z2JnkDP50S+1d8g9UsYZAEUAv6VIHMNL0iM2fqlJFAq2wF1KdjN 3xq4dmvFnDihIMdK+o3exE///pTDij36wDQLRpoRYCt7MBp0VL4n46uD/rniN+4bhB0+ 104Q== 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=vjojPbAZCZTm66THKz2INVh3tZm0jABrqXmO5V1a0wU=; b=A+R3xPGzVP8iZgtXxuoe6Zn7RoN/myWtJiEv3f5auZWf3zeH9ZX/orbVCo8AXmEssJ Y0CLdpLXZ5xTPpF0dKHppd1apiSVo4W+lLUbVe15kz/6IgeFp6DtxmTVesAVujjdyj1d MTDSIRiWPN8G1AYYcqArYbpzt4s1ggrassI/W/5rGOQlN+5kDG352LLfnjgO5llIzbNe SejBC2yBKp0Tk9fkCVhwvc8btigsmPJdxYgNO4FaLFiybdoWUCKXHVJcNl5bLOBPTcHF 5TnGxzUbkdI1cLt08oUx/JNFA6KlstuSflWzlI8GY50fFje+JiqwRNqwmtOyShi32wbS SM5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bOncOETT; 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 i2-20020a05620a27c200b006be5a7cd63csi1023448qkp.224.2022.09.27.08.54.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Sep 2022 08:54:21 -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=bOncOETT; 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]:36664 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1odCub-0001z8-Cm for patch@linaro.org; Tue, 27 Sep 2022 11:54:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1odBMp-0005Et-QD for qemu-devel@nongnu.org; Tue, 27 Sep 2022 10:15:23 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:46734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1odBMl-00062E-Ki for qemu-devel@nongnu.org; Tue, 27 Sep 2022 10:15:22 -0400 Received: by mail-wm1-x336.google.com with SMTP id n40-20020a05600c3ba800b003b49aefc35fso5517191wms.5 for ; Tue, 27 Sep 2022 07:15:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=vjojPbAZCZTm66THKz2INVh3tZm0jABrqXmO5V1a0wU=; b=bOncOETTUL52OFCBTuM6WiteaXsBwHa8z81wgpPagwiAIvVOm4UmMX1d3Gr7Pnz+/S e0qWcNNoSWL3Ac3fbZeK0pTCVRYP38cmKZjSJV3f7dth683kApw0iKYbunASionRqiFi Zw+6NpqJgTW8n7Ea8urXSsQ431pj5nF3hdXI5IKF3ztD/b8eDRYCoAMFEHjACwa4PCBx woURAwnaHiQBJ1eIV5tYz+H+gTkvrBmMsx0BQX7g3uFG0dB3illtXRJ0l/KcXsBkFRoc tzc1kkTLFIXbz4JMFBnb2Vy7DXHaD7W8y0/RWbg57yKnzDP92y/X/wBf7SdSiNKGnIRr DbLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=vjojPbAZCZTm66THKz2INVh3tZm0jABrqXmO5V1a0wU=; b=LpOOLEpPYUE9EZfPsI767t27I8qa/UAiRwUvPLLrt2IVlZYCYljx4bCS7tSrhg+mdn CE0Wlb29WJ3AG9Z3PumRypRhWcTEKRESUjm7T8JmBTNU/pQsiuSRXu90L/pMPQ1vhnKK C0MXmUvRv9qUyff2aPtFBEb4W/bQ03ppz+7A8AlIK/wbV32lgliRE3k5H1vYZm4VTile cynCnYhOHJ0zkmDNJ/pO2GdjH0zSCUVS/LDiY1wcduEC0ZpZSYVWYyPal87zx7FsH7t3 nJbGwg8lcr35OZS7FRFT7XUdBkop7Q3oYfnnRixX+QSTwQySxFjNSDDsKmHUeopgSPw6 mkkg== X-Gm-Message-State: ACrzQf3heezarhT1p32BKWWg0M5VqcJyN3ngzsEDEjASd2o+RPxPycsH dv99SDil3BmI7pj31Dk4CwqsHQ== X-Received: by 2002:a1c:4c18:0:b0:3b4:9b1d:5501 with SMTP id z24-20020a1c4c18000000b003b49b1d5501mr2884277wmf.13.1664288116334; Tue, 27 Sep 2022 07:15:16 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id d4-20020adffd84000000b0022b0064841esm1281877wrr.59.2022.09.27.07.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 07:15:11 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0308F1FFBA; Tue, 27 Sep 2022 15:15:09 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , Mads Ynddal , Paolo Bonzini , Richard Henderson , kvm@vger.kernel.org (open list:Overall KVM CPUs) Subject: [PATCH v3 14/15] gdbstub: move guest debug support check to ops Date: Tue, 27 Sep 2022 15:15:03 +0100 Message-Id: <20220927141504.3886314-15-alex.bennee@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220927141504.3886314-1-alex.bennee@linaro.org> References: <20220927141504.3886314-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x336.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" This removes the final hard coding of kvm_enabled() in gdbstub and moves the check to an AccelOps. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Cc: Mads Ynddal Reviewed-by: Mads Ynddal --- accel/kvm/kvm-cpus.h | 1 + gdbstub/internals.h | 1 + include/sysemu/accel-ops.h | 1 + include/sysemu/kvm.h | 7 ------- accel/kvm/kvm-accel-ops.c | 1 + accel/kvm/kvm-all.c | 6 ++++++ accel/tcg/tcg-accel-ops.c | 6 ++++++ gdbstub/gdbstub.c | 5 ++--- gdbstub/softmmu.c | 9 +++++++++ gdbstub/user.c | 6 ++++++ 10 files changed, 33 insertions(+), 10 deletions(-) diff --git a/accel/kvm/kvm-cpus.h b/accel/kvm/kvm-cpus.h index 33e435d62b..fd63fe6a59 100644 --- a/accel/kvm/kvm-cpus.h +++ b/accel/kvm/kvm-cpus.h @@ -18,6 +18,7 @@ void kvm_destroy_vcpu(CPUState *cpu); void kvm_cpu_synchronize_post_reset(CPUState *cpu); void kvm_cpu_synchronize_post_init(CPUState *cpu); void kvm_cpu_synchronize_pre_loadvm(CPUState *cpu); +bool kvm_supports_guest_debug(void); int kvm_insert_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len); int kvm_remove_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len); void kvm_remove_all_breakpoints(CPUState *cpu); diff --git a/gdbstub/internals.h b/gdbstub/internals.h index 41e2e72dbf..eabb0341d1 100644 --- a/gdbstub/internals.h +++ b/gdbstub/internals.h @@ -9,6 +9,7 @@ #ifndef _INTERNALS_H_ #define _INTERNALS_H_ +bool gdb_supports_guest_debug(void); int gdb_breakpoint_insert(CPUState *cs, int type, hwaddr addr, hwaddr len); int gdb_breakpoint_remove(CPUState *cs, int type, hwaddr addr, hwaddr len); void gdb_breakpoint_remove_all(CPUState *cs); diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h index 86794ac273..8cc7996def 100644 --- a/include/sysemu/accel-ops.h +++ b/include/sysemu/accel-ops.h @@ -47,6 +47,7 @@ struct AccelOpsClass { int64_t (*get_elapsed_ticks)(void); /* gdbstub hooks */ + bool (*supports_guest_debug)(void); int (*insert_breakpoint)(CPUState *cpu, int type, hwaddr addr, hwaddr len); int (*remove_breakpoint)(CPUState *cpu, int type, hwaddr addr, hwaddr len); void (*remove_all_breakpoints)(CPUState *cpu); diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 21d3f1d01e..6e1bd01725 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -46,7 +46,6 @@ extern bool kvm_readonly_mem_allowed; extern bool kvm_direct_msi_allowed; extern bool kvm_ioeventfd_any_length_allowed; extern bool kvm_msi_use_devid; -extern bool kvm_has_guest_debug; #define kvm_enabled() (kvm_allowed) /** @@ -168,11 +167,6 @@ extern bool kvm_has_guest_debug; */ #define kvm_msi_devid_required() (kvm_msi_use_devid) -/* - * Does KVM support guest debugging - */ -#define kvm_supports_guest_debug() (kvm_has_guest_debug) - #else #define kvm_enabled() (0) @@ -190,7 +184,6 @@ extern bool kvm_has_guest_debug; #define kvm_direct_msi_enabled() (false) #define kvm_ioeventfd_any_length_enabled() (false) #define kvm_msi_devid_required() (false) -#define kvm_supports_guest_debug() (false) #endif /* CONFIG_KVM_IS_POSSIBLE */ diff --git a/accel/kvm/kvm-accel-ops.c b/accel/kvm/kvm-accel-ops.c index 5c0e37514c..fbf4fe3497 100644 --- a/accel/kvm/kvm-accel-ops.c +++ b/accel/kvm/kvm-accel-ops.c @@ -99,6 +99,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->supports_guest_debug = kvm_supports_guest_debug; ops->insert_breakpoint = kvm_insert_breakpoint; ops->remove_breakpoint = kvm_remove_breakpoint; ops->remove_all_breakpoints = kvm_remove_all_breakpoints; diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index b8c734fe3a..6ebff6e5a6 100644 --- a/accel/kvm/kvm-all.c +++ b/accel/kvm/kvm-all.c @@ -3287,6 +3287,12 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap) return data.err; } +bool kvm_supports_guest_debug(void) +{ + /* probed during kvm_init() */ + return kvm_has_guest_debug; +} + int kvm_insert_breakpoint(CPUState *cpu, int type, hwaddr addr, hwaddr len) { struct kvm_sw_breakpoint *bp; diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 965c2ad581..19cbf1db3a 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -93,6 +93,11 @@ void tcg_handle_interrupt(CPUState *cpu, int mask) } } +static bool tcg_supports_guest_debug(void) +{ + return true; +} + /* Translate GDB watchpoint type to a flags value for cpu_watchpoint_* */ static inline int xlat_gdb_type(CPUState *cpu, int gdbtype) { @@ -198,6 +203,7 @@ static void tcg_accel_ops_init(AccelOpsClass *ops) } } + ops->supports_guest_debug = tcg_supports_guest_debug; ops->insert_breakpoint = tcg_insert_breakpoint; ops->remove_breakpoint = tcg_remove_breakpoint; ops->remove_all_breakpoints = tcg_remove_all_breakpoints; diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c index ff9f3f9586..be88ca0d71 100644 --- a/gdbstub/gdbstub.c +++ b/gdbstub/gdbstub.c @@ -45,7 +45,6 @@ #include "qemu/sockets.h" #include "sysemu/hw_accel.h" -#include "sysemu/kvm.h" #include "sysemu/runstate.h" #include "semihosting/semihost.h" #include "exec/exec-all.h" @@ -3447,8 +3446,8 @@ int gdbserver_start(const char *device) return -1; } - if (kvm_enabled() && !kvm_supports_guest_debug()) { - error_report("gdbstub: KVM doesn't support guest debugging"); + if (!gdb_supports_guest_debug()) { + error_report("gdbstub: current accelerator doesn't support guest debugging"); return -1; } diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c index 4e73890379..f208c6cf15 100644 --- a/gdbstub/softmmu.c +++ b/gdbstub/softmmu.c @@ -15,6 +15,15 @@ #include "sysemu/cpus.h" #include "internals.h" +bool gdb_supports_guest_debug(void) +{ + const AccelOpsClass *ops = cpus_get_accel(); + if (ops->supports_guest_debug) { + return ops->supports_guest_debug(); + } + return false; +} + int gdb_breakpoint_insert(CPUState *cs, int type, hwaddr addr, hwaddr len) { const AccelOpsClass *ops = cpus_get_accel(); diff --git a/gdbstub/user.c b/gdbstub/user.c index 42652b28a7..033e5fdd71 100644 --- a/gdbstub/user.c +++ b/gdbstub/user.c @@ -14,6 +14,12 @@ #include "hw/core/cpu.h" #include "internals.h" +bool gdb_supports_guest_debug(void) +{ + /* user-mode == TCG == supported */ + return true; +} + int gdb_breakpoint_insert(CPUState *cs, int type, hwaddr addr, hwaddr len) { CPUState *cpu;