Skip to contentSkip to conversation

x86/amd: don't set X86_BUG_SYSRET_SS_ATTRS if forced to zero

PATCH In review Juergen Gross 3 participants 21 messages Apr 25, 2017 – Apr 27, 2017 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/amd: don't set X86_BUG_SYSRET_SS_ATTRS if forced to zero

When running as Xen pv guest X86_BUG_SYSRET_SS_ATTRS must not be set on AMD cpus. Xen will disable this via setup_clear_cpu_cap(), so test cpu_caps_cleared to not have disabled this bit.

This bug/feature bit is kind of special as it will be used very early when switching threads. Setting the bit and clearing it a little bit later leaves a critical window where things can go wrong. This time window has enlarged a little bit by using setup_clear_cpu_cap() instead of the hypervisor's set_cpu_features callback. It seems this larger window now makes it rather easy to hit the problem.

The proper solution is to never set the bit in case of Xen.

---
 arch/x86/kernel/cpu/amd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +3 -1
index c36140d788fe..f659b6f534b7 100644
@@ -800,7 +800,9 @@ static void init_amd(struct cpuinfo_x86 *c)
 			set_cpu_cap(c, X86_FEATURE_3DNOWPREFETCH);
 
 	/* AMD CPUs don't reset SS attributes on SYSRET */
-	set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
+	if (!test_bit(X86_BUG_SYSRET_SS_ATTRS,
+		      (unsigned long *)cpu_caps_cleared))
+		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
 }
 
 #ifdef CONFIG_X86_32
Signature · 1 line
2.12.0
maintainer
#1 lore raw
Quoted 23 lines · Juergen Gross

When running as Xen pv guest X86_BUG_SYSRET_SS_ATTRS must not be set on AMD cpus. Xen will disable this via setup_clear_cpu_cap(), so test cpu_caps_cleared to not have disabled this bit.

This bug/feature bit is kind of special as it will be used very early when switching threads. Setting the bit and clearing it a little bit later leaves a critical window where things can go wrong. This time window has enlarged a little bit by using setup_clear_cpu_cap() instead of the hypervisor's set_cpu_features callback. It seems this larger window now makes it rather easy to hit the problem.

The proper solution is to never set the bit in case of Xen.

---
 arch/x86/kernel/cpu/amd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +0 -0
index c36140d788fe..f659b6f534b7 100644

arch/x86/kernel/cpu/amd.c static void init_amd(struct cpuinfo_x86 *c) · line 806

Quoted 8 lines
arch/x86/kernel/cpu/amd.c +3 -1
@@ -800,7 +800,9 @@ static void init_amd(struct cpuinfo_x86 *c)
 			set_cpu_cap(c, X86_FEATURE_3DNOWPREFETCH);
 
 	/* AMD CPUs don't reset SS attributes on SYSRET */
-	set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
+	if (!test_bit(X86_BUG_SYSRET_SS_ATTRS,
+		      (unsigned long *)cpu_caps_cleared))
+		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
 }

Hold on, AFAICT we have this order:

c_init() -> init_amd() sets X86_BUG_SYSRET_SS_ATTRS init_hypervisor->x86_hyper->set_cpu_features-> clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

and all is good.

And I remember seeing a patchset doing some xen cpuid cleanup so I'm assuming you're doing setup_clear_cpu_cap() now? And now we have to wag the dog?

Confused.

Signature · 9 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
maintainer
#2 lore raw
In reply to Juergen Gross
Quoted 23 lines · Juergen Gross

When running as Xen pv guest X86_BUG_SYSRET_SS_ATTRS must not be set on AMD cpus. Xen will disable this via setup_clear_cpu_cap(), so test cpu_caps_cleared to not have disabled this bit.

This bug/feature bit is kind of special as it will be used very early when switching threads. Setting the bit and clearing it a little bit later leaves a critical window where things can go wrong. This time window has enlarged a little bit by using setup_clear_cpu_cap() instead of the hypervisor's set_cpu_features callback. It seems this larger window now makes it rather easy to hit the problem.

