From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D122FC433EF for ; Wed, 13 Oct 2021 19:54:48 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 42A1361040 for ; Wed, 13 Oct 2021 19:54:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 42A1361040 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:54016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1makKt-0003c2-EP for qemu-devel@archiver.kernel.org; Wed, 13 Oct 2021 15:54:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1makIu-0001UK-1x for qemu-devel@nongnu.org; Wed, 13 Oct 2021 15:52:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27700) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1makIq-0001P7-At for qemu-devel@nongnu.org; Wed, 13 Oct 2021 15:52:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634154759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Bt6pdkI9efYxb2PaM1vRt2x7pgoGbklMN/ZpR9EusM=; b=SxI8AMOmJJBNPhQK6Vluo+Fz64WwRJfA518EZCHz3McWz6awwsTetr+1jolMxCiPuJ8fqe sjJB1vQ3c9ttQoyU7ymcYRKr6JPFZGg1A/Opjlx5Z/cNj1gxAAj+smHk3uoKO2Y8IhClMB QVkgYLGXBSQXILuwtScNUGY8M6chQt4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-Wp-nIAvtPW2Y9SZ5XPm0Zg-1; Wed, 13 Oct 2021 15:52:38 -0400 X-MC-Unique: Wp-nIAvtPW2Y9SZ5XPm0Zg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 51318802936; Wed, 13 Oct 2021 19:52:37 +0000 (UTC) Received: from starship (unknown [10.35.206.50]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F7E75F4EA; Wed, 13 Oct 2021 19:52:02 +0000 (UTC) Message-ID: <01068d813041258eba607c38f33f7cb13b1026a4.camel@redhat.com> Subject: Re: [PATCH 2/3] gdbstub: implement NOIRQ support for single step on KVM From: Maxim Levitsky To: Alex =?ISO-8859-1?Q?Benn=E9e?= Date: Wed, 13 Oct 2021 22:52:01 +0300 In-Reply-To: <87v920vs1v.fsf@linaro.org> References: <20210914155214.105415-1-mlevitsk@redhat.com> <20210914155214.105415-3-mlevitsk@redhat.com> <87v920vs1v.fsf@linaro.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Received-SPF: pass client-ip=170.10.133.124; envelope-from=mlevitsk@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.049, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Marcelo Tosatti , Philippe =?ISO-8859-1?Q?Mathieu-Daud=E9?= , qemu-devel@nongnu.org, kvm@vger.kernel.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Wed, 2021-10-13 at 16:50 +0100, Alex Bennée wrote: > Maxim Levitsky writes: > > > Signed-off-by: Maxim Levitsky > > --- > > accel/kvm/kvm-all.c | 25 ++++++++++++++++++ > > gdbstub.c | 60 ++++++++++++++++++++++++++++++++++++-------- > > include/sysemu/kvm.h | 13 ++++++++++ > > 3 files changed, 88 insertions(+), 10 deletions(-) > > > > diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c > > index 6b187e9c96..e141260796 100644 > > --- a/accel/kvm/kvm-all.c > > +++ b/accel/kvm/kvm-all.c > > @@ -169,6 +169,8 @@ bool kvm_vm_attributes_allowed; > > bool kvm_direct_msi_allowed; > > bool kvm_ioeventfd_any_length_allowed; > > bool kvm_msi_use_devid; > > +bool kvm_has_guest_debug; > > +int kvm_sstep_flags; > > static bool kvm_immediate_exit; > > static hwaddr kvm_max_slot_size = ~0; > > > > @@ -2559,6 +2561,25 @@ static int kvm_init(MachineState *ms) > > kvm_sregs2 = > > (kvm_check_extension(s, KVM_CAP_SREGS2) > 0); > > > > + kvm_has_guest_debug = > > + (kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG) > 0); > > + > > + kvm_sstep_flags = 0; > > + > > + if (kvm_has_guest_debug) { > > + /* Assume that single stepping is supported */ > > + kvm_sstep_flags = SSTEP_ENABLE; > > + > > + int guest_debug_flags = > > + kvm_check_extension(s, KVM_CAP_SET_GUEST_DEBUG2); > > + > > + if (guest_debug_flags > 0) { > > + if (guest_debug_flags & KVM_GUESTDBG_BLOCKIRQ) { > > + kvm_sstep_flags |= SSTEP_NOIRQ; > > + } > > + } > > + } > > + > > kvm_state = s; > > > > ret = kvm_arch_init(ms, s); > > @@ -3188,6 +3209,10 @@ int kvm_update_guest_debug(CPUState *cpu, unsigned long reinject_trap) > > > > if (cpu->singlestep_enabled) { > > data.dbg.control |= KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_SINGLESTEP; > > + > > + if (cpu->singlestep_enabled & SSTEP_NOIRQ) { > > + data.dbg.control |= KVM_GUESTDBG_BLOCKIRQ; > > + } > > } > > kvm_arch_update_guest_debug(cpu, &data.dbg); > > > > diff --git a/gdbstub.c b/gdbstub.c > > index 5d8e6ae3cd..48bb803bae 100644 > > --- a/gdbstub.c > > +++ b/gdbstub.c > > @@ -368,12 +368,11 @@ typedef struct GDBState { > > gdb_syscall_complete_cb current_syscall_cb; > > GString *str_buf; > > GByteArray *mem_buf; > > + int sstep_flags; > > + int supported_sstep_flags; > > } GDBState; > > > > -/* By default use no IRQs and no timers while single stepping so as to > > - * make single stepping like an ICE HW step. > > - */ > > -static int sstep_flags = SSTEP_ENABLE|SSTEP_NOIRQ|SSTEP_NOTIMER; > > +static GDBState gdbserver_state; > > > > /* Retrieves flags for single step mode. */ > > static int get_sstep_flags(void) > > @@ -385,11 +384,10 @@ static int get_sstep_flags(void) > > if (replay_mode != REPLAY_MODE_NONE) { > > return SSTEP_ENABLE; > > } else { > > - return sstep_flags; > > + return gdbserver_state.sstep_flags; > > } > > } > > > > -static GDBState gdbserver_state; > > > > static void init_gdbserver_state(void) > > { > > @@ -399,6 +397,23 @@ static void init_gdbserver_state(void) > > gdbserver_state.str_buf = g_string_new(NULL); > > gdbserver_state.mem_buf = g_byte_array_sized_new(MAX_PACKET_LENGTH); > > gdbserver_state.last_packet = g_byte_array_sized_new(MAX_PACKET_LENGTH + 4); > > + > > + > > + if (kvm_enabled()) { > > + gdbserver_state.supported_sstep_flags = kvm_get_supported_sstep_flags(); > > + } else { > > + gdbserver_state.supported_sstep_flags = > > + SSTEP_ENABLE | SSTEP_NOIRQ | SSTEP_NOTIMER; > > + } > > This fails to build: > > o -c ../../gdbstub.c > ../../gdbstub.c: In function ‘init_gdbserver_state’: > ../../gdbstub.c:403:49: error: implicit declaration of function ‘kvm_get_supported_sstep_flags’ [-Werror=implicit-function-declaration] > 403 | gdbserver_state.supported_sstep_flags = kvm_get_supported_sstep_flags(); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../gdbstub.c:403:49: error: nested extern declaration of ‘kvm_get_supported_sstep_flags’ [-Werror=nested-externs] > ../../gdbstub.c: In function ‘gdbserver_start’: > ../../gdbstub.c:3531:27: error: implicit declaration of function ‘kvm_supports_guest_debug’; did you mean ‘kvm_update_guest_debug’? [-Werror=implicit-function-declaration] > 3531 | if (kvm_enabled() && !kvm_supports_guest_debug()) { > | ^~~~~~~~~~~~~~~~~~~~~~~~ > | kvm_update_guest_debug > ../../gdbstub.c:3531:27: error: nested extern declaration of ‘kvm_supports_guest_debug’ [-Werror=nested-externs] > cc1: all warnings being treated as errors > > In fact looking back I can see I mentioned this last time: > > Subject: Re: [PATCH 2/2] gdbstub: implement NOIRQ support for single step on > KVM, when kvm's KVM_GUESTDBG_BLOCKIRQ debug flag is supported. > Date: Mon, 19 Apr 2021 17:29:25 +0100 > In-reply-to: <20210401144152.1031282-3-mlevitsk@redhat.com> > Message-ID: <871rb69qqk.fsf@linaro.org> > > Please in future could you include a revision number for your spin and > mention bellow the --- what changes have been made since the last > posting. You mean it fails to build without KVM? I swear I tested build with TTG only after you mentioned this (or as it seems I only tried to). Could you give me the ./configure parameters you used? Sorry for this! Best regards, Maxim Levitsky > >