On Fri, 16 Jan 2015, Andrew Cooper wrote:
> This has no guest-visible change, but makes the Hypervisor side bounds
> checking more simple.
> 
> Signed-off-by: Andrew Cooper <andrew.coop...@citrix.com>
> CC: Keir Fraser <k...@xen.org>
> CC: Jan Beulich <jbeul...@suse.com>
> CC: Ian Campbell <ian.campb...@citrix.com>
> CC: Stefano Stabellini <stefano.stabell...@citrix.com>
> CC: Tim Deegan <t...@xen.org>
> 

For the tiny arm part:

Acked-by: Stefano Stabellini <stefano.stabell...@eu.citrix.com>

> 
> There are no functional changes as a result of this patch, but I have an RFC
> improvement to suggest.
> 
> The bounds check against MAX_VIRT_CPUS is spurious now that PVH domains can
> use vcpu_op hypercalls.  It is fine as MAX_VIRT_CPUS (8K) is far higher than
> current 128 limit for HVM guests, but there is nothing conceptually preventing
> an HVM domain from having more than 8k CPUs (x2apic allows for 2^32 unique 
> ids).
> 
> I propose dropping the MAX_VIRT_CPU bounds check completely, and relying on
> d->max_vcpus to be within the approprate bounds.  This will result in a guest
> visible change insofar that some of their -EINVAL errors will turn into
> -ENOENT, which is why this is suggestion is RFC.
> ---
>  xen/arch/arm/domain.c           |    2 +-
>  xen/arch/x86/hvm/hvm.c          |    4 ++--
>  xen/common/compat/domain.c      |    6 +++---
>  xen/common/domain.c             |    6 +++---
>  xen/include/asm-arm/hypercall.h |    2 +-
>  xen/include/public/vcpu.h       |    2 +-
>  xen/include/xen/hypercall.h     |    4 ++--
>  7 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 7221bc8..cfc7ab4 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -777,7 +777,7 @@ void arch_dump_domain_info(struct domain *d)
>  }
>  
>  
> -long do_arm_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
> +long do_arm_vcpu_op(int cmd, unsigned int vcpuid, 
> XEN_GUEST_HANDLE_PARAM(void) arg)
>  {
>      switch ( cmd )
>      {
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 8b06bfd..e096094 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -4659,7 +4659,7 @@ static long hvm_physdev_op(int cmd, 
> XEN_GUEST_HANDLE_PARAM(void) arg)
>  }
>  
>  static long hvm_vcpu_op(
> -    int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
> +    int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
>  {
>      long rc;
>  
> @@ -4718,7 +4718,7 @@ static long hvm_memory_op_compat32(int cmd, 
> XEN_GUEST_HANDLE_PARAM(void) arg)
>  }
>  
>  static long hvm_vcpu_op_compat32(
> -    int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
> +    int cmd, unsigned vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
>  {
>      long rc;
>  
> diff --git a/xen/common/compat/domain.c b/xen/common/compat/domain.c
> index b4be3b3..510843d 100644
> --- a/xen/common/compat/domain.c
> +++ b/xen/common/compat/domain.c
> @@ -23,13 +23,13 @@ CHECK_SIZE_(struct, vcpu_info);
>  CHECK_vcpu_register_vcpu_info;
>  #undef xen_vcpu_register_vcpu_info
>  
> -int compat_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
> +int compat_vcpu_op(int cmd, unsigned int vcpuid, 
> XEN_GUEST_HANDLE_PARAM(void) arg)
>  {
>      struct domain *d = current->domain;
>      struct vcpu *v;
>      int rc = 0;
>  
> -    if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) )
> +    if ( vcpuid >= MAX_VIRT_CPUS )
>          return -EINVAL;
>  
>      if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
> @@ -59,7 +59,7 @@ int compat_vcpu_op(int cmd, int vcpuid, 
> XEN_GUEST_HANDLE_PARAM(void) arg)
>          domain_unlock(d);
>  
>          if ( rc == -ERESTART )
> -            rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iih",
> +            rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iuh",
>                                                 cmd, vcpuid, arg);
>  
>          xfree(cmp_ctxt);
> diff --git a/xen/common/domain.c b/xen/common/domain.c
> index 336e9ea..e02823e 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -1139,14 +1139,14 @@ void unmap_vcpu_info(struct vcpu *v)
>      put_page_and_type(mfn_to_page(mfn));
>  }
>  
> -long do_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg)
> +long do_vcpu_op(int cmd, unsigned int vcpuid, XEN_GUEST_HANDLE_PARAM(void) 
> arg)
>  {
>      struct domain *d = current->domain;
>      struct vcpu *v;
>      struct vcpu_guest_context *ctxt;
>      long rc = 0;
>  
> -    if ( (vcpuid < 0) || (vcpuid >= MAX_VIRT_CPUS) )
> +    if ( vcpuid >= MAX_VIRT_CPUS )
>          return -EINVAL;
>  
>      if ( vcpuid >= d->max_vcpus || (v = d->vcpu[vcpuid]) == NULL )
> @@ -1174,7 +1174,7 @@ long do_vcpu_op(int cmd, int vcpuid, 
> XEN_GUEST_HANDLE_PARAM(void) arg)
>          free_vcpu_guest_context(ctxt);
>  
>          if ( rc == -ERESTART )
> -            rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iih",
> +            rc = hypercall_create_continuation(__HYPERVISOR_vcpu_op, "iuh",
>                                                 cmd, vcpuid, arg);
>  
>          break;
> diff --git a/xen/include/asm-arm/hypercall.h b/xen/include/asm-arm/hypercall.h
> index 94a92d4..a0c5a31 100644
> --- a/xen/include/asm-arm/hypercall.h
> +++ b/xen/include/asm-arm/hypercall.h
> @@ -4,7 +4,7 @@
>  #include <public/domctl.h> /* for arch_do_domctl */
>  int do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg);
>  
> -long do_arm_vcpu_op(int cmd, int vcpuid, XEN_GUEST_HANDLE_PARAM(void) arg);
> +long do_arm_vcpu_op(int cmd, unsigned int vcpuid, 
> XEN_GUEST_HANDLE_PARAM(void) arg);
>  
>  long subarch_do_domctl(struct xen_domctl *domctl, struct domain *d,
>                         XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl);
> diff --git a/xen/include/public/vcpu.h b/xen/include/public/vcpu.h
> index e888daf..898b89f 100644
> --- a/xen/include/public/vcpu.h
> +++ b/xen/include/public/vcpu.h
> @@ -31,7 +31,7 @@
>  
>  /*
>   * Prototype for this hypercall is:
> - *  int vcpu_op(int cmd, int vcpuid, void *extra_args)
> + *  long vcpu_op(int cmd, unsigned int vcpuid, void *extra_args)
>   * @cmd        == VCPUOP_??? (VCPU operation).
>   * @vcpuid     == VCPU to operate on.
>   * @extra_args == Operation-specific extra arguments (NULL if none).
> diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h
> index 8c55779..eda8a36 100644
> --- a/xen/include/xen/hypercall.h
> +++ b/xen/include/xen/hypercall.h
> @@ -109,7 +109,7 @@ do_vm_assist(
>  extern long
>  do_vcpu_op(
>      int cmd,
> -    int vcpuid,
> +    unsigned int vcpuid,
>      XEN_GUEST_HANDLE_PARAM(void) arg);
>  
>  struct vcpu;
> @@ -160,7 +160,7 @@ compat_grant_table_op(
>  extern int
>  compat_vcpu_op(
>      int cmd,
> -    int vcpuid,
> +    unsigned int vcpuid,
>      XEN_GUEST_HANDLE_PARAM(void) arg);
>  
>  extern int
> -- 
> 1.7.10.4
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to