diff mbox series

[2/6] riscv: Allow NOMMU kernels to access all of RAM

Message ID 20241026171441.3047904-3-samuel.holland@sifive.com (mailing list archive)
State New
Headers show
Series riscv: Relocatable NOMMU kernels | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-2-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh took 143.83s
conchuod/patch-2-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh took 2614.35s
conchuod/patch-2-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh took 3042.30s
conchuod/patch-2-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh took 21.25s
conchuod/patch-2-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh took 23.39s
conchuod/patch-2-test-6 success .github/scripts/patches/tests/checkpatch.sh took 0.63s
conchuod/patch-2-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh took 43.33s
conchuod/patch-2-test-8 success .github/scripts/patches/tests/header_inline.sh took 0.01s
conchuod/patch-2-test-9 success .github/scripts/patches/tests/kdoc.sh took 0.48s
conchuod/patch-2-test-10 success .github/scripts/patches/tests/module_param.sh took 0.01s
conchuod/patch-2-test-11 success .github/scripts/patches/tests/verify_fixes.sh took 0.00s
conchuod/patch-2-test-12 success .github/scripts/patches/tests/verify_signedoff.sh took 0.03s

Commit Message

Samuel Holland Oct. 26, 2024, 5:13 p.m. UTC
NOMMU kernels currently cannot access memory below the kernel link
address. Remove this restriction by setting PAGE_OFFSET to the actual
start of RAM, as determined from the devicetree. The kernel link address
must be a constant, so keep using CONFIG_PAGE_OFFSET for that purpose.

Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
---

 arch/riscv/include/asm/page.h    | 12 ++++--------
 arch/riscv/include/asm/pgtable.h |  2 +-
 2 files changed, 5 insertions(+), 9 deletions(-)

Comments

Jesse T Oct. 27, 2024, 8:09 p.m. UTC | #1
On Sat, Oct 26, 2024 at 1:16 PM Samuel Holland
<samuel.holland@sifive.com> wrote:
>
> NOMMU kernels currently cannot access memory below the kernel link
> address. Remove this restriction by setting PAGE_OFFSET to the actual
> start of RAM, as determined from the devicetree. The kernel link address
> must be a constant, so keep using CONFIG_PAGE_OFFSET for that purpose.
>
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Reviewed-by: Jesse Taube <mr.bossman075@gmail.com>

> ---
>
>  arch/riscv/include/asm/page.h    | 12 ++++--------
>  arch/riscv/include/asm/pgtable.h |  2 +-
>  2 files changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h
> index 32d308a3355f..24d1ac052609 100644
> --- a/arch/riscv/include/asm/page.h
> +++ b/arch/riscv/include/asm/page.h
> @@ -26,12 +26,9 @@
>   * When not using MMU this corresponds to the first free page in
>   * physical memory (aligned on a page boundary).
>   */
> -#ifdef CONFIG_64BIT
>  #ifdef CONFIG_MMU
> +#ifdef CONFIG_64BIT
>  #define PAGE_OFFSET            kernel_map.page_offset
> -#else
> -#define PAGE_OFFSET            _AC(CONFIG_PAGE_OFFSET, UL)
> -#endif
>  /*
>   * By default, CONFIG_PAGE_OFFSET value corresponds to SV57 address space so
>   * define the PAGE_OFFSET value for SV48 and SV39.
> @@ -41,6 +38,9 @@
>  #else
>  #define PAGE_OFFSET            _AC(CONFIG_PAGE_OFFSET, UL)
>  #endif /* CONFIG_64BIT */
> +#else
> +#define PAGE_OFFSET            ((unsigned long)phys_ram_base)
> +#endif /* CONFIG_MMU */
>
>  #ifndef __ASSEMBLY__
>
> @@ -97,11 +97,7 @@ typedef struct page *pgtable_t;
>  #define MIN_MEMBLOCK_ADDR      0
>  #endif
>
> -#ifdef CONFIG_MMU
>  #define ARCH_PFN_OFFSET                (PFN_DOWN((unsigned long)phys_ram_base))
> -#else
> -#define ARCH_PFN_OFFSET                (PAGE_OFFSET >> PAGE_SHIFT)
> -#endif /* CONFIG_MMU */
>
>  struct kernel_mapping {
>         unsigned long page_offset;
> diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
> index e79f15293492..e224ac66e635 100644
> --- a/arch/riscv/include/asm/pgtable.h
> +++ b/arch/riscv/include/asm/pgtable.h
> @@ -12,7 +12,7 @@
>  #include <asm/pgtable-bits.h>
>
>  #ifndef CONFIG_MMU
> -#define KERNEL_LINK_ADDR       PAGE_OFFSET
> +#define KERNEL_LINK_ADDR       _AC(CONFIG_PAGE_OFFSET, UL)
>  #define KERN_VIRT_SIZE         (UL(-1))
>  #else
>
> --
> 2.45.1
>
>
> _______________________________________________
> 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/page.h b/arch/riscv/include/asm/page.h
index 32d308a3355f..24d1ac052609 100644
--- a/arch/riscv/include/asm/page.h
+++ b/arch/riscv/include/asm/page.h
@@ -26,12 +26,9 @@ 
  * When not using MMU this corresponds to the first free page in
  * physical memory (aligned on a page boundary).
  */
-#ifdef CONFIG_64BIT
 #ifdef CONFIG_MMU
+#ifdef CONFIG_64BIT
 #define PAGE_OFFSET		kernel_map.page_offset
-#else
-#define PAGE_OFFSET		_AC(CONFIG_PAGE_OFFSET, UL)
-#endif
 /*
  * By default, CONFIG_PAGE_OFFSET value corresponds to SV57 address space so
  * define the PAGE_OFFSET value for SV48 and SV39.
@@ -41,6 +38,9 @@ 
 #else
 #define PAGE_OFFSET		_AC(CONFIG_PAGE_OFFSET, UL)
 #endif /* CONFIG_64BIT */
+#else
+#define PAGE_OFFSET		((unsigned long)phys_ram_base)
+#endif /* CONFIG_MMU */
 
 #ifndef __ASSEMBLY__
 
@@ -97,11 +97,7 @@  typedef struct page *pgtable_t;
 #define MIN_MEMBLOCK_ADDR      0
 #endif
 
-#ifdef CONFIG_MMU
 #define ARCH_PFN_OFFSET		(PFN_DOWN((unsigned long)phys_ram_base))
-#else
-#define ARCH_PFN_OFFSET		(PAGE_OFFSET >> PAGE_SHIFT)
-#endif /* CONFIG_MMU */
 
 struct kernel_mapping {
 	unsigned long page_offset;
diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h
index e79f15293492..e224ac66e635 100644
--- a/arch/riscv/include/asm/pgtable.h
+++ b/arch/riscv/include/asm/pgtable.h
@@ -12,7 +12,7 @@ 
 #include <asm/pgtable-bits.h>
 
 #ifndef CONFIG_MMU
-#define KERNEL_LINK_ADDR	PAGE_OFFSET
+#define KERNEL_LINK_ADDR	_AC(CONFIG_PAGE_OFFSET, UL)
 #define KERN_VIRT_SIZE		(UL(-1))
 #else