The proper solution is to never set the bit in case of Xen.

---
 arch/x86/kernel/cpu/amd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +0 -0
index c36140d788fe..f659b6f534b7 100644

arch/x86/kernel/cpu/amd.c static void init_amd(struct cpuinfo_x86 *c) · line 806

Quoted 8 lines
arch/x86/kernel/cpu/amd.c +3 -1
@@ -800,7 +800,9 @@ static void init_amd(struct cpuinfo_x86 *c)
 			set_cpu_cap(c, X86_FEATURE_3DNOWPREFETCH);
 
 	/* AMD CPUs don't reset SS attributes on SYSRET */
-	set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
+	if (!test_bit(X86_BUG_SYSRET_SS_ATTRS,
+		      (unsigned long *)cpu_caps_cleared))
+		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
 }

Hold on, AFAICT we have this order:

c_init() -> init_amd() sets X86_BUG_SYSRET_SS_ATTRS init_hypervisor->x86_hyper->set_cpu_features-> clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

and all is good.

And I remember seeing a patchset doing some xen cpuid cleanup so I'm assuming you're doing setup_clear_cpu_cap() now? And now we have to wag the dog?

Confused.

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
#3 lore raw
Quoted 35 lines · Borislav Petkov
Quoted 23 lines · Juergen Gross

When running as Xen pv guest X86_BUG_SYSRET_SS_ATTRS must not be set on AMD cpus. Xen will disable this via setup_clear_cpu_cap(), so test cpu_caps_cleared to not have disabled this bit.

This bug/feature bit is kind of special as it will be used very early when switching threads. Setting the bit and clearing it a little bit later leaves a critical window where things can go wrong. This time window has enlarged a little bit by using setup_clear_cpu_cap() instead of the hypervisor's set_cpu_features callback. It seems this larger window now makes it rather easy to hit the problem.

The proper solution is to never set the bit in case of Xen.

---
 arch/x86/kernel/cpu/amd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +0 -0
index c36140d788fe..f659b6f534b7 100644

arch/x86/kernel/cpu/amd.c static void init_amd(struct cpuinfo_x86 *c) · line 806

Quoted 8 lines
arch/x86/kernel/cpu/amd.c +3 -1
@@ -800,7 +800,9 @@ static void init_amd(struct cpuinfo_x86 *c)
 			set_cpu_cap(c, X86_FEATURE_3DNOWPREFETCH);
 
 	/* AMD CPUs don't reset SS attributes on SYSRET */
-	set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
+	if (!test_bit(X86_BUG_SYSRET_SS_ATTRS,
+		      (unsigned long *)cpu_caps_cleared))
+		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
 }

Hold on, AFAICT we have this order:

Quoted 1 line

c_init() -> init_amd() sets X86_BUG_SYSRET_SS_ATTRS

And what happens when there is a scheduling event right here? __switch_to() will see X86_BUG_SYSRET_SS_ATTRS set and take a wrong path.

Quoted 1 line

init_hypervisor->x86_hyper->set_cpu_features-> clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

And now (with setup_clear_cpu_cap()) the bit is cleared a little bit later. And all should be good. But it isn't.

Quoted 6 lines

and all is good.

And I remember seeing a patchset doing some xen cpuid cleanup so I'm assuming you're doing setup_clear_cpu_cap() now? And now we have to wag the dog?

No, now the time window with X86_BUG_SYSRET_SS_ATTRS set is so long we actually see the problem happening.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#4 lore raw
In reply to Borislav Petkov
Quoted 35 lines · Borislav Petkov
Quoted 23 lines · Juergen Gross

When running as Xen pv guest X86_BUG_SYSRET_SS_ATTRS must not be set on AMD cpus. Xen will disable this via setup_clear_cpu_cap(), so test cpu_caps_cleared to not have disabled this bit.

