diff mbox series

riscv: mm: Update the comment of CONFIG_PAGE_OFFSET

Message ID 20230809031023.3575407-1-songshuaishuai@tinylab.org (mailing list archive)
State Accepted
Commit d42469b616b1efe8bf57ddddefb7405a050deca0
Headers show
Series riscv: mm: Update the comment of CONFIG_PAGE_OFFSET | expand

Checks

Context Check Description
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be fixes at HEAD 7e3811521dc3
conchuod/fixes_present success Fixes tag present in non-next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 4 and now 4
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 2808 this patch: 2808
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 15871 this patch: 15871
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 12 this patch: 12
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success Fixes tag looks correct
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Song Shuai Aug. 9, 2023, 3:10 a.m. UTC
From: Song Shuai <suagrfillet@gmail.com>

Since the commit 011f09d12052 set sv57 as default for CONFIG_64BIT,
the comment of CONFIG_PAGE_OFFSET should be updated too.

Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
Signed-off-by: Song Shuai <suagrfillet@gmail.com>
---
 arch/riscv/include/asm/page.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Song Shuai Sept. 14, 2023, 2:08 a.m. UTC | #1
Song Shuai <songshuaishuai@tinylab.org> 于2023年8月9日周三 03:12写道:
>
> From: Song Shuai <suagrfillet@gmail.com>
>
> Since the commit 011f09d12052 set sv57 as default for CONFIG_64BIT,
> the comment of CONFIG_PAGE_OFFSET should be updated too.
>
> Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
> Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> ---
>  arch/riscv/include/asm/page.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
> index b55ba20903ec..53c00164c042 100644
> --- a/arch/riscv/include/asm/page.h
> +++ b/arch/riscv/include/asm/page.h
> @@ -33,8 +33,8 @@
>  #define PAGE_OFFSET            _AC(CONFIG_PAGE_OFFSET, UL)
>  #endif
>  /*
> - * By default, CONFIG_PAGE_OFFSET value corresponds to SV48 address space so
> - * define the PAGE_OFFSET value for SV39.
> + * By default, CONFIG_PAGE_OFFSET value corresponds to SV57 address space so
> + * define the PAGE_OFFSET value for SV48 and SV39.
>   */
>  #define PAGE_OFFSET_L4         _AC(0xffffaf8000000000, UL)
>  #define PAGE_OFFSET_L3         _AC(0xffffffd800000000, UL)
> --
> 2.20.1
>
Ping...
Guo Ren Sept. 14, 2023, 4:59 a.m. UTC | #2
On Wed, Aug 9, 2023 at 11:11 AM Song Shuai <songshuaishuai@tinylab.org> wrote:
>
> From: Song Shuai <suagrfillet@gmail.com>
>
> Since the commit 011f09d12052 set sv57 as default for CONFIG_64BIT,
> the comment of CONFIG_PAGE_OFFSET should be updated too.
>
> Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
> Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> ---
>  arch/riscv/include/asm/page.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
> index b55ba20903ec..53c00164c042 100644
> --- a/arch/riscv/include/asm/page.h
> +++ b/arch/riscv/include/asm/page.h
> @@ -33,8 +33,8 @@
>  #define PAGE_OFFSET            _AC(CONFIG_PAGE_OFFSET, UL)
Why not remove CONFIG_PAGE_OFFSET and define PAGE_OFFSET_L2 ?

>  #endif
>  /*
> - * By default, CONFIG_PAGE_OFFSET value corresponds to SV48 address space so
> - * define the PAGE_OFFSET value for SV39.
> + * By default, CONFIG_PAGE_OFFSET value corresponds to SV57 address space so
> + * define the PAGE_OFFSET value for SV48 and SV39.
>   */
>  #define PAGE_OFFSET_L4         _AC(0xffffaf8000000000, UL)
>  #define PAGE_OFFSET_L3         _AC(0xffffffd800000000, UL)
> --
> 2.20.1
>
Song Shuai Sept. 14, 2023, 6:51 a.m. UTC | #3
在 2023/9/14 12:59, Guo Ren 写道:
> On Wed, Aug 9, 2023 at 11:11 AM Song Shuai <songshuaishuai@tinylab.org> wrote:
>>
>> From: Song Shuai <suagrfillet@gmail.com>
>>
>> Since the commit 011f09d12052 set sv57 as default for CONFIG_64BIT,
>> the comment of CONFIG_PAGE_OFFSET should be updated too.
>>
>> Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
>> Signed-off-by: Song Shuai <suagrfillet@gmail.com>
>> ---
>>   arch/riscv/include/asm/page.h | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
>> index b55ba20903ec..53c00164c042 100644
>> --- a/arch/riscv/include/asm/page.h
>> +++ b/arch/riscv/include/asm/page.h
>> @@ -33,8 +33,8 @@
>>   #define PAGE_OFFSET            _AC(CONFIG_PAGE_OFFSET, UL)
> Why not remove CONFIG_PAGE_OFFSET and define PAGE_OFFSET_L2 ?
>
CONFIG_PAGE_OFFSET holds the first memory address regarding the 
different CONFIGs (MMU,32BIT,64BIT).

As for 64BIT, it actually represents "PAGE_OFFSET_L5" for Sv57 page mode 
defaultly. And the real page mode may be downgraded from kernel cmdline 
or restricted by the hardware, so the PAGE_OFFSET_L3/L4 was defined to 
set the real PAGE_OFFSET.

IIUC, the "PAGE_OFFSET_L2" you specified might be the "PAGE_OFFSET_L5" I 
previously mentioned,
If not, the PAGE_OFFSET_L2 semantically means the page offset for 
32BIT's default Sv32 page mode,and it has already been held in 
CONFIG_PAGE_OFFSET too.

