All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>,
	Xen-devel <xen-devel@lists.xen.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH 3/5] xen/domain: Audit config->max_vcpus during {, arch_}check_domain_config()
Date: Tue, 9 Oct 2018 12:23:28 +0100	[thread overview]
Message-ID: <b2a7e43d-c106-838a-625f-74786bbe814b@arm.com> (raw)
In-Reply-To: <1538751289-1109-4-git-send-email-andrew.cooper3@citrix.com>

Hi Andrew,

On 05/10/2018 15:54, Andrew Cooper wrote:
> The purpose of this is to move the auduting to be earlier than
> arch_domain_create().
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> ---
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>
> 
> The max_vcpus setting for GIC_V3 is somewhat confusing.  The current GIC_V3
> driver claims to support 4096 cpus, while the newer GIC_V3 driver uses 255.

The maximum number of vCPUs supported for GICv3 depends on the number of 
affinity levels supported by the vGIC emulation.

> ---
>   xen/arch/arm/domain.c | 18 ++++++++++++++++++
>   xen/arch/x86/domain.c |  6 ++++++
>   xen/common/domain.c   |  3 +++
>   3 files changed, 27 insertions(+)
> 
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 43593a4..9676893 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -601,6 +601,8 @@ void vcpu_switch_to_aarch64_mode(struct vcpu *v)
>   
>   int arch_check_domain_config(struct xen_domctl_createdomain *config)
>   {
> +    unsigned int max_vcpus = 0;
> +
>       /* Fill in the native GIC version, passed back to the toolstack. */
>       if ( config->arch.gic_version == XEN_DOMCTL_CONFIG_GIC_NATIVE )
>       {
> @@ -619,6 +621,22 @@ int arch_check_domain_config(struct xen_domctl_createdomain *config)
>           }
>       }
>   
> +    /* Calculate the maximum number of vcpus from the selected GIC version... */
> +    switch ( config->arch.gic_version )
> +    {
> +    case GIC_V2: max_vcpus = 8;   break;
> +    case GIC_V3: max_vcpus = 255; break;
> +
> +    default:
> +        return -EOPNOTSUPP;
> +    }

I would prefer to keep those values in a separate helper implemented by 
each vGIC.

> +
> +    /* ... clipped at the maximum value Xen has been configured for. */
> +    max_vcpus = min(max_vcpus, MAX_VIRT_CPUS + 0u);

+ 0U feels a bit odd to read. It would be better to append u in 
MAX_VIRT_CPUS.

> +
> +    if ( config->max_vcpus > max_vcpus )
> +        return -EINVAL;
> +
>       return 0;
>   }
>   
> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
> index 26cab7c..19023d4 100644
> --- a/xen/arch/x86/domain.c
> +++ b/xen/arch/x86/domain.c
> @@ -403,6 +403,12 @@ void arch_vcpu_destroy(struct vcpu *v)
>   
>   int arch_check_domain_config(struct xen_domctl_createdomain *config)
>   {
> +    unsigned int max_vcpus = ((config->flags & XEN_DOMCTL_CDF_hvm_guest)
> +                              ? HVM_MAX_VCPUS : MAX_VIRT_CPUS);
> +
> +    if ( config->max_vcpus > max_vcpus )
> +        return -EINVAL;
> +
>       return 0;
>   }
>   
> diff --git a/xen/common/domain.c b/xen/common/domain.c
> index 236c2ad..9882550 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -297,6 +297,9 @@ static int check_domain_config(struct xen_domctl_createdomain *config)
>                              XEN_DOMCTL_CDF_xs_domain) )
>           return -EINVAL;
>   
> +    if ( config->max_vcpus < 1 )
> +        return -EINVAL;
> +
>       return arch_check_domain_config(config);
>   }
>   
> 

Cheers,

-- 
Julien Grall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-10-09 11:23 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05 14:54 [PATCH RFC 0/5] xen/domain: Allocate d->vcpu[] earlier during domain construction Andrew Cooper
2018-10-05 14:54 ` [PATCH 1/5] xen/domain: Introduce a new check_domain_config() helper Andrew Cooper
2018-10-08 13:37   ` Jan Beulich
2018-10-05 14:54 ` [PATCH 2/5] xen/domain: Introduce a new arch_check_domain_config() helper Andrew Cooper
2018-10-08 13:39   ` Jan Beulich
2018-10-09 10:57   ` Julien Grall
2018-10-05 14:54 ` [PATCH 3/5] xen/domain: Audit config->max_vcpus during {, arch_}check_domain_config() Andrew Cooper
2018-10-08  6:44   ` Alan Robinson
2018-10-08 13:45   ` Jan Beulich
2018-11-09 18:44     ` Andrew Cooper
2018-11-12  8:21       ` Jan Beulich
2018-10-09 11:23   ` Julien Grall [this message]
2018-11-09 18:43     ` Andrew Cooper
2018-11-12 11:43       ` Julien Grall
2018-11-12 11:45         ` Andrew Cooper
2018-10-05 14:54 ` [PATCH 4/5] xen/domain: Allocate d->vcpu[] earlier during domain_create() Andrew Cooper
2018-10-08 13:51   ` Jan Beulich
2018-10-08 17:39     ` Andrew Cooper
2018-10-09  6:06       ` Jan Beulich
2018-10-05 14:54 ` [PATCH 5/5] Revert "xen/arm: vgic-v3: Delay the initialization of the domain information" Andrew Cooper
2018-10-09 11:25   ` Julien Grall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2a7e43d-c106-838a-625f-74786bbe814b@arm.com \
    --to=julien.grall@arm.com \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.