diff mbox series

[1/4] riscv: Fix TASK_SIZE on 64-bit NOMMU

Message ID 20240227003630.3634533-2-samuel.holland@sifive.com (mailing list archive)
State Accepted
Commit 6065e736f82c817c9a597a31ee67f0ce4628e948
Headers show
Series riscv: 64-bit NOMMU fixes and enhancements | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh
conchuod/patch-1-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh
conchuod/patch-1-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh
conchuod/patch-1-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-1-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-1-test-6 success .github/scripts/patches/tests/checkpatch.sh
conchuod/patch-1-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh
conchuod/patch-1-test-8 success .github/scripts/patches/tests/header_inline.sh
conchuod/patch-1-test-9 success .github/scripts/patches/tests/kdoc.sh
conchuod/patch-1-test-10 success .github/scripts/patches/tests/module_param.sh
conchuod/patch-1-test-11 success .github/scripts/patches/tests/verify_fixes.sh
conchuod/patch-1-test-12 success .github/scripts/patches/tests/verify_signedoff.sh

Commit Message

Samuel Holland Feb. 27, 2024, 12:34 a.m. UTC
On NOMMU, userspace memory can come from anywhere in physical RAM. The
current definition of TASK_SIZE is wrong if any RAM exists above 4G,
causing spurious failures in the userspace access routines.

Fixes: 6bd33e1ece52 ("riscv: add nommu support")
Fixes: c3f896dcf1e4 ("mm: switch the test_vmalloc module to use __vmalloc_node")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
---

 arch/riscv/include/asm/pgtable.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jisheng Zhang March 27, 2024, 7:04 a.m. UTC | #1
On Mon, Feb 26, 2024 at 04:34:46PM -0800, Samuel Holland wrote:
> On NOMMU, userspace memory can come from anywhere in physical RAM. The
> current definition of TASK_SIZE is wrong if any RAM exists above 4G,
> causing spurious failures in the userspace access routines.
> 
> Fixes: 6bd33e1ece52 ("riscv: add nommu support")
> Fixes: c3f896dcf1e4 ("mm: switch the test_vmalloc module to use __vmalloc_node")
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>

Reviewed-by: Jisheng Zhang <jszhang@kernel.org>

> ---
> 
>  arch/riscv/include/asm/pgtable.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index 0c94260b5d0c..a564a39e5676 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -882,7 +882,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
>  #define PAGE_SHARED		__pgprot(0)
>  #define PAGE_KERNEL		__pgprot(0)
>  #define swapper_pg_dir		NULL
> -#define TASK_SIZE		0xffffffffUL
> +#define TASK_SIZE		_AC(-1, UL)
>  #define VMALLOC_START		_AC(0, UL)
>  #define VMALLOC_END		TASK_SIZE
>  
> -- 
> 2.43.0
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
Bo Gan March 27, 2024, 7:54 a.m. UTC | #2
On 3/27/24 12:04 AM, Jisheng Zhang wrote:
> On Mon, Feb 26, 2024 at 04:34:46PM -0800, Samuel Holland wrote:
>> On NOMMU, userspace memory can come from anywhere in physical RAM. The
>> current definition of TASK_SIZE is wrong if any RAM exists above 4G,
>> causing spurious failures in the userspace access routines.
>>
>> Fixes: 6bd33e1ece52 ("riscv: add nommu support")
>> Fixes: c3f896dcf1e4 ("mm: switch the test_vmalloc module to use __vmalloc_node")
>> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> 
> Reviewed-by: Jisheng Zhang <jszhang@kernel.org>
> 

Reviewed-by: Bo Gan <ganboing@gmail.com>

Thanks for this patch! I'm doing something similar locally and it fixes the
linux nommu + musl libc build on my JH7110 S7 core.

Bo

>> ---
>>
>>   arch/riscv/include/asm/pgtable.h | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
>> index 0c94260b5d0c..a564a39e5676 100644
>> --- a/arch/riscv/include/asm/pgtable.h
>> +++ b/arch/riscv/include/asm/pgtable.h
>> @@ -882,7 +882,7 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)
>>   #define PAGE_SHARED		__pgprot(0)
>>   #define PAGE_KERNEL		__pgprot(0)
>>   #define swapper_pg_dir		NULL
>> -#define TASK_SIZE		0xffffffffUL
>> +#define TASK_SIZE		_AC(-1, UL)
>>   #define VMALLOC_START		_AC(0, UL)
>>   #define VMALLOC_END		TASK_SIZE
>>   
>> -- 
>> 2.43.0
>>
>>
>> _______________________________________________
>> linux-riscv mailing list
>> linux-riscv@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-riscv
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
>
diff mbox series

Patch

diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index 0c94260b5d0c..a564a39e5676 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -882,7 +882,7 @@  static inline pte_t pte_swp_clear_exclusive(pte_t pte)
 #define PAGE_SHARED		__pgprot(0)
 #define PAGE_KERNEL		__pgprot(0)
 #define swapper_pg_dir		NULL
-#define TASK_SIZE		0xffffffffUL
+#define TASK_SIZE		_AC(-1, UL)
 #define VMALLOC_START		_AC(0, UL)
 #define VMALLOC_END		TASK_SIZE