Re: [RFC PATCH v0 3/6] x86: Enable Upper Address Ignore(UAI) feature

From: Andrew Cooper
Date: Thu Mar 10 2022 - 14:47:11 EST


On 10/03/2022 11:15, Bharata B Rao wrote:
> diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
> index f7a132eb794d..12615b1b4af5 100644
> --- a/arch/x86/kernel/setup.c
> +++ b/arch/x86/kernel/setup.c
> @@ -740,6 +740,12 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
> return 0;
> }
>
> +static inline void __init uai_enable(void)
> +{
> + if (boot_cpu_has(X86_FEATURE_UAI))
> + msr_set_bit(MSR_EFER, _EFER_UAI);
> +}
> +
> /*
> * Determine if we were loaded by an EFI loader. If so, then we have also been
> * passed the efi memmap, systab, etc., so we should use these data structures
> @@ -1146,6 +1152,8 @@ void __init setup_arch(char **cmdline_p)
>
> x86_init.paging.pagetable_init();
>
> + uai_enable();

I would think incredibly carefully before enabling UAI by default.

Suffice it to say that Intel were talked down from 7 bits to 6, and
apparently AMD didn't get the same memo from the original requesters.

The problem is that UAI + LA57 means that all the poison pointers cease
functioning as a defence-in-depth mechanism, and become legal pointers
pointing at random positions in user or kernel space.

~Andrew