Re: [PATCH v7 1/4] RISC-V: mm: Restrict address space for sv39,sv48,sv57

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey Charlie,

On Wed, Jul 26, 2023 at 09:45:55AM -0700, Charlie Jenkins wrote:
> Make sv48 the default address space for mmap as some applications
> currently depend on this assumption. A hint address passed to mmap will
> cause the largest address space that fits entirely into the hint to be
> used. If the hint is less than or equal to 1<<38, an sv39 address will
> be used. An exception is that if the hint address is 0, then a sv48
> address will be used. After an address space is completely full, the next
> smallest address space will be used.
> 
> Signed-off-by: Charlie Jenkins <charlie@xxxxxxxxxxxx>
> ---
>  arch/riscv/include/asm/elf.h       |  2 +-
>  arch/riscv/include/asm/pgtable.h   | 13 ++++++++-
>  arch/riscv/include/asm/processor.h | 47 +++++++++++++++++++++++++-----
>  3 files changed, 53 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/riscv/include/asm/elf.h b/arch/riscv/include/asm/elf.h
> index c24280774caf..5d3368d5585c 100644
> --- a/arch/riscv/include/asm/elf.h
> +++ b/arch/riscv/include/asm/elf.h
> @@ -49,7 +49,7 @@ extern bool compat_elf_check_arch(Elf32_Ehdr *hdr);
>   * the loader.  We need to make sure that it is out of the way of the program
>   * that it will "exec", and that there is sufficient room for the brk.
>   */
> -#define ELF_ET_DYN_BASE		((TASK_SIZE / 3) * 2)
> +#define ELF_ET_DYN_BASE		((DEFAULT_MAP_WINDOW / 3) * 2)
>  
>  #ifdef CONFIG_64BIT
>  #ifdef CONFIG_COMPAT
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index 75970ee2bda2..530f6a171a2b 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -63,12 +63,23 @@
>   * position vmemmap directly below the VMALLOC region.
>   */
>  #ifdef CONFIG_64BIT
> +#define VA_BITS_SV39 39
> +#define VA_BITS_SV48 48
> +#define VA_BITS_SV57 57
> +
> +#define VA_USER_SV39 (UL(1) << (VA_BITS_SV39 - 1))
> +#define VA_USER_SV48 (UL(1) << (VA_BITS_SV48 - 1))
> +#define VA_USER_SV57 (UL(1) << (VA_BITS_SV57 - 1))
> +
>  #define VA_BITS		(pgtable_l5_enabled ? \
> -				57 : (pgtable_l4_enabled ? 48 : 39))
> +				VA_BITS_SV57 : (pgtable_l4_enabled ? VA_BITS_SV48 : VA_BITS_SV39))
>  #else
>  #define VA_BITS		32
>  #endif

Please, at the very least, build test things for rv32 if you are going
to change things in mm:
io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39'
io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39'
io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39'
io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39'
io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39'
io_uring/io_uring.c:3457:20: error: use of undeclared identifier 'VA_BITS_SV39'
mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39'
mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39'
mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39'
mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39'
mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39'
mm/util.c:441:19: error: use of undeclared identifier 'VA_BITS_SV39'
mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39'
mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39'
mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39'
mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39'
mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39'
mm/mmap.c:1770:20: error: use of undeclared identifier 'VA_BITS_SV39'

Thanks,
Conor.

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux