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

Re: [PATCH 1/2] x86/mm: tidy XENMEM_{get,set}_pod_target handling


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 13 Sep 2021 10:56:37 +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; bh=JALDp/VUGx0Jw78BgXO6MzlUdZlfU4RREqGisKbNKd4=; b=AjqPcBsCTG0hpTIC5Nkc+Noymvh/yWJ+FE/lA+HkSMq1uMMQ5Z+gf8DMBnX78uL6R7lHq3VyvfmwI4+8ORdriO1xMG6HO/1xK5AZCAiejaiwlSNEir8b78N2/zjlhBp2y0bwBxP9xJFevbHxPmgcJkYZMtG6KsGl2xt1eZQJ8O9sSoj3UN96RMcdIOEltGEt0MDMGHgFKllz+F5h3PwcDrr/VxdzctJhRtH2pMT0toaa07KFAfOY8LwHBYsb62QVVCrDbatZaiXlccgNtg78DR7BpxRU4luMRyFUWDfX4umnKoiJOWFxhzgko4GIaXaHZlO7eNdjTLHlKZmsffLfdA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ExUOR10L7Jw54nTUh4OUr4O7H3ggtjlFpB5hJQkbStFdRoj1armjEu/yxO2UzGpM7IQvvwVdthZ73Te6j5QmeKnKLbeCVF9T1e92dHd+Ybezilczmyd83LLQjEcTgj5A2KfNgZJCIInJmrkt6GF2nCqOxlNIP/F6ZKnTBcZWQ5OFz4UQ8wlkyslS7EQxlQ0iv6t8v7qStccmfzXMZJr7zq4ifXs9EWmR76+GG7RHZQYmhJ2kRgjOacTBBHIk4eG/uQFG3DwBcxtUYLSALI5V8RZPQe/PXpxE4MIM31dctoCrLB2fhXIphtCL/njNCeHQowAc3nEYDwUQEsm8m98jnQ==
  • Authentication-results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Mon, 13 Sep 2021 08:56:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 13.09.2021 10:55, Jan Beulich wrote:
> Do away with the "pod_target_out_unlock" label. In particular by folding
> if()-s, the logic can be expressed with less code (and no goto-s) this
> way.
> 
> Limit scope of "p2m", constifying it at the same time.
> 
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

And this is of course patch 2/2. I'm sorry for the screw-up.

Jan

> --- a/xen/arch/x86/mm.c
> +++ b/xen/arch/x86/mm.c
> @@ -4777,7 +4777,6 @@ long arch_memory_op(unsigned long cmd, X
>      {
>          xen_pod_target_t target;
>          struct domain *d;
> -        struct p2m_domain *p2m;
>  
>          if ( copy_from_guest(&target, arg, 1) )
>              return -EFAULT;
> @@ -4789,23 +4788,17 @@ long arch_memory_op(unsigned long cmd, X
>          if ( !is_hvm_domain(d) )
>              rc = -EINVAL;
>          else if ( cmd == XENMEM_set_pod_target )
> -            rc = xsm_set_pod_target(XSM_PRIV, d);
> -        else
> -            rc = xsm_get_pod_target(XSM_PRIV, d);
> -
> -        if ( rc != 0 )
> -            goto pod_target_out_unlock;
> -
> -        if ( cmd == XENMEM_set_pod_target )
>          {
> -            if ( target.target_pages > d->max_pages )
> -            {
> +            rc = xsm_set_pod_target(XSM_PRIV, d);
> +            if ( rc )
> +                ASSERT(rc < 0);
> +            else if ( target.target_pages > d->max_pages )
>                  rc = -EINVAL;
> -                goto pod_target_out_unlock;
> -            }
> -
> -            rc = p2m_pod_set_mem_target(d, target.target_pages);
> +            else
> +                rc = p2m_pod_set_mem_target(d, target.target_pages);
>          }
> +        else
> +            rc = xsm_get_pod_target(XSM_PRIV, d);
>  
>          if ( rc == -ERESTART )
>          {
> @@ -4814,19 +4807,16 @@ long arch_memory_op(unsigned long cmd, X
>          }
>          else if ( rc >= 0 )
>          {
> -            p2m = p2m_get_hostp2m(d);
> +            const struct p2m_domain *p2m = p2m_get_hostp2m(d);
> +
>              target.tot_pages       = domain_tot_pages(d);
>              target.pod_cache_pages = p2m->pod.count;
>              target.pod_entries     = p2m->pod.entry_count;
>  
>              if ( __copy_to_guest(arg, &target, 1) )
> -            {
> -                rc= -EFAULT;
> -                goto pod_target_out_unlock;
> -            }
> +                rc = -EFAULT;
>          }
>  
> -    pod_target_out_unlock:
>          rcu_unlock_domain(d);
>          return rc;
>      }
> 
> 




 


Rackspace

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