This bug/feature bit is kind of special as it will be used very early when switching threads. Setting the bit and clearing it a little bit later leaves a critical window where things can go wrong. This time window has enlarged a little bit by using setup_clear_cpu_cap() instead of the hypervisor's set_cpu_features callback. It seems this larger window now makes it rather easy to hit the problem.

The proper solution is to never set the bit in case of Xen.

---
 arch/x86/kernel/cpu/amd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/amd.c +0 -0
index c36140d788fe..f659b6f534b7 100644

arch/x86/kernel/cpu/amd.c static void init_amd(struct cpuinfo_x86 *c) · line 806

Quoted 8 lines
arch/x86/kernel/cpu/amd.c +3 -1
@@ -800,7 +800,9 @@ static void init_amd(struct cpuinfo_x86 *c)
 			set_cpu_cap(c, X86_FEATURE_3DNOWPREFETCH);
 
 	/* AMD CPUs don't reset SS attributes on SYSRET */
-	set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
+	if (!test_bit(X86_BUG_SYSRET_SS_ATTRS,
+		      (unsigned long *)cpu_caps_cleared))
+		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);
 }

Hold on, AFAICT we have this order:

Quoted 1 line

c_init() -> init_amd() sets X86_BUG_SYSRET_SS_ATTRS

And what happens when there is a scheduling event right here? __switch_to() will see X86_BUG_SYSRET_SS_ATTRS set and take a wrong path.

Quoted 1 line

init_hypervisor->x86_hyper->set_cpu_features-> clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

And now (with setup_clear_cpu_cap()) the bit is cleared a little bit later. And all should be good. But it isn't.

Quoted 6 lines

and all is good.

And I remember seeing a patchset doing some xen cpuid cleanup so I'm assuming you're doing setup_clear_cpu_cap() now? And now we have to wag the dog?

No, now the time window with X86_BUG_SYSRET_SS_ATTRS set is so long we actually see the problem happening.

Juergen

maintainer
#5 lore raw
Quoted 3 lines · Juergen Gross

And what happens when there is a scheduling event right here? __switch_to() will see X86_BUG_SYSRET_SS_ATTRS set and take a wrong path.

So the whole thing we're doing right now is wrong: set bit and then clear bit.

We should not set the bit at all and there won't be any window to get it wrong.

So can we do something like this instead:

	if (!cpu_has(c, X86_FEATURE_XENPV))
		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

or is XENPV the wrong thing to test?

Signature · 9 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
maintainer
#6 lore raw
In reply to Juergen Gross
Quoted 3 lines · Juergen Gross

And what happens when there is a scheduling event right here? __switch_to() will see X86_BUG_SYSRET_SS_ATTRS set and take a wrong path.

So the whole thing we're doing right now is wrong: set bit and then clear bit.

We should not set the bit at all and there won't be any window to get it wrong.

So can we do something like this instead:

	if (!cpu_has(c, X86_FEATURE_XENPV))
		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

or is XENPV the wrong thing to test?

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
#7 lore raw
Quoted 10 lines · Borislav Petkov
Quoted 3 lines · Juergen Gross

And what happens when there is a scheduling event right here? __switch_to() will see X86_BUG_SYSRET_SS_ATTRS set and take a wrong path.

So the whole thing we're doing right now is wrong: set bit and then clear bit.

We should not set the bit at all and there won't be any window to get it wrong.

Quoted 7 lines

So can we do something like this instead:

	if (!cpu_has(c, X86_FEATURE_XENPV))
		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

or is XENPV the wrong thing to test?

X86_BUG_SYSRET_SS_ATTRS only actually causes a problem if you enter the kernel via an IDT vector (forcing %ss to NULL), then exiting the kernel via the optimistic sysret path, which on AMD loads the %ss selector, but apparently doesn't update the segment cache (and %ss.dpl in particular).