So IMO there is no need to touch CONFIG_PAGE_OFFSET in this context.

Please correct me If I'm wrong.
>>   #endif
>>   /*
>> - * By default, CONFIG_PAGE_OFFSET value corresponds to SV48 address space so
>> - * define the PAGE_OFFSET value for SV39.
>> + * By default, CONFIG_PAGE_OFFSET value corresponds to SV57 address space so
>> + * define the PAGE_OFFSET value for SV48 and SV39.
>>    */
>>   #define PAGE_OFFSET_L4         _AC(0xffffaf8000000000, UL)
>>   #define PAGE_OFFSET_L3         _AC(0xffffffd800000000, UL)
>> --
>> 2.20.1
>>
> 
>
Guo Ren Oct. 29, 2023, 1:53 p.m. UTC | #4
On Thu, Sep 14, 2023 at 2:52 PM Song Shuai <songshuaishuai@tinylab.org> wrote:
>
>
>
> 在 2023/9/14 12:59, Guo Ren 写道:
> > On Wed, Aug 9, 2023 at 11:11 AM Song Shuai <songshuaishuai@tinylab.org> wrote:
> >>
> >> From: Song Shuai <suagrfillet@gmail.com>
> >>
> >> Since the commit 011f09d12052 set sv57 as default for CONFIG_64BIT,
> >> the comment of CONFIG_PAGE_OFFSET should be updated too.
> >>
> >> Fixes: 011f09d12052 ("riscv: mm: Set sv57 on defaultly")
> >> Signed-off-by: Song Shuai <suagrfillet@gmail.com>
> >> ---
> >>   arch/riscv/include/asm/page.h | 4 ++--
> >>   1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
> >> index b55ba20903ec..53c00164c042 100644
> >> --- a/arch/riscv/include/asm/page.h
> >> +++ b/arch/riscv/include/asm/page.h
> >> @@ -33,8 +33,8 @@
> >>   #define PAGE_OFFSET            _AC(CONFIG_PAGE_OFFSET, UL)
> > Why not remove CONFIG_PAGE_OFFSET and define PAGE_OFFSET_L2 ?
> >
> CONFIG_PAGE_OFFSET holds the first memory address regarding the
> different CONFIGs (MMU,32BIT,64BIT).
>
> As for 64BIT, it actually represents "PAGE_OFFSET_L5" for Sv57 page mode
> defaultly. And the real page mode may be downgraded from kernel cmdline
> or restricted by the hardware, so the PAGE_OFFSET_L3/L4 was defined to
> set the real PAGE_OFFSET.
>
> IIUC, the "PAGE_OFFSET_L2" you specified might be the "PAGE_OFFSET_L5" I
> previously mentioned,
> If not, the PAGE_OFFSET_L2 semantically means the page offset for
> 32BIT's default Sv32 page mode,and it has already been held in
> CONFIG_PAGE_OFFSET too.
>
> So IMO there is no need to touch CONFIG_PAGE_OFFSET in this context.

I mean:

#define PAGE_OFFSET_L5         _AC(0xff60000000000000, UL)
#define PAGE_OFFSET_L4         _AC(0xffffaf8000000000, UL)
#define PAGE_OFFSET_L3         _AC(0xffffffd800000000, UL)
#define PAGE_OFFSET_L2         _AC(0xC0000000)

#ifdef CONFIG_MMU
#ifdef CONFIG_64BIT
#define PAGE_OFFSET             kernel_map.page_offset
#else /* CONFIG_64BIT */
#define PAGE_OFFSET             PAGE_OFFSET_L2
#endif /* CONFIG_64BIT */
#else /* CONFIG_MMU */
#define PAGE_OFFSET             0x80000000
#endif /* CONFIG_MMU */

kernel_map.page_offset = _AC(PAGE_OFFSET_L5, UL);

The kernel_map.page_offset is no use to CONFIG_32BIT.

Remove the CONFIG_PAGE_OFFSET, and put all PAGE_OFFSET* together to
ease maintenance and reading.



>
> Please correct me If I'm wrong.
> >>   #endif
> >>   /*
> >> - * By default, CONFIG_PAGE_OFFSET value corresponds to SV48 address space so
> >> - * define the PAGE_OFFSET value for SV39.
> >> + * By default, CONFIG_PAGE_OFFSET value corresponds to SV57 address space so
> >> + * define the PAGE_OFFSET value for SV48 and SV39.
> >>    */
> >>   #define PAGE_OFFSET_L4         _AC(0xffffaf8000000000, UL)
> >>   #define PAGE_OFFSET_L3         _AC(0xffffffd800000000, UL)
> >> --
> >> 2.20.1
> >>
> >
> >
>
> --
> Thanks
> Song Shuai
>
diff mbox series

Patch

diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
index b55ba20903ec..53c00164c042 100644
--- a/arch/riscv/include/asm/page.h
+++ b/arch/riscv/include/asm/page.h
@@ -33,8 +33,8 @@ 
 #define PAGE_OFFSET		_AC(CONFIG_PAGE_OFFSET, UL)
 #endif
 /*
- * By default, CONFIG_PAGE_OFFSET value corresponds to SV48 address space so
- * define the PAGE_OFFSET value for SV39.
+ * By default, CONFIG_PAGE_OFFSET value corresponds to SV57 address space so
+ * define the PAGE_OFFSET value for SV48 and SV39.
  */
 #define PAGE_OFFSET_L4		_AC(0xffffaf8000000000, UL)
 #define PAGE_OFFSET_L3		_AC(0xffffffd800000000, UL)