From: Sohil Mehta <sohil.mehta@intel.com>
To: Jo Van Bulck <jo.vanbulck@cs.kuleuven.be>,
<linux-kernel@vger.kernel.org>, <dave.hansen@linux.intel.com>,
<luto@kernel.org>, <peterz@infradead.org>, <mingo@redhat.com>
Cc: <x86@kernel.org>, <bp@alien8.de>, <tglx@linutronix.de>, <hpa@zytor.com>
Subject: Re: [PATCH RESEND] x86/pti: Fix kernel warnings for pti= and nopti cmdline options.
Date: Tue, 8 Aug 2023 17:13:12 -0700 [thread overview]
Message-ID: <c0aed6a4-23e0-d947-5c17-26e580d5c40a@intel.com> (raw)
In-Reply-To: <20230808195615.9795-1-jo.vanbulck@cs.kuleuven.be>
On 8/8/2023 12:56 PM, Jo Van Bulck wrote:
> -
> - if (cmdline_find_option_bool(boot_command_line, "nopti") ||
> - cpu_mitigations_off()) {
> + if (pti_mode == PTI_FORCE_OFF || cpu_mitigations_off()) {
Can mitigations be off through some other mechanisms such as kernel config?
Maybe split the mitigations_off check into a separate if and it's own
unique print message?
The existing code might have the same issue as well.
Also, with the separated check you can avoid the unnecessary re-setting
of pti_mode when pti_mode == PTI_FORCE_OFF is true.
> pti_mode = PTI_FORCE_OFF;> pti_print_if_insecure("disabled on command line.");
> return;
> }
>
> -autosel:
> - if (!boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN))
> + if (pti_mode == PTI_AUTO && !boot_cpu_has_bug(X86_BUG_CPU_MELTDOWN))
> return;
> -enable:
> +
> + if (pti_mode == PTI_FORCE_ON)
> + pti_print_if_secure("force enabled on command line.");
> setup_force_cpu_cap(X86_FEATURE_PTI);
> }
>
> +static int __init pti_parse_cmdline(char *arg)
> +{
> + if (!strcmp(arg, "off"))
> + pti_mode = PTI_FORCE_OFF;
> + else if (!strcmp(arg, "on"))
> + pti_mode = PTI_FORCE_ON;
> + else if (!strcmp(arg, "auto"))
> + pti_mode = PTI_AUTO;
> + else
> + return -EINVAL;
> + return 0;
> +}
> +early_param("pti", pti_parse_cmdline);
> +
> +static int __init pti_parse_cmdline_nopti(char *arg)
> +{
> + pti_mode = PTI_FORCE_OFF;
> + return 0;
> +}
> +early_param("nopti", pti_parse_cmdline_nopti);
> +
In the rare case that both pti= and nopti is set the existing code seems
to ignore the nopti option. Would the new implementation do the same?
Sohil
next prev parent reply other threads:[~2023-08-09 0:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 19:56 Jo Van Bulck
2023-08-09 0:13 ` Sohil Mehta [this message]
2023-08-11 18:23 ` Jo Van Bulck
2023-08-11 19:13 ` Sohil Mehta
2023-08-11 21:20 ` Jo Van Bulck
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=c0aed6a4-23e0-d947-5c17-26e580d5c40a@intel.com \
--to=sohil.mehta@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jo.vanbulck@cs.kuleuven.be \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.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®