The problem (for all ring-deprivileged virtuailsation; not just Xen PV), is that

savesegment(ss, ss_sel);
if (ss_sel != __KERNEL_DS)

    loadsegment(ss, __KERNEL_DS);

tries to load %ss with an RPL of 0, and things blow up.

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#8 lore raw
In reply to Borislav Petkov
Quoted 10 lines · Borislav Petkov
Quoted 3 lines · Juergen Gross

And what happens when there is a scheduling event right here? __switch_to() will see X86_BUG_SYSRET_SS_ATTRS set and take a wrong path.

So the whole thing we're doing right now is wrong: set bit and then clear bit.

We should not set the bit at all and there won't be any window to get it wrong.

Quoted 7 lines

So can we do something like this instead:

	if (!cpu_has(c, X86_FEATURE_XENPV))
		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

or is XENPV the wrong thing to test?

X86_BUG_SYSRET_SS_ATTRS only actually causes a problem if you enter the kernel via an IDT vector (forcing %ss to NULL), then exiting the kernel via the optimistic sysret path, which on AMD loads the %ss selector, but apparently doesn't update the segment cache (and %ss.dpl in particular).

The problem (for all ring-deprivileged virtuailsation; not just Xen PV), is that

savesegment(ss, ss_sel);
if (ss_sel != __KERNEL_DS)

    loadsegment(ss, __KERNEL_DS);

tries to load %ss with an RPL of 0, and things blow up.

~Andrew

maintainer
#9 lore raw
Quoted 2 lines · Andrew Cooper

The problem (for all ring-deprivileged virtuailsation; not just Xen PV), is that

I know what that that bug flag is for.

I'm asking whether the xen guest boot sets a flag early - like XENPV, for example - which can differentiate between baremetal and virt boot in a fairly generic manner so that we don't set that bug flag then instead of the set and then clear dance we do currently.

Signature · 9 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
maintainer
#10 lore raw
In reply to Andrew Cooper
Quoted 2 lines · Andrew Cooper

The problem (for all ring-deprivileged virtuailsation; not just Xen PV), is that

I know what that that bug flag is for.

I'm asking whether the xen guest boot sets a flag early - like XENPV, for example - which can differentiate between baremetal and virt boot in a fairly generic manner so that we don't set that bug flag then instead of the set and then clear dance we do currently.

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
#11 lore raw
In reply to Borislav Petkov
Quoted 7 lines · Borislav Petkov
Quoted 3 lines · Juergen Gross

And what happens when there is a scheduling event right here? __switch_to() will see X86_BUG_SYSRET_SS_ATTRS set and take a wrong path.

So the whole thing we're doing right now is wrong: set bit and then clear bit.

Right. And this is handled by my patch.

The really clean solution would be to add this test to set_cpu_bug() et al. Don't set/clear the bit if anyone selected to force a value. The force variants would be capable to overwrite, the normal variants wouldn't. This would require a lot of research to avoid pitfalls with today's handling, though. OTOH one could remove all the calls to apply_forced_caps().

Quoted 10 lines

We should not set the bit at all and there won't be any window to get it wrong.

So can we do something like this instead:

	if (!cpu_has(c, X86_FEATURE_XENPV))
		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

or is XENPV the wrong thing to test?

This would work. OTOH I'd prefer to test whether the bit should be forced to remain zero than use the knowledge _who_ is trying to force it.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#12 lore raw
In reply to Borislav Petkov
Quoted 7 lines · Borislav Petkov
Quoted 3 lines · Juergen Gross

And what happens when there is a scheduling event right here? __switch_to() will see X86_BUG_SYSRET_SS_ATTRS set and take a wrong path.

So the whole thing we're doing right now is wrong: set bit and then clear bit.

Right. And this is handled by my patch.

