[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 0/4] Remove unconditional arch dependency on asm/debugger.h


  • To: Bobby Eshleman <bobby.eshleman@xxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Thu, 15 Jul 2021 20:33:14 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pw9MWLCvrlHTL+avR4APXUKKGaKcOwj4dGl7QwaOYVI=; b=n8M+PXlMJD967tgqYAsprnuloOhE3oelwfWfpq/mLfC0AS3Ov81yE8GpvyYJj73BnMObw22qxOx9BVnoxWj5dLE6xrs/Gbn/Vc/0RCVgPhgyB/qO/rxF60n6Up7UBDigu0wSyLEgLAp5/HscgGhRhHyoYRre/AqRIGlYF4PXlkJo5HgUTvX4GiTgdwIWbPsQEbjBEGfNXuMkAKlmjWoWYjONyzug/5ZTfn0ZmU8sLdo7lvNw85kSnHcny/7D23gx4myWiHcFFrZvffgrrPGoVr1iqjOBtHg5eP0O3dPKO1TNjLmApq8mCpmOmWdsIBPcjV0KTDDkoOpy4rPfVTz5pQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j21eh2TZpxqOzNF137ZqjS+msuYfDLDSiVCyI0qbBeWXcaUS1YyxPuogsdfUTnRFldG3HbRysJgwevMdtPX7yU+ZDVsqXhT0jseBJsvAsvtZBOZdRYmfCCjXIUmA2IGesyglCdt4vPdZioDj3BEs+OUKzHb0DCE4dGQwInZgRIR716vUVXYqGvTNBF55VVWARs59gYLNdOGCLn3hsZt7fUzZucsEctvcPSgV3HQm71wSa62Gzv5bqdV+ELMuZoqA10DsLUCF3/Q1JT9LkH9CS1NCKtFgsOCyG6pwF4zCTRgs0F+bTquPLhcXf40AG3vU9T0BiALIFg7sQQgRwohtfw==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "George Dunlap" <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Elena Ufimtseva <elena.ufimtseva@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>
  • Delivery-date: Thu, 15 Jul 2021 19:33:46 +0000
  • Ironport-hdrordr: A9a23:mkAsDaELqXqoqCcSpLqELMeALOsnbusQ8zAXPiBKJCC9E/bo8v xG+c5w6faaslkssR0b9+xoW5PwI080l6QU3WB5B97LMDUO0FHCEGgI1/qA/9SPIUzDHu4279 YbT0B9YueAcGSTW6zBkXWF+9VL+qj5zEix792uq0uE1WtRGtldBwESMHf9LmRGADNoKLAeD5 Sm6s9Ot1ObCA8qhpTSPAhiYwDbzee77a7bXQ==
  • Ironport-sdr: vZn8hqhl/E9QGHRMgNeuP80zw3rvn79xR731YzRmJ3seh0e+RfLPDOPfM6Omhki0fwVd3hCNNc /XqpnPyUg9M56ZVX77kWZ4vxWOVbyJDJtaVSRSTnnTamOooL8mdh+exA5OdnsNrt0RmzIlH4iI 9M7LOffOsXxE/gCV1zXv73bCpsZRD0FyFVukCj0N2QiNQJMKVCft5v+WWSPuYZCyx4bJg5B0E2 H4P3CRIrtVdn+63yeGrk7c+2xXpCN0WWpHoxwbBSVxaBOaj4eXEy/hrkYW8xilunsB/WRCazAf DTo=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14/07/2021 21:37, Bobby Eshleman wrote:
> Currently, any architecture wishing to use common/ is likely
> to be required to implement the functions found in "asm/debugger.h".
> Some architectures, however, do not have an actual use for these
> functions and so are forced to implement stubs.  This patch does the
> following:
>
> * Supplies common stubs if !CONFIG_CRASH_DEBUG for any architecture,
>   removing the need for all new architectures to have "asm/debugger.h".
> * Moves parts of the x86 implementation to "arch/x86/debugger.c".
> * Removes the ARM calls to its stubs.
> * Centralizes non-inlined x86 code conditionally compiled by 
> CONFIG_CRASH_DEBUG
>   into arch/x86/debugger.c, which is now conditionally built for
>   CONFIG_CRASH_DEBUG via Kbuild (i.e., obj-$(CONFIG_CRASH_DEBUG)).
> * Tries to improve the x86 implementation by not inlining large
>   functions (but preserving inlining for those that seemed "small").

My replies from yesterday appear to have got lost.  Lets try it again. 
Jan already picked up on the header file and commit change in patch 1.

However, patch 2 actually demonstrates a massive confusion which exists
in the x86 code.  We have two things called debugger, which are
unrelated, but mixed in asm-x86/debugger.h

There is gdbstub itself, which is an implementation of the gdb remote
debugging protocol over serial.  (I've never seen anyone use this in a
decade, and the logic isn't remotely SMP-safe at all, so I'm very
tempted to suggest ripping it out completely, but lets ignore that for now).

Then we have debugger_trap_*() which claims to be arch-neutral wrappers
to a common debugging interface, which is only actually backed by
gdbstub in x86.  Both of these facilities are to do with debugging Xen
itself when Xen crashes.


Then there is gdbsx which is totally unrelated to the above, and is a
daemon in dom0 to translate the gdb remote protocol into a set of
hypercalls to perform on a guest under test. 
domain_pause_for_debugger() is gdbsx functionality, and nothing to do
with Xen crashing.

On top of that, debugger_trap_entry() is actually a layering violation
merging the two.

Therefore, I recommend the following, in this order:

1) Patch emptying debugger_trap_entry() and expanding the contents
inline in do_int3/debug().  Both already have an if ( !guest_mode() )
path, so add an else if ( ... ) clause.  This supersedes patch 3. 
(Also, fix the logic to have "const struct vcpu *curr = current" and
avoid the opencoded use of current lower down).

curr->arch.gdbsx_vcpu_event only being set for TRAP_int3 looks totally
bogus (the non-int3 paths cause gdbsx to miss notifications), but is
repeated all across Xen.  Keep the logic unchanged across the move, and
leave fixing gdbsx bugs to some future point.

2) Patch (or patches) renaming arch/x86/debug.c to arch/x86/gdbsx.c, and
add a new include/asm-x86/gdbsx.h.

domain_pause_for_debugger() wants moving (prototype and definition)
which subsumes patch 4, and deletes domain.c's include of debugger.h

domctl.s ifdef'd gdbsx_guest_mem_io() wants moving too, as it has one
caller, and is the sole caller of dbg_rw_mem().  The two functions
likely want merging so we don't just have a wrapper making trivial API
change.  This will also require some header file renames.

With this done, there is now a properly split between the
actually-CONFIG_GDBSX stuff and the actually-CONFIG_DEBUG_CRASH stuff.

3) What is currently patch 1 wants to be next, taking with it the header
file rename from patch 2.

4) Finally, the remanent of patch 2.  The CONFIG_CRASH_DEBUG
implementation is now just the gdbstub call in _fatal(), so I don't
think a new debugger.c file is necessary.


Hopefully this all makes sense.

~Andrew




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.