On 5/11/2022 7:57 AM, Kirill A. Shutemov wrote: > LAM_U48 steals bits above 47-bit for tags and makes it impossible for > userspace to use full address space on 5-level paging machine. > > Make these features mutually exclusive: whichever gets enabled first > blocks the othe one. > > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> > --- > arch/x86/include/asm/elf.h | 3 ++- > arch/x86/include/asm/mmu_context.h | 13 +++++++++++++ > arch/x86/kernel/sys_x86_64.c | 5 +++-- > arch/x86/mm/hugetlbpage.c | 6 ++++-- > arch/x86/mm/mmap.c | 9 ++++++++- > 5 files changed, 30 insertions(+), 6 deletions(-) > > diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h > index 29fea180a665..53b96b0c8cc3 100644 > --- a/arch/x86/include/asm/elf.h > +++ b/arch/x86/include/asm/elf.h > @@ -328,7 +328,8 @@ static inline int mmap_is_ia32(void) > extern unsigned long task_size_32bit(void); > extern unsigned long task_size_64bit(int full_addr_space); > extern unsigned long get_mmap_base(int is_legacy); > -extern bool mmap_address_hint_valid(unsigned long addr, unsigned long len); > +extern bool mmap_address_hint_valid(struct mm_struct *mm, > + unsigned long addr, unsigned long len); > extern unsigned long get_sigframe_size(void); > > #ifdef CONFIG_X86_32 > diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h > index 27516046117a..c8a6d80dfec3 100644 > --- a/arch/x86/include/asm/mmu_context.h > +++ b/arch/x86/include/asm/mmu_context.h > @@ -218,6 +218,19 @@ static inline bool arch_vma_access_permitted(struct vm_area_struct *vma, > > unsigned long __get_current_cr3_fast(void); > > +#ifdef CONFIG_X86_5LEVEL > +static inline bool full_va_allowed(struct mm_struct *mm) > +{ > + /* LAM_U48 steals VA bits abouve 47-bit for tags */ > + return mm->context.lam != LAM_U48; > +} > +#else This is called from X86 common code but appears to be LAM-specific. What would mm->context.lam contain if X86_FEATURE_LAM isn't set? Regards, Bharata.