The really clean solution would be to add this test to set_cpu_bug() et al. Don't set/clear the bit if anyone selected to force a value. The force variants would be capable to overwrite, the normal variants wouldn't. This would require a lot of research to avoid pitfalls with today's handling, though. OTOH one could remove all the calls to apply_forced_caps().

Quoted 10 lines

We should not set the bit at all and there won't be any window to get it wrong.

So can we do something like this instead:

	if (!cpu_has(c, X86_FEATURE_XENPV))
		set_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

or is XENPV the wrong thing to test?

This would work. OTOH I'd prefer to test whether the bit should be forced to remain zero than use the knowledge _who_ is trying to force it.

Juergen

maintainer
#13 lore raw
Quoted 1 line · Juergen Gross

The really clean solution would be to add this test to set_cpu_bug()

No, the really clean solution is to set it once and not play toggle games.

Quoted 3 lines

This would work. OTOH I'd prefer to test whether the bit should be forced to remain zero than use the knowledge _who_ is trying to force it.

Because we're in the business of investigating who did?

Nah, we should set it or clear it once and not do funky toggle games. Especially if in the future something else changes and timing windows grow and we refactor stuff and yadda yadda...

Signature · 9 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
maintainer
#14 lore raw
In reply to Juergen Gross
Quoted 1 line · Juergen Gross

The really clean solution would be to add this test to set_cpu_bug()

No, the really clean solution is to set it once and not play toggle games.

Quoted 3 lines

This would work. OTOH I'd prefer to test whether the bit should be forced to remain zero than use the knowledge _who_ is trying to force it.

Because we're in the business of investigating who did?

Nah, we should set it or clear it once and not do funky toggle games. Especially if in the future something else changes and timing windows grow and we refactor stuff and yadda yadda...

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
#15 lore raw
Quoted 10 lines · Borislav Petkov
Quoted 1 line · Juergen Gross

The really clean solution would be to add this test to set_cpu_bug()

No, the really clean solution is to set it once and not play toggle games.

Quoted 3 lines

This would work. OTOH I'd prefer to test whether the bit should be forced to remain zero than use the knowledge _who_ is trying to force it.

Quoted 5 lines

Because we're in the business of investigating who did?

Nah, we should set it or clear it once and not do funky toggle games. Especially if in the future something else changes and timing windows grow and we refactor stuff and yadda yadda...

So what else is my patch doing? It is avoiding to set the bit in case somebody (i.e. Xen) was forcing it to remain zero.

I'm not feeling strong about it. So if you want to test for X86_FEATURE_XENPV to avoid setting X86_BUG_SYSRET_SS_ATTRS I'm fine with it.

Will send V2 with that change.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#16 lore raw
In reply to Borislav Petkov
Quoted 10 lines · Borislav Petkov
Quoted 1 line · Juergen Gross

The really clean solution would be to add this test to set_cpu_bug()

No, the really clean solution is to set it once and not play toggle games.

Quoted 3 lines

This would work. OTOH I'd prefer to test whether the bit should be forced to remain zero than use the knowledge _who_ is trying to force it.

Quoted 5 lines

Because we're in the business of investigating who did?

Nah, we should set it or clear it once and not do funky toggle games. Especially if in the future something else changes and timing windows grow and we refactor stuff and yadda yadda...

So what else is my patch doing? It is avoiding to set the bit in case somebody (i.e. Xen) was forcing it to remain zero.

I'm not feeling strong about it. So if you want to test for X86_FEATURE_XENPV to avoid setting X86_BUG_SYSRET_SS_ATTRS I'm fine with it.

Will send V2 with that change.

Juergen

maintainer
#17 lore raw
Quoted 5 lines · Juergen Gross

I'm not feeling strong about it. So if you want to test for X86_FEATURE_XENPV to avoid setting X86_BUG_SYSRET_SS_ATTRS I'm fine with it.

Will send V2 with that change.

And remove the corresponding

	clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

in xen_set_cpu_features().

