diff mbox series

[v2,3/3] x86/spec: fix INDIRECT_THUNK option to only be set when build-enabled

Message ID 20240223120616.73503-4-roger.pau@citrix.com (mailing list archive)
State Superseded
Headers show
Series x86/spec: improve command line parsing | expand

Commit Message

Roger Pau Monne Feb. 23, 2024, 12:06 p.m. UTC
Attempt to provide a more helpful error message when the user attempts to set
spec-ctrl=bti-thunk option but the support is build-time disabled.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v1:
 - New in this version.
---
 xen/arch/x86/spec_ctrl.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jan Beulich Feb. 26, 2024, 8:40 a.m. UTC | #1
On 23.02.2024 13:06, Roger Pau Monne wrote:
> --- a/xen/arch/x86/spec_ctrl.c
> +++ b/xen/arch/x86/spec_ctrl.c
> @@ -239,6 +239,7 @@ static int __init cf_check parse_spec_ctrl(const char *s)
>          /* Xen's speculative sidechannel mitigation settings. */
>          else if ( !strncmp(s, "bti-thunk=", 10) )
>          {
> +#ifdef CONFIG_INDIRECT_THUNK
>              s += 10;
>  
>              if ( !cmdline_strcmp(s, "retpoline") )

              if ( !IS_ENABLED(CONFIG_INDIRECT_THUNK) )
              {
                  no_config_param("INDIRECT_THUNK", "spec-ctrl", s, ss);
                  rc = -EINVAL;
              }
              else if ( !cmdline_strcmp(s, "retpoline") )

?

Also, while touching INDIRECT_THUNK, could I talk you into also adjusting
documentation accordingly? It presently mentions INDIRECT_THUNK, when
really it means CONFIG_INDIRECT_THUNK.

Jan

> @@ -249,6 +250,10 @@ static int __init cf_check parse_spec_ctrl(const char *s)
>                  opt_thunk = THUNK_JMP;
>              else
>                  rc = -EINVAL;
> +#else
> +            no_config_param("INDIRECT_THUNK", "spec-ctrl", s, ss);
> +            rc = -EINVAL;
> +#endif
>          }
>  
>          /* Bits in MSR_SPEC_CTRL. */
diff mbox series

Patch

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 4ce8a7a0b8ef..f3432f1a6c80 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -239,6 +239,7 @@  static int __init cf_check parse_spec_ctrl(const char *s)
         /* Xen's speculative sidechannel mitigation settings. */
         else if ( !strncmp(s, "bti-thunk=", 10) )
         {
+#ifdef CONFIG_INDIRECT_THUNK
             s += 10;
 
             if ( !cmdline_strcmp(s, "retpoline") )
@@ -249,6 +250,10 @@  static int __init cf_check parse_spec_ctrl(const char *s)
                 opt_thunk = THUNK_JMP;
             else
                 rc = -EINVAL;
+#else
+            no_config_param("INDIRECT_THUNK", "spec-ctrl", s, ss);
+            rc = -EINVAL;
+#endif
         }
 
         /* Bits in MSR_SPEC_CTRL. */