Skip to contentSkip to conversation

x86: properly gate clearing of PKU feature

PATCH In review Jan Beulich 2 participants 5 messages Aug 29, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: properly gate clearing of PKU feature

setup_clear_cpu_cap() is __init and hence may not be called post-boot. Note that opt_pku nevertheless is not getting __initdata added - see e.g. commit 43fa95ae6a ("mm: make opt_bootscrub non-init").

xen/arch/x86/cpu/common.c +1 -1
@@ -466,7 +466,7 @@ void identify_cpu(struct cpuinfo_x86 *c)
 		this_cpu->c_init(c);
 
 
-   	if ( !opt_pku )
+   	if (c == &boot_cpu_data && !opt_pku)
 		setup_clear_cpu_cap(X86_FEATURE_PKU);
 
 	/*

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

Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Jan Beulich

setup_clear_cpu_cap() is __init and hence may not be called post-boot. Note that opt_pku nevertheless is not getting __initdata added - see e.g. commit 43fa95ae6a ("mm: make opt_bootscrub non-init").

However, I'm tempted to suggest that this logic disappears entirely. Given that we don't support it for PV guests, and can't without taking a CR4 write on toggle_kernel_mode(), all this actually controls is whether the bit finds its way into the HVM max policy.

~Andrew

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

#2 lore raw
Quoted 5 lines · Andrew Cooper
Quoted 4 lines · Jan Beulich

setup_clear_cpu_cap() is __init and hence may not be called post-boot. Note that opt_pku nevertheless is not getting __initdata added - see e.g. commit 43fa95ae6a ("mm: make opt_bootscrub non-init").

Quoted 8 lines
Quoted 1 line

However, I'm tempted to suggest that this logic disappears entirely. Given that we don't support it for PV guests, and can't without taking a CR4 write on toggle_kernel_mode(), all this actually controls is whether the bit finds its way into the HVM max policy.

Well, if you mean replacing opt_pku by an addition to parse_xen_cpuid(), then I'll be happy to do that as a follow-on. If there is another direction you've been considering, then you'd have to at least outline it.

Jan

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

#3 lore raw
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Andrew Cooper
Quoted 5 lines · Jan Beulich

setup_clear_cpu_cap() is __init and hence may not be called post-boot. Note that opt_pku nevertheless is not getting __initdata added - see e.g. commit 43fa95ae6a ("mm: make opt_bootscrub non-init").

Quoted 8 lines
Quoted 4 lines

However, I'm tempted to suggest that this logic disappears entirely. Given that we don't support it for PV guests, and can't without taking a CR4 write on toggle_kernel_mode(), all this actually controls is whether the bit finds its way into the HVM max policy.

Well, if you mean replacing opt_pku by an addition to parse_xen_cpuid(), then I'll be happy to do that as a follow-on. If there is another direction you've been considering, then you'd have to at least outline it.

Well - I did say "disappear entirely".  I don't see it as having, or liable to gain, any useful purpose.

In reality, it was subsumed into cpuid= by my patch to allow all bits to be tweak-able.

~Andrew

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

#4 lore raw
Quoted 19 lines · Andrew Cooper
Quoted 9 lines · Jan Beulich
Quoted 8 lines · Andrew Cooper
Quoted 5 lines · Jan Beulich

setup_clear_cpu_cap() is __init and hence may not be called post-boot. Note that opt_pku nevertheless is not getting __initdata added - see e.g. commit 43fa95ae6a ("mm: make opt_bootscrub non-init").

Quoted 8 lines
Quoted 4 lines

However, I'm tempted to suggest that this logic disappears entirely. Given that we don't support it for PV guests, and can't without taking a CR4 write on toggle_kernel_mode(), all this actually controls is whether the bit finds its way into the HVM max policy.

Well, if you mean replacing opt_pku by an addition to parse_xen_cpuid(), then I'll be happy to do that as a follow-on. If there is another direction you've been considering, then you'd have to at least outline it.

Quoted 5 lines

Well - I did say "disappear entirely".  I don't see it as having, or liable to gain, any useful purpose.

In reality, it was subsumed into cpuid= by my patch to allow all bits to be tweak-able.

Did you post this patch already (I don't seem to recall; I only recall there being the plan to do this)?

Jan

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