Re: [patch V2 2/5] x86/kaiser: Simplify disabling of global pages

From: Dave Hansen
Date: Mon Nov 27 2017 - 13:15:39 EST


On 11/26/2017 03:14 PM, Thomas Gleixner wrote:
> +static void enable_global_pages(void)
> +{
> +#ifndef CONFIG_KAISER
> + __supported_pte_mask |= _PAGE_GLOBAL;
> +#endif
> +}
> +
> static void __init probe_page_size_mask(void)
> {
> /*
> @@ -179,11 +186,11 @@ static void __init probe_page_size_mask(
> cr4_set_bits_and_update_boot(X86_CR4_PSE);
>
> /* Enable PGE if available */
> + __supported_pte_mask |= _PAGE_GLOBAL;
> if (boot_cpu_has(X86_FEATURE_PGE)) {
> cr4_set_bits_and_update_boot(X86_CR4_PGE);
> - __supported_pte_mask |= _PAGE_GLOBAL;
> - } else
> - __supported_pte_mask &= ~_PAGE_GLOBAL;
> + enable_global_pages();
> + }

This looks a little funky. Doesn't this or _PAGE_GLOBAL into
__supported_pte_mask twice? Once before the if(), and then a second
time via enable_global_pages() inside the if?

Did you intend for it to be masked *out* in the first one and then or'd
back in via enable_global_pages()?