mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nikolay Borisov <nik.borisov@suse.com>
To: Xin Li <xin@zytor.com>, linux-kernel@vger.kernel.org
Cc: hpa@zytor.com, tglx@linutronix.de, mingo@redhat.com,
	bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org,
	peterz@infradead.org, andrew.cooper3@citrix.com,
	houwenlong.hwl@antgroup.com
Subject: Re: [PATCH v2 1/3] x86/fred: Parse cmdline param "fred=" in cpu_parse_early_param()
Date: Mon, 15 Jul 2024 09:44:25 +0300	[thread overview]
Message-ID: <e0de0183-00d1-46a5-ba2b-6df431b58743@suse.com> (raw)
In-Reply-To: <7fad52e6-83cf-4c17-9b3f-4dfa087f8fc4@zytor.com>



On 12.07.24 г. 20:40 ч., Xin Li wrote:
> On 7/10/2024 11:53 AM, Nikolay Borisov wrote:
>> On 9.07.24 г. 18:40 ч., Xin Li (Intel) wrote:
> 
>>> @@ -1510,6 +1510,11 @@ static void __init cpu_parse_early_param(void)
>>>       if (cmdline_find_option_bool(boot_command_line, "nousershstk"))
>>>           setup_clear_cpu_cap(X86_FEATURE_USER_SHSTK);
>>> +    /* Minimize the gap between FRED is available and available but 
>>> disabled. */
>>> +    arglen = cmdline_find_option(boot_command_line, "fred", arg, 
>>> sizeof(arg));
>>> +    if (arglen != 2 || strncmp(arg, "on", 2))
>>
>> I'm confused why you keep perverting the calling convention of 
>> cmdline_find_option. The doc clearly states:
>>
>>      * Returns the position of that @option (starts counting with 1)
>>      * or 0 on not found.  @option will only be found if it is found
>>      * as an entire word in @cmdline.  For instance, if @option="car"
>>      * then a cmdline which contains "cart" will not match.
>>
>> You should only care if arglen is non 0, which if it is you check if 
>> its value equal 'on', why bother with its starting position?
>>


Actually, I have quoted the wrong doc, the correct one is:

"
Returns the length of the argument (regardless of if it was
truncated to fit in the buffer), or -1 on not found.
"

> 
> Well, just look at how it is used in match_option() in
> arch/x86/kernel/cpu/bugs.c and arch/x86/kernel/cpu/intel.c.

Exactly, in bugs.c it's used as I've suggested:

In spectre_v2_parse_user_cmdline it checks if spectre_v2_user is present 
(if a negative value is returned) and if not it returns some default.

In spectre_v2_parse_cmdline it's used exactly the same way - return some 
default if that function returns a negative value (spectre_v2 check) or 
return some specific value if it found nospectre_v2.

And in sld_state_setup the code just checks for a non-negative value i.e 
the argument has been found.

Otoh, I see what you are trying to say if I look at the usage of this 
function in arch/x86/boot/compressed/acpi.c


Still I find this convention a bit counter-intuitive, but given it's not 
a precedent I'm fine with leaving it as is.




> 
> This is a short version and it will be expanded once we have more
> option strings well defined (match_option() should be a common lib
> function then).
> 

  reply	other threads:[~2024-07-15  6:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 15:40 [PATCH v2 0/3] Enable FRED earlier Xin Li (Intel)
2024-07-09 15:40 ` [PATCH v2 1/3] x86/fred: Parse cmdline param "fred=" in cpu_parse_early_param() Xin Li (Intel)
2024-07-10 18:53   ` Nikolay Borisov
2024-07-12 17:40     ` Xin Li
2024-07-15  6:44       ` Nikolay Borisov [this message]
2024-08-13 20:03   ` [tip: x86/fred] " tip-bot2 for Xin Li (Intel)
2024-07-09 15:40 ` [PATCH v2 2/3] x86/fred: Split FRED RSP initialization into a separate function Xin Li (Intel)
2024-08-13 20:03   ` [tip: x86/fred] x86/fred: Move " tip-bot2 for Xin Li (Intel)
2024-07-09 15:40 ` [PATCH v2 3/3] x86/fred: Enable FRED right after init_mem_mapping() Xin Li (Intel)
2024-08-13 12:45   ` Thomas Gleixner
2024-08-13 15:57     ` Xin Li
2024-08-13 20:03   ` [tip: x86/fred] " tip-bot2 for Xin Li (Intel)
2024-08-13 10:07 ` [PATCH v2 0/3] Enable FRED earlier Thomas Gleixner
2024-08-13 15:58   ` Xin Li
2024-08-13 16:03     ` Xin Li

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=e0de0183-00d1-46a5-ba2b-6df431b58743@suse.com \
    --to=nik.borisov@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=houwenlong.hwl@antgroup.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xin@zytor.com \
    /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®