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

Re: [PATCH] x86/cpuid: Introduce dom0-cpuid command line option


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 15 Dec 2021 09:34:34 +0100
  • 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=EntNobZw59qZauAyRBO6b0T0b+lzqTdU7cIWKa5tkNE=; b=mFSBe7zA2B/BglHEXJjJQkZhDBropXb6HaymfbAPHuvWWbIuFzTRqtuXBR0LC+9/Uu+U0ue7xHeogOusTh0qAg/NNLpl55BbWSr57VCF7JWSFW5tVp4AHdO0rJxOqR6FYzyx+40M/p0PutThXxTgXCTCqZODBUbdTOlIZ0CST00ZajYDgzp3rczDL06ERWaG7+Q36f0DqTcxwDwlfbHt7b6x4sfa+/XPImnltTROGvf+QtMT4U07uC3yorrZWou5Pj+r22/MLQKW5kqOE1fdRJD0lyh3di+ZknIPdVA+xqYBGCd/Y+UNtRtAZjjygAhrWJM6ZSoG+dkZcOi27K2kJw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EnAZ5Gbl4+Q+1dJ06x6pxShyR5rjktq1GZXcQZfLSSJVIQAgX8XQLvXCQ8HosiwRqpvwQtS45sGTcoVaIGe5TCYpg09m5HR4i2iJ7l5r4zGaJIyFIMKmjayuJNJUQpxnc93PrlpWjzJZQQDka2HlZleWQIrhgwtYzvOddVhHsccgH+5GxtaFSPQiB4h+8NavaxCAP9PhFZ6ADHwoQDZyXWGqNzeQaoeJ77wYcj0VJMtzXAKA/bVcNXm9uVe+EKT2v/1TsrlJJ482SSeBkbJu/im5KnvXl/H5vdFTBG9B/cExeOiHsCT3NnlY9y7/+I9/BE2kd43bX6k2A3iSsLk+Cw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Daniel Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Wed, 15 Dec 2021 08:35:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 14.12.2021 22:16, Andrew Cooper wrote:
> Specifically, this lets the user opt in to non-default for dom0.
> 
> Split features[] out of parse_xen_cpuid(), giving it a lightly more
> appropraite name, so it can be shared with parse_xen_cpuid().

With the latter one I guess you mean parse_dom0_cpuid()?

> Collect all dom0 settings together in dom0_{en,dis}able_feat[], and apply it
> to dom0's policy when other tweaks are being made.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> ---
> CC: Jan Beulich <JBeulich@xxxxxxxx>
> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> CC: Wei Liu <wl@xxxxxxx>
> CC: Daniel Smith <dpsmith@xxxxxxxxxxxxxxxxxxxx>
> 
> RFC, because I think we've got a preexisting error with late hwdom here.  We
> really should not be cobbering a late hwdom's settings (which were provided in
> the usual way by the toolstack in dom0).

For ITSC I think also covering late hwdom is at least acceptable. For the
speculation controls I'm less certain (but as per the comment there they're
temporary only anyway), and I agree the command line option here should
strictly only apply to Dom0 (or else, as a minor aspect, the option also
would better be named "hwdom-cpuid=").

> Furthermore, the distinction gets more murky in a hyperlaunch future where
> multiple domains may be constructed by Xen, and there is reason to expect that
> a full toolstack-like configuration is made available for them.

Like above, anything created via the toolstack interfaces should use the
toolstack controls. If there was something dom0less-like on x86, domains
created that way (without toolstack involvement) would instead want to
have another way of controlling their CPUID settings.

> One option might be to remove the special case from init_domain_cpuid_policy()
> and instead make a call into the cpuid code from create_dom0().  It would have
> to be placed between domain_create() and alloc_dom0_vcpu0() for dynamic sizing
> of the FPU block to work.  Thoughts?

As said above, I think the ITSC special case could stay. But apart from
this I agree.

> --- a/docs/misc/xen-command-line.pandoc
> +++ b/docs/misc/xen-command-line.pandoc
> @@ -801,6 +801,22 @@ Controls for how dom0 is constructed on x86 systems.
>  
>      If using this option is necessary to fix an issue, please report a bug.
>  
> +### dom0-cpuid
> +    = List of comma separated booleans
> +
> +    Applicability: x86
> +
> +This option allows for fine tuning of the facilities dom0 will use, after
> +accounting for hardware capabilities and Xen settings as enumerated via 
> CPUID.
> +
> +Options are accepted in positive and negative form, to enable or disable
> +specific features.  All selections via this mechanism are subject to normal
> +CPU Policy safety logic.
> +
> +This option is intended for developers to opt dom0 into non-default features,
> +and is not intended for use in production circumstances.  If using this 
> option
> +is necessary to fix an issue, please report a bug.

You may want to state explicitly that disables take priority over enables,
as per the present implementation. Personally I would find it better if the
item specified last took effect. This is, as mentioned in other contexts,
so one can override earlier settings (e.g. in a xen.cfg file used with
xen.efi) by simply appending to the command line.

> @@ -97,6 +98,73 @@ static int __init parse_xen_cpuid(const char *s)
>  }
>  custom_param("cpuid", parse_xen_cpuid);
>  
> +static uint32_t __hwdom_initdata dom0_enable_feat[FSCAPINTS];
> +static uint32_t __hwdom_initdata dom0_disable_feat[FSCAPINTS];
> +
> +static int __init parse_dom0_cpuid(const char *s)
> +{
> +    const char *ss;
> +    int val, rc = 0;
> +
> +    do {
> +        const struct feature_name *lhs, *rhs, *mid = NULL /* GCC... */;
> +        const char *feat;
> +
> +        ss = strchr(s, ',');
> +        if ( !ss )
> +            ss = strchr(s, '\0');
> +
> +        /* Skip the 'no-' prefix for name comparisons. */
> +        feat = s;
> +        if ( strncmp(s, "no-", 3) == 0 )
> +            feat += 3;
> +
> +        /* (Re)initalise lhs and rhs for binary search. */
> +        lhs = feature_names;
> +        rhs = feature_names + ARRAY_SIZE(feature_names);
> +
> +        while ( lhs < rhs )
> +        {
> +            int res;
> +
> +            mid = lhs + (rhs - lhs) / 2;
> +            res = cmdline_strcmp(feat, mid->name);
> +
> +            if ( res < 0 )
> +            {
> +                rhs = mid;
> +                continue;
> +            }
> +            if ( res > 0 )
> +            {
> +                lhs = mid + 1;
> +                continue;
> +            }
> +
> +            if ( (val = parse_boolean(mid->name, s, ss)) >= 0 )
> +            {
> +                __set_bit(mid->bit,
> +                          val ? dom0_enable_feat : dom0_disable_feat);
> +                mid = NULL;
> +            }
> +
> +            break;
> +        }
> +
> +        /*
> +         * Mid being NULL means that the name and boolean were successfully
> +         * identified.  Everything else is an error.
> +         */
> +        if ( mid )
> +            rc = -EINVAL;
> +
> +        s = ss + 1;
> +    } while ( *ss );
> +
> +    return rc;
> +}
> +custom_param("dom0-cpuid", parse_dom0_cpuid);

I wonder whether it wouldn't be better (less duplication) if the bulk
of the code was also shared with parse_xen_cpuid(). In return moving
features[] wouldn't be needed then.

Jan




 


Rackspace

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