So that we can set it once, only on !XENPV feature set.

/me looks again at the code...

Gah, except that we do

	set_cpu_cap(c, X86_FEATURE_XENPV);

and that runs as part of init_hypervisor() and it runs *after* c_init().

So, back to square one. :-\

So lemme try to explain again what I mean:

I'd like to have a generic way of detecting whether I'm running as a xen guest at ->c_init() time and depending on the result of that detection, to set X86_BUG_SYSRET_SS_ATTRS or not set it.

Does that make more sense?

Thanks.

Signature · 9 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
maintainer
#18 lore raw
In reply to Juergen Gross
Quoted 5 lines · Juergen Gross

I'm not feeling strong about it. So if you want to test for X86_FEATURE_XENPV to avoid setting X86_BUG_SYSRET_SS_ATTRS I'm fine with it.

Will send V2 with that change.

And remove the corresponding

	clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

in xen_set_cpu_features().

So that we can set it once, only on !XENPV feature set.

/me looks again at the code...

Gah, except that we do

	set_cpu_cap(c, X86_FEATURE_XENPV);

and that runs as part of init_hypervisor() and it runs *after* c_init().

So, back to square one. :-\

So lemme try to explain again what I mean:

I'd like to have a generic way of detecting whether I'm running as a xen guest at ->c_init() time and depending on the result of that detection, to set X86_BUG_SYSRET_SS_ATTRS or not set it.

Does that make more sense?

Thanks.

Signature · 4 lines
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.
#19 lore raw
Quoted 5 lines · Borislav Petkov
Quoted 4 lines · Juergen Gross

I'm not feeling strong about it. So if you want to test for X86_FEATURE_XENPV to avoid setting X86_BUG_SYSRET_SS_ATTRS I'm fine with it.

Quoted 7 lines
Quoted 1 line

Will send V2 with that change.

And remove the corresponding

	clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

in xen_set_cpu_features().

Okay, you are right, we can omit this one now.

Quoted 9 lines

So that we can set it once, only on !XENPV feature set.

/me looks again at the code...

Gah, except that we do

	set_cpu_cap(c, X86_FEATURE_XENPV);

and that runs as part of init_hypervisor() and it runs *after* c_init().

No, this is called by xen_start_kernel(), long before c_init().

Quoted 9 lines

So, back to square one. :-\

So lemme try to explain again what I mean:

I'd like to have a generic way of detecting whether I'm running as a xen guest at ->c_init() time and depending on the result of that detection, to set X86_BUG_SYSRET_SS_ATTRS or not set it.

Does that make more sense?

This does make sense and it is working, as Sander could confirm.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#20 lore raw
In reply to Borislav Petkov
Quoted 5 lines · Borislav Petkov
Quoted 4 lines · Juergen Gross

I'm not feeling strong about it. So if you want to test for X86_FEATURE_XENPV to avoid setting X86_BUG_SYSRET_SS_ATTRS I'm fine with it.

Quoted 7 lines
Quoted 1 line

Will send V2 with that change.

And remove the corresponding

	clear_cpu_bug(c, X86_BUG_SYSRET_SS_ATTRS);

in xen_set_cpu_features().

Okay, you are right, we can omit this one now.

Quoted 9 lines

So that we can set it once, only on !XENPV feature set.

/me looks again at the code...

Gah, except that we do

	set_cpu_cap(c, X86_FEATURE_XENPV);

and that runs as part of init_hypervisor() and it runs *after* c_init().

No, this is called by xen_start_kernel(), long before c_init().

Quoted 9 lines

So, back to square one. :-\

So lemme try to explain again what I mean:

I'd like to have a generic way of detecting whether I'm running as a xen guest at ->c_init() time and depending on the result of that detection, to set X86_BUG_SYSRET_SS_ATTRS or not set it.

Does that make more sense?

This does make sense and it is working, as Sander could confirm.

Juergen