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

Re: [PATCH v2] x86: Fix XEN_DOMCTL_gdbsx_guestmemio crash


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 25 Apr 2022 13:04:36 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D8LqPUEqPTc5d5HzZHn/6C/8BcpKRavIT4XXO9jbtj4=; b=EDMr+bLHOG0bu1eTFH3ELTMj6N6Mm12B2yr6xvNFw1RlSyHjNQ3cqyb5VLMh/cIYthA9SWuWS7M/x0Cy74+x/7ec65ittqQVClxylVBtoVbhd4EZzdouRO34l+A41jTxUifEGWYHYDllHG6ll/eOUDLa6Z8jxgXbiJCIC1ioli/EP32NWw/kfQLfamu+a5JGHbOoXZGhgXp+3IbVLbxz7BDhFFUQd+t3SW013O2duHiVyHKoEWMlACkJLUekwXogU/mknZJI0vUmQ/BD1O3rVXB2Ei7+J2lij6mvczL+tmsTXuZI2oBfqn5CpCvYwHTsz53P0R/Z2cLcRvLcKYR8Xw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PZMP1F0C9KG46MI1Ol5lIrNA/sRRdRhHWVgmI78pUYcNeu8zfBg89OCH833vhRs+cMMn68UdanuvMajycZLD8vvGz5SRdHA9kWuX5Xq8A/AA36TNn97PpR5aSqvSrTWQsA3tPr8awetZHr70oUwC4JeDirgiHqKCktvD6uvS+OrAfOZeGgKMHUr9+sW4cUQRNSHzCtrdpvhChkm7SC3I6k9Ya7d8nFPxGVo2If6QLI4oTzXGWoS+Ve27H/scCHMa4GZpFZaOia/h6rTMhev9qbAMPugDkQg9jGwWym62WAzdjKllHxPIvsrMnM2Ibkf+4cJFBt7LM3T3Fy+Rvbbe4Q==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 25 Apr 2022 11:04:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 25.04.2022 12:06, Andrew Cooper wrote:
> @@ -178,6 +179,71 @@ void domain_pause_for_debugger(void)
>          send_global_virq(VIRQ_DEBUGGER);
>  }
>  
> +long gdbsx_domctl(struct domain *d, struct xen_domctl *domctl, bool 
> *copyback)

Is there anything that requires "long" (and not just "int") here and ...

> +{
> +    struct vcpu *v;
> +    long ret = 0;

... here?

> +    switch ( domctl->cmd )
> +    {
> +    case XEN_DOMCTL_gdbsx_guestmemio:
> +        ret = gdbsx_guest_mem_io(d, &domctl->u.gdbsx_guest_memio);
> +        if ( !ret )
> +            *copyback = true;
> +        break;
> +
> +    case XEN_DOMCTL_gdbsx_pausevcpu:
> +        ret = -EBUSY;
> +        if ( !d->controller_pause_count )
> +            break;
> +        ret = -EINVAL;
> +        if ( (v = domain_vcpu(d, domctl->u.gdbsx_pauseunp_vcpu.vcpu)) == 
> NULL )
> +            break;
> +        ret = vcpu_pause_by_systemcontroller(v);
> +        break;
> +
> +    case XEN_DOMCTL_gdbsx_unpausevcpu:
> +        ret = -EBUSY;
> +        if ( !d->controller_pause_count )
> +            break;
> +        ret = -EINVAL;
> +        if ( (v = domain_vcpu(d, domctl->u.gdbsx_pauseunp_vcpu.vcpu)) == 
> NULL )
> +            break;
> +        ret = vcpu_unpause_by_systemcontroller(v);
> +        if ( ret == -EINVAL )
> +            printk(XENLOG_G_WARNING
> +                   "WARN: %pd attempting to unpause %pv which is not 
> paused\n",
> +                   current->domain, v);
> +        break;
> +
> +    case XEN_DOMCTL_gdbsx_domstatus:
> +        domctl->u.gdbsx_domstatus.vcpu_id = -1;
> +        domctl->u.gdbsx_domstatus.paused = d->controller_pause_count > 0;
> +        if ( domctl->u.gdbsx_domstatus.paused )
> +        {
> +            for_each_vcpu ( d, v )
> +            {
> +                if ( v->arch.gdbsx_vcpu_event )
> +                {
> +                    domctl->u.gdbsx_domstatus.vcpu_id = v->vcpu_id;
> +                    domctl->u.gdbsx_domstatus.vcpu_ev =
> +                        v->arch.gdbsx_vcpu_event;
> +                    v->arch.gdbsx_vcpu_event = 0;
> +                    break;
> +                }
> +            }
> +        }
> +        *copyback = true;
> +        break;
> +
> +    default:
> +        ASSERT_UNREACHABLE();
> +        ret = -ENOSYS;
> +    }

Just as a remark: It's never really clear to me whether we actually want
to permit omitting "break" in cases like this one. It always feels
slightly risky towards someone subsequently adding another case label
below here without adding the suddenly necessary "break". While for
sentinel code like this doing so may be okay, it would seem to me that
we might be better off not allowing omission of "break" anywhere.

> --- a/xen/arch/x86/include/asm/gdbsx.h
> +++ b/xen/arch/x86/include/asm/gdbsx.h
> @@ -2,18 +2,27 @@
>  #ifndef __X86_GDBX_H__
>  #define __X86_GDBX_H__
>  
> -#ifdef CONFIG_GDBSX
> +#include <xen/stdbool.h>
>  
>  struct domain;
> -struct xen_domctl_gdbsx_memio;
> +struct xen_domctl;
>  
> -int gdbsx_guest_mem_io(struct domain *d, struct xen_domctl_gdbsx_memio *iop);
> +#ifdef CONFIG_GDBSX
>  
>  void domain_pause_for_debugger(void);
>  
> +long gdbsx_domctl(struct domain *d, struct xen_domctl *domctl, bool 
> *copyback);
> +
>  #else
>  
> +#include <xen/errno.h>
> +
>  static inline void domain_pause_for_debugger(void) {}
>  
> +long gdbsx_domctl(struct domain *d, struct xen_domctl *domctl, bool 
> *copyback)

static inline?

Jan




 


Rackspace

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