All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [Xen-devel] [PATCH v2] x86/cpuid: Extend the cpuid= option to support all named features
Date: Fri, 6 Sep 2019 16:27:34 +0100	[thread overview]
Message-ID: <7a0a832d-e7a6-7f2f-66be-7d0af44aa3ff@citrix.com> (raw)
In-Reply-To: <a7787fb5-02ea-61a0-b503-21b21c2961aa@suse.com>

On 06/09/2019 16:18, Jan Beulich wrote:
> On 05.09.2019 21:49, Andrew Cooper wrote:
>> --- a/xen/arch/x86/cpuid.c
>> +++ b/xen/arch/x86/cpuid.c
>> @@ -21,45 +21,62 @@ static const uint32_t deep_features[] = INIT_DEEP_FEATURES;
>>  
>>  static int __init parse_xen_cpuid(const char *s)
>>  {
>> +    static const struct feature {
>> +        const char *name;
>> +        unsigned int bit;
>> +    } features[] __initconst = INIT_FEATURE_NAMES, *lhs, *mid, *rhs;
> The pointer field want this to use __initconstrel.

Ok.

> And I don't think you mean lhs, mid, and rhs to also be static?

No - not intentional.

>  Albeit ...
>
>>      const char *ss;
>>      int val, rc = 0;
>>  
>>      do {
>> +        const char *feat;
>> +
>>          ss = strchr(s, ',');
>>          if ( !ss )
>>              ss = strchr(s, '\0');
>>  
>> -        if ( (val = parse_boolean("md-clear", s, ss)) >= 0 )
>> -        {
>> -            if ( !val )
>> -                setup_clear_cpu_cap(X86_FEATURE_MD_CLEAR);
>> -        }
>> -        else if ( (val = parse_boolean("ibpb", s, ss)) >= 0 )
>> -        {
>> -            if ( !val )
>> -                setup_clear_cpu_cap(X86_FEATURE_IBPB);
>> -        }
>> -        else if ( (val = parse_boolean("ibrsb", s, ss)) >= 0 )
>> -        {
>> -            if ( !val )
>> -                setup_clear_cpu_cap(X86_FEATURE_IBRSB);
>> -        }
>> -        else if ( (val = parse_boolean("stibp", s, ss)) >= 0 )
>> -        {
>> -            if ( !val )
>> -                setup_clear_cpu_cap(X86_FEATURE_STIBP);
>> -        }
>> -        else if ( (val = parse_boolean("l1d-flush", s, ss)) >= 0 )
>> -        {
>> -            if ( !val )
>> -                setup_clear_cpu_cap(X86_FEATURE_L1D_FLUSH);
>> -        }
>> -        else if ( (val = parse_boolean("ssbd", s, ss)) >= 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 = features;
>> +        rhs = features + ARRAY_SIZE(features);
> ... the comment here suggests you do, but I don't currently see why.

We are inside a do { } () while loop, parsing something such as
cpuid=avx512,ss,smx

The binary search over the feature names needs to start again from
scratch for each new cpuid= list item.

Otherwise, the while ( lhs < rhs ) binary search will never be entered
for the second cpuid= item.

~Andrew

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

  reply	other threads:[~2019-09-06 15:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-05 19:49 [Xen-devel] [PATCH v2] x86/cpuid: Extend the cpuid= option to support all named features Andrew Cooper
2019-09-06 15:18 ` Jan Beulich
2019-09-06 15:27   ` Andrew Cooper [this message]
2019-09-06 15:54     ` Jan Beulich
2019-09-25 12:30 ` Jan Beulich
2019-09-25 12:32   ` Andrew Cooper
2019-09-25 12:39     ` Jan Beulich

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=7a0a832d-e7a6-7f2f-66be-7d0af44aa3ff@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.