Re: [PATCH v2 1/3] x86/fred: Parse cmdline param "fred=" in cpu_parse_early_param()

From: Xin Li
Date: Fri Jul 12 2024 - 13:41:52 EST


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?


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.

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).