* [PATCH] x86/spec-ctrl: Fix the parsing of xpti= on fixed Intel hardware
@ 2018-07-23 13:48 Andrew Cooper
2018-07-23 14:22 ` Juergen Gross
2018-07-23 14:33 ` Wei Liu
0 siblings, 2 replies; 4+ messages in thread
From: Andrew Cooper @ 2018-07-23 13:48 UTC (permalink / raw)
To: Xen-devel
Cc: Juergen Gross, Sergey Dyasli, Wei Liu, Andrew Cooper, Jan Beulich,
Roger Pau Monné
The calls to xpti_init_default() in parse_xpti() are buggy. The CPUID data
hasn't been fetched that early, and boot_cpu_has(X86_FEATURE_ARCH_CAPS) will
always evaluate false.
As a result, the default case won't disable XPTI on Intel hardware which
advertises ARCH_CAPABILITIES_RDCL_NO.
Simplify parse_xpti() to solely the setting of opt_xpti according to the
passed string, and have init_speculation_mitigations() call
xpti_init_default() if appropiate. Drop the force parameter, and pass caps
instead, to avoid redundant re-reading of MSR_ARCH_CAPS.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Juergen Gross <jgross@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Sergey Dyasli <sergey.dyasli@citrix.com>
---
xen/arch/x86/spec_ctrl.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 73dc717..32a4ea6 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -423,17 +423,10 @@ static bool __init should_use_eager_fpu(void)
#define OPT_XPTI_DEFAULT 0xff
uint8_t __read_mostly opt_xpti = OPT_XPTI_DEFAULT;
-static __init void xpti_init_default(bool force)
+static __init void xpti_init_default(uint64_t caps)
{
- uint64_t caps = 0;
-
- if ( !force && (opt_xpti != OPT_XPTI_DEFAULT) )
- return;
-
if ( boot_cpu_data.x86_vendor == X86_VENDOR_AMD )
caps = ARCH_CAPABILITIES_RDCL_NO;
- else if ( boot_cpu_has(X86_FEATURE_ARCH_CAPS) )
- rdmsrl(MSR_ARCH_CAPABILITIES, caps);
if ( caps & ARCH_CAPABILITIES_RDCL_NO )
opt_xpti = 0;
@@ -446,8 +439,6 @@ static __init int parse_xpti(const char *s)
const char *ss;
int val, rc = 0;
- xpti_init_default(false);
-
do {
ss = strchr(s, ',');
if ( !ss )
@@ -465,7 +456,7 @@ static __init int parse_xpti(const char *s)
default:
if ( !strcmp(s, "default") )
- xpti_init_default(true);
+ opt_xpti = OPT_XPTI_DEFAULT;
else if ( (val = parse_boolean("dom0", s, ss)) >= 0 )
opt_xpti = (opt_xpti & ~OPT_XPTI_DOM0) |
(val ? OPT_XPTI_DOM0 : 0);
@@ -627,7 +618,9 @@ void __init init_speculation_mitigations(void)
if ( default_xen_spec_ctrl )
setup_force_cpu_cap(X86_FEATURE_SC_MSR_IDLE);
- xpti_init_default(false);
+ if ( opt_xpti == OPT_XPTI_DEFAULT )
+ xpti_init_default(caps);
+
if ( opt_xpti == 0 )
setup_force_cpu_cap(X86_FEATURE_NO_XPTI);
else
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] x86/spec-ctrl: Fix the parsing of xpti= on fixed Intel hardware
2018-07-23 13:48 [PATCH] x86/spec-ctrl: Fix the parsing of xpti= on fixed Intel hardware Andrew Cooper
@ 2018-07-23 14:22 ` Juergen Gross
2018-07-24 10:12 ` Jan Beulich
2018-07-23 14:33 ` Wei Liu
1 sibling, 1 reply; 4+ messages in thread
From: Juergen Gross @ 2018-07-23 14:22 UTC (permalink / raw)
To: Andrew Cooper, Xen-devel
Cc: Sergey Dyasli, Wei Liu, Jan Beulich, Roger Pau Monné
On 23/07/18 15:48, Andrew Cooper wrote:
> The calls to xpti_init_default() in parse_xpti() are buggy. The CPUID data
> hasn't been fetched that early, and boot_cpu_has(X86_FEATURE_ARCH_CAPS) will
> always evaluate false.
>
> As a result, the default case won't disable XPTI on Intel hardware which
> advertises ARCH_CAPABILITIES_RDCL_NO.
>
> Simplify parse_xpti() to solely the setting of opt_xpti according to the
> passed string, and have init_speculation_mitigations() call
> xpti_init_default() if appropiate. Drop the force parameter, and pass caps
> instead, to avoid redundant re-reading of MSR_ARCH_CAPS.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/spec-ctrl: Fix the parsing of xpti= on fixed Intel hardware
2018-07-23 14:22 ` Juergen Gross
@ 2018-07-24 10:12 ` Jan Beulich
0 siblings, 0 replies; 4+ messages in thread
From: Jan Beulich @ 2018-07-24 10:12 UTC (permalink / raw)
To: Andrew Cooper
Cc: Juergen Gross, Sergey Dyasli, Xen-devel, Wei Liu, Roger Pau Monne
>>> On 23.07.18 at 16:22, <jgross@suse.com> wrote:
> On 23/07/18 15:48, Andrew Cooper wrote:
>> The calls to xpti_init_default() in parse_xpti() are buggy. The CPUID data
>> hasn't been fetched that early, and boot_cpu_has(X86_FEATURE_ARCH_CAPS) will
>> always evaluate false.
>>
>> As a result, the default case won't disable XPTI on Intel hardware which
>> advertises ARCH_CAPABILITIES_RDCL_NO.
>>
>> Simplify parse_xpti() to solely the setting of opt_xpti according to the
>> passed string, and have init_speculation_mitigations() call
>> xpti_init_default() if appropiate. Drop the force parameter, and pass caps
>> instead, to avoid redundant re-reading of MSR_ARCH_CAPS.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
>
> Reviewed-by: Juergen Gross <jgross@suse.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] x86/spec-ctrl: Fix the parsing of xpti= on fixed Intel hardware
2018-07-23 13:48 [PATCH] x86/spec-ctrl: Fix the parsing of xpti= on fixed Intel hardware Andrew Cooper
2018-07-23 14:22 ` Juergen Gross
@ 2018-07-23 14:33 ` Wei Liu
1 sibling, 0 replies; 4+ messages in thread
From: Wei Liu @ 2018-07-23 14:33 UTC (permalink / raw)
To: Andrew Cooper
Cc: Juergen Gross, Sergey Dyasli, Wei Liu, Xen-devel, Jan Beulich,
Roger Pau Monné
On Mon, Jul 23, 2018 at 02:48:02PM +0100, Andrew Cooper wrote:
> The calls to xpti_init_default() in parse_xpti() are buggy. The CPUID data
> hasn't been fetched that early, and boot_cpu_has(X86_FEATURE_ARCH_CAPS) will
> always evaluate false.
>
> As a result, the default case won't disable XPTI on Intel hardware which
> advertises ARCH_CAPABILITIES_RDCL_NO.
>
> Simplify parse_xpti() to solely the setting of opt_xpti according to the
> passed string, and have init_speculation_mitigations() call
> xpti_init_default() if appropiate. Drop the force parameter, and pass caps
> instead, to avoid redundant re-reading of MSR_ARCH_CAPS.
>
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-24 10:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-23 13:48 [PATCH] x86/spec-ctrl: Fix the parsing of xpti= on fixed Intel hardware Andrew Cooper
2018-07-23 14:22 ` Juergen Gross
2018-07-24 10:12 ` Jan Beulich
2018-07-23 14:33 ` Wei Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.