From: John Haxby <john.haxby@oracle.com>
To: Andi Kleen <ak@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Jonathan Corbet <corbet@lwn.net>,
x86@kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 1/1] x86/fpu: Allow clearcpuid= to clear several bits
Date: Wed, 22 Apr 2020 16:21:51 +0100 [thread overview]
Message-ID: <96EA2DF4-7490-4FF0-BB3E-EC9157517918@oracle.com> (raw)
In-Reply-To: <20200422143554.GI608746@tassilo.jf.intel.com>
> On 22 Apr 2020, at 15:35, Andi Kleen <ak@linux.intel.com> wrote:
>
>
> Thanks good catch.
>
>> if (cmdline_find_option(boot_command_line, "clearcpuid", arg,
>> - sizeof(arg)) &&
>> - get_option(&argptr, &bit) &&
>> - bit >= 0 &&
>> - bit < NCAPINTS * 32)
>> - setup_clear_cpu_cap(bit);
>> + sizeof(arg))) {
>> + /* cpuid bit numbers are mostly three digits */
>> + enum { nints = sizeof(arg)/(3+1) + 1 };
>
> Not sure what the digits have to do with the stack space of an int array.
>
> We should have enough stack to afford some more than 8.
sizeof(arg) == 32; room enough for eight three-digit with their trailing commas. If sizeof(arg) == 1024 instead then there'd be more than enough room to remove every single feature. TBH, 512 is more than enough for the 89 flags I have listed on this machine I'm looking at here. I'll grow sizeof(arg) and nints accordingly.
>
> Would be good to have a warning if the arguments are longer.
>
Yes, I should definitely do that -- coming to a V2 soon.
> Maybe it would be simpler to fix the early arg parser
> to allow multiple instances again? That would also avoid the limit,
> and keep everything compatible.
>
I did wonder about that. However, cmdline_find_option() is specifically documented as
* Find a non-boolean option (i.e. option=argument). In accordance with
* standard Linux practice, if this option is repeated, this returns the
* last instance on the command line.
And since that appeared in 2017 I decided to stick with the new-fangled interface :) This is a little-used feature; I'm not sure it's worth the effort of parsing the command line for the old style. What do you think?
jch
> -Andi
>
>
>> + int i, bits[nints];
>> +
>> + get_options(arg, nints, bits);
>> + for (i = 1; i <= bits[0]; i++) {
>> + if (bits[i] >= 0 && bits[i] < NCAPINTS * 32)
>> + setup_clear_cpu_cap(bits[i]);
>> + }
>> + }
>> }
>>
>> /*
>> --
>> 2.25.3
>>
next prev parent reply other threads:[~2020-04-22 15:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-22 12:03 [PATCH 0/1] " John Haxby
2020-04-22 12:03 ` [PATCH 1/1] " John Haxby
2020-04-22 14:35 ` Andi Kleen
2020-04-22 15:21 ` John Haxby [this message]
2020-04-23 1:41 ` Andi Kleen
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=96EA2DF4-7490-4FF0-BB3E-EC9157517918@oracle.com \
--to=john.haxby@oracle.com \
--cc=ak@linux.intel.com \
--cc=bp@alien8.de \
--cc=corbet@lwn.net \
--cc=hpa@zytor.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®