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

Re: [PATCH v3 2/6] x86/debugger: separate Xen and guest debugging debugger_trap_* functions


  • To: Bobby Eshleman <bobby.eshleman@xxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 24 Aug 2021 12:26:34 +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=PaXmZZWfOQnh5Uqnd7+tz6N1KiG5HkP1DbeFPUnPszM=; b=WszYnsGpnWT82RZtM/2SvaL2gTlUooIn19UdtdfadT+D1OsAvpiX4wv8MfbUEizZ6r90KmLfms+ZxshDwTz5AH0R8aRkGbHWhjvw3LfFAR/Lfu1yo+HKV5fzjdf2B4mTJmX1WXV8xovLQYATt6hQ8IdfDU4KWHjltOCLzEtIjAZp85UHvyOs5XGeA/F+D9wUN6OkZWc82zl0MZdFrsLTF89ZlW4/ldG+2YrRuVjWARw/hNpjwmo3nl0l5qvsCAMbgBAgdcVfvm8O/tGltJNceupZ8vu8n5O27nDKwWbmN7+77rN9UCfErC6VG+6YWEsmbTPBHsJorA/Z0USyhslGdg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gDQ6jHNuVsA+LfvAlJ9B49uDtYZqVy43ojdWC7r5WM1/UMo8QJseo7Sk/6kyUZBrcp/cEWxbbmenLcNnO8NIpSkhHixPCMzWgPaQGGn0nCDzY6+1zez7M8uo6S8xdlPo4AjRZXbwOPm/ZVW3pG6zqn3I/1MaoDjIBWcaDMaR7MYczurKMpX1GzfZSyT+VWUz6sje6T16PKHbtKLRgtJPuVSrMXrJFIWhzPpZxuhWhMgtyEj/Lx0MfwDjQC6wyxJbw68IlLQSA9o2kxl822TnlI9ZNUxdiVyX/yYT1dFMxvqB2O6/651SJ485e5dToZDR4g1Y77okTPlD4s3mLdNt0w==
  • Authentication-results: esa3.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>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Elena Ufimtseva <elena.ufimtseva@xxxxxxxxxx>, Jun Nakajima <jun.nakajima@xxxxxxxxx>, Kevin Tian <kevin.tian@xxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>
  • Delivery-date: Tue, 24 Aug 2021 11:26:53 +0000
  • Ironport-hdrordr: A9a23:Xk1NeaNqKyASPcBcT0T155DYdb4zR+YMi2TDiHofdfUFSKClfp 6V8cjztSWUtN4QMEtQ/OxoS5PwPk80kqQFnbX5XI3SITUO3VHHEGgM1/qb/9SNIVyYygcZ79 YbT0EcMqyBMbEZt7eC3ODQKb9Jq7PmgcPY99s2jU0dKT2CA5sQnjuRYTzrdHGeKjM2Z6bRWK Dsnfau8FGbCAoqh4mAdzc4t6+pnay8qLvWJTo9QzI34giHij2lrJb8Dhijxx8bFxdC260r/2 TpmxHwovzLiYD69jbsk0voq7hGktrozdVOQOSKl8guMz3pziKlfp5oVbGutC085Muv9FEput /RpApIBbUz11rhOkWO5Tf90Qjp1zgjr1fk1F+jmHPm5ff0QTorYvAxyL5xQ1/80Q4Nrdt82K VE0yayrJxMFy7Nmyz7+pzhSwxqvlDcmwtmrccjy1hkFacOYr5YqoISuGlPFo0bIS784Ic7VM FzEcDn4upMe1/yVQGagoBW+q3qYp0PJGbBfqBb0fbligS+3UoJjHfw/fZv2kvpr/kGOsF5D4 2uCNUaqFlMJvVmJ56VSt1xGvdepwT2MFvx2VmpUCDa/Zc8SjnwQq7MkcAIDd6RCes1JbsJ6d j8uQBjxCEPk3yHM7zH4HQMyGGWfFmA
  • Ironport-sdr: TQg+DA0nzjWUkqws9TPicD8s/Np1hsmZF1Gc66qxLdGgkXweL5jFMQ6pE0gZJvkKo40ZnNB7ci kxddi2ZRMnt2W/HBUor19ocuiIgvJI+lpLr3Taw5JQ7KIh1B6JwdXIlnMFZvYcM32LFvXdsWMM HQTv4dp4RfjPVpvmOfKROXSZyQoQsZ8VOPzsBO84B95m+T/SBjT3S15Le+/AuXZxLg6qvwNTGv rs28muBUZ1p0wZ3t8gypnKvK1yxOkVR0qZH1G63etEeGXLiDjTIRrR9tsTDjIndDjdpCugjisl iuqyldVxOWQ6GfBQGqFMfSXS
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 18/08/2021 21:29, Bobby Eshleman wrote:
> diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
> index e60af16ddd..d0a4c0ea74 100644
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -858,13 +858,20 @@ static void do_trap(struct cpu_user_regs *regs)
>      if ( regs->error_code & X86_XEC_EXT )
>          goto hardware_trap;
>  
> -    if ( debugger_trap_entry(trapnr, regs) )
> -        return;
> -
>      ASSERT(trapnr < 32);
>  
>      if ( guest_mode(regs) )
>      {
> +        struct vcpu *curr = current;
> +        if ( (trapnr == TRAP_debug || trapnr == TRAP_int3) &&
> +              guest_kernel_mode(curr, regs) &&
> +              curr->domain->debugger_attached )
> +        {
> +            if ( trapnr != TRAP_debug )
> +                curr->arch.gdbsx_vcpu_event = trapnr;
> +            domain_pause_for_debugger();
> +            return;
> +        }

There's no need for this.  Both TRAP_debug and TRAP_int3 have their own
custom handers, and don't use do_trap().

> @@ -1215,6 +1218,12 @@ void do_int3(struct cpu_user_regs *regs)
>  
>          return;
>      }
> +    else if ( guest_kernel_mode(curr, regs) && 
> curr->domain->debugger_attached )

if ( foo ) { ...; return; } else if ( bar )  is a dangerous anti-pattern.

This should just be a plain if().

> @@ -1994,6 +1994,11 @@ void do_debug(struct cpu_user_regs *regs)
>  
>          return;
>      }
> +    else if ( guest_kernel_mode(v, regs) && v->domain->debugger_attached )

Same here.

> @@ -2028,6 +2030,12 @@ void do_entry_CP(struct cpu_user_regs *regs)
>       */
>      if ( guest_mode(regs) )
>      {
> +        struct vcpu *curr = current;
> +        if ( guest_kernel_mode(curr, regs) && 
> curr->domain->debugger_attached )
> +        {
> +            domain_pause_for_debugger();
> +            return;
> +        }
>          gprintk(XENLOG_ERR, "Hit #CP[%04x] in guest context %04x:%p\n",
>                  ec, regs->cs, _p(regs->rip));
>          ASSERT_UNREACHABLE();

This path is fatal to Xen, because it should be impossible.  If we ever
get around to supporting CET for PV guests, #CP still isn't #DB/#BP so
shouldn't pause for the debugger.

I can fix all of these on commit.

~Andrew




 


Rackspace

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