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: Ian Jackson <Ian.Jackson@citrix.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>, Jan Beulich <JBeulich@suse.com>
Subject: Re: [PATCH v2 3/5] xen/domain: Stricter configuration checking
Date: Wed, 14 Nov 2018 18:51:06 +0000	[thread overview]
Message-ID: <1f29d294-a9a4-8327-1093-d8abf863092a@arm.com> (raw)
In-Reply-To: <1542039391-32406-4-git-send-email-andrew.cooper3@citrix.com>

Hi Andrew,

On 12/11/2018 16:16, Andrew Cooper wrote:
> Currently, a number of options passed for domain creation are ignored, or have
> implicit fallback behaviour.  This is bad for forwards compatibility, and for
> end users to be certain that they got the configuration they asked for.
> 
> With this change:
>   * ARM now strictly requires that XEN_DOMCTL_CDF_hap is passed.  Previously,
>     only XEN_DOMCTL_CDF_hvm_guest was checked.
>   * For x86, requesting HAP without HVM is now prohibited, as the combination
>     makes no sense.
>   * For x86, requesting HAP on a non-HAP capable system will fail, rather than
>     silently fall back to Shadow.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

For the Arm bits:

Acked-by: Julien Grall <julien.grall@arm.com>

Cheers,

> ---
> 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>
> CC: Ian Jackson <Ian.Jackson@citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> 
> Semi RFC because this may cause a user-visible change in behaviour.  However,
> if the user has gone to the effort of specifying hap=1, silently falling back
> to shadow is unexpected, and IMO, a bug.
> 
> Alternatively, if this proves to be controversial, it can be dropped from the
> series to avoid blocking the main bugfix.
> 
> v2:
>   * New
> ---
>   xen/arch/arm/domain.c |  7 +++++++
>   xen/arch/x86/domain.c | 40 ++++++++++++++++++++++++++++++++++++++++
>   xen/common/domain.c   | 34 +++-------------------------------
>   3 files changed, 50 insertions(+), 31 deletions(-)
> 
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index c24ace6..08ba412 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -601,6 +601,13 @@ void vcpu_switch_to_aarch64_mode(struct vcpu *v)
>   
>   int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
>   {
> +    if ( !(config->flags & XEN_DOMCTL_CDF_hvm_guest) ||
> +         !(config->flags & XEN_DOMCTL_CDF_hap) )
> +    {
> +        dprintk(XENLOG_INFO, "Unsupported configuration %#x\n", config->flags);
> +        return -EINVAL;
> +    }
> +
>       /* Fill in the native GIC version, passed back to the toolstack. */
>       if ( config->arch.gic_version == XEN_DOMCTL_CONFIG_GIC_NATIVE )
>       {
> diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
> index 28a145a..f47ad04 100644
> --- a/xen/arch/x86/domain.c
> +++ b/xen/arch/x86/domain.c
> @@ -420,6 +420,46 @@ void arch_vcpu_destroy(struct vcpu *v)
>   
>   int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
>   {
> +    bool hvm;
> +
> +    if ( !IS_ENABLED(CONFIG_PV) && !(config->flags & XEN_DOMCTL_CDF_hvm_guest) )
> +    {
> +        dprintk(XENLOG_INFO, "PV support not available\n");
> +        return -EINVAL;
> +    }
> +
> +    if ( !hvm_enabled && (config->flags & XEN_DOMCTL_CDF_hvm_guest) )
> +    {
> +        dprintk(XENLOG_INFO, "HVM support not available\n");
> +        return -EINVAL;
> +    }
> +
> +    hvm = config->flags & XEN_DOMCTL_CDF_hvm_guest;
> +
> +    if ( !hvm )
> +    {
> +        if ( config->flags & XEN_DOMCTL_CDF_hap )
> +        {
> +            dprintk(XENLOG_INFO, "HAP inapplicable for PV guests\n");
> +            return -EINVAL;
> +        }
> +    }
> +    else
> +    {
> +        if ( !IS_ENABLED(CONFIG_SHADOW_PAGING) &&
> +             !(config->flags & XEN_DOMCTL_CDF_hap) )
> +        {
> +            dprintk(XENLOG_INFO, "SHADOW support not available\n");
> +            return -EINVAL;
> +        }
> +
> +        if ( !hvm_hap_supported() && (config->flags & XEN_DOMCTL_CDF_hap) )
> +        {
> +            dprintk(XENLOG_INFO, "HAP support not available\n");
> +            return -EINVAL;
> +        }
> +    }
> +
>       return 0;
>   }
>   
> diff --git a/xen/common/domain.c b/xen/common/domain.c
> index ddaf74a..f69f405 100644
> --- a/xen/common/domain.c
> +++ b/xen/common/domain.c
> @@ -339,37 +339,9 @@ struct domain *domain_create(domid_t domid,
>           hardware_domain = d;
>       }
>   
> -    /* Sort out our idea of is_{pv,hvm}_domain(). */
> -    if ( config )
> -    {
> -        if ( config->flags & XEN_DOMCTL_CDF_hvm_guest )
> -        {
> -#ifdef CONFIG_HVM
> -            d->guest_type = guest_type_hvm;
> -#else
> -            err = -EINVAL;
> -            goto fail;
> -#endif
> -        }
> -        else
> -        {
> -#ifdef CONFIG_PV
> -            d->guest_type = guest_type_pv;
> -#else
> -            err = -EINVAL;
> -            goto fail;
> -#endif
> -        }
> -    }
> -    else
> -    {
> -        /*
> -         * At least the idle domain should be treated as PV domain
> -         * because it uses PV context switch functions. To err on the
> -         * safe side, leave all system domains to be guest_type_pv.
> -         */
> -        d->guest_type = guest_type_pv;
> -    }
> +    /* Sort out our idea of is_{pv,hvm}_domain().  All system domains are PV. */
> +    d->guest_type = ((config && (config->flags & XEN_DOMCTL_CDF_hvm_guest))
> +                     ? guest_type_hvm : guest_type_pv);
>   
>       TRACE_1D(TRC_DOM0_DOM_ADD, d->domain_id);
>   
> 

-- 
Julien Grall

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

  parent reply	other threads:[~2018-11-14 18:51 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-12 16:16 [PATCH v2 0/5] xen/domain: Allocate d->vcpu[] earlier during domain construction Andrew Cooper
2018-11-12 16:16 ` [PATCH v2 1/5] xen/domain: Introduce a new sanitise_domain_config() helper Andrew Cooper
2018-11-13 14:03   ` Jan Beulich
2018-11-14 18:49   ` Julien Grall
2018-11-12 16:16 ` [PATCH v2 2/5] xen/domain: Introduce a new arch_sanitise_domain_config() helper Andrew Cooper
2018-11-12 16:16 ` [PATCH v2 3/5] xen/domain: Stricter configuration checking Andrew Cooper
2018-11-13 14:14   ` Jan Beulich
2018-11-13 14:36     ` Wei Liu
2018-11-13 14:39       ` Andrew Cooper
2018-11-13 14:49         ` Wei Liu
2018-11-13 16:56         ` Jan Beulich
2018-11-13 15:07     ` Andrew Cooper
2018-11-13 16:54       ` Jan Beulich
2018-11-14 17:44   ` [PATCH v3 3/5] xen/domain: Move guest type checks into the arch_sanitise_domain_config() path Andrew Cooper
2018-11-14 18:52     ` Julien Grall
     [not found]     ` <013C0C6C020000F58E2C01CD@prv1-mh.provo.novell.com>
2018-11-15 10:51       ` Jan Beulich
2018-11-14 18:51   ` Julien Grall [this message]
2018-11-12 16:16 ` [PATCH v2 4/5] xen/domain: Allocate d->vcpu[] earlier during domain_create() Andrew Cooper
2018-11-13 14:17   ` Jan Beulich
2018-11-14 18:20   ` [PATCH v3 " Andrew Cooper
2018-11-14 18:59   ` [PATCH v2 " Julien Grall
2018-11-14 19:04     ` Andrew Cooper
2018-11-14 19:36       ` [PATCH v4 " Andrew Cooper
2018-11-14 19:37         ` Julien Grall
2018-11-14 19:38           ` Andrew Cooper
2018-11-14 19:48             ` [PATCH v5 " Andrew Cooper
2018-11-14 19:50               ` Julien Grall
2018-11-12 16:16 ` [PATCH v2 5/5] Revert "xen/arm: vgic-v3: Delay the initialization of the domain information" Andrew Cooper

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=1f29d294-a9a4-8327-1093-d8abf863092a@arm.com \
    --to=julien.grall@arm.com \
    --cc=Ian.Jackson@citrix.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.