RISCV device tree mapping
cover RISCV device tree mapping
Current patch series introduces device tree mapping for RISC-V.
Also, it introduces common stuff for working with fdt which is
based on the patches from [1]:
[PATCH v4 2/6] xen/device-tree: Move Arm's setup.c bootinfo functions to common [PATCH v4 3/6] xen/common: Move Arm's bootfdt.c
All changes which were done on top of Shawn's patches please find in "Changes" section of each patch.
[1] https://lore.kernel.org/xen-devel/[email protected]/
Oleksii Kurochko (3):
xen/riscv: enable CONFIG_HAS_DEVICE_TREE xen/riscv: introduce device tree maping function xen/riscv: map FDT
Shawn Anastasio (2):
xen/device-tree: Move Arm's setup.c bootinfo functions to common xen/common: Move Arm's bootfdt.c to common
MAINTAINERS | 2 + xen/arch/arm/Makefile | 1 - xen/arch/arm/bootfdt.c | 622 --------------------------- xen/arch/arm/include/asm/setup.h | 200 +-------- xen/arch/arm/setup.c | 432 ------------------- xen/arch/riscv/Kconfig | 1 + xen/arch/riscv/include/asm/config.h | 6 + xen/arch/riscv/include/asm/mm.h | 2 + xen/arch/riscv/mm.c | 37 +- xen/arch/riscv/riscv64/head.S | 3 + xen/arch/riscv/setup.c | 21 + xen/common/Makefile | 1 + xen/common/device-tree/Makefile | 2 + xen/common/device-tree/bootfdt.c | 635 ++++++++++++++++++++++++++++ xen/common/device-tree/bootinfo.c | 459 ++++++++++++++++++++ xen/include/xen/bootfdt.h | 210 +++++++++ 16 files changed, 1375 insertions(+), 1259 deletions(-) delete mode 100644 xen/arch/arm/bootfdt.c create mode 100644 xen/common/device-tree/Makefile create mode 100644 xen/common/device-tree/bootfdt.c create mode 100644 xen/common/device-tree/bootinfo.c create mode 100644 xen/include/xen/bootfdt.h
Signature · 1 line
2.45.2
PATCH 1/5 xen/device-tree: Move Arm's setup.c bootinfo functions to common
From: Shawn Anastasio <[email protected]>
Arm's setup.c contains a collection of functions for parsing memory map and other boot information from a device tree. Since these routines are generally useful on any architecture that supports device tree booting, move them into xen/common/device-tree.
---
Changes in V5:
- add xen/include/xen/bootfdt.h to MAINTAINERS file.
- drop message "Early device tree parsing and".
- After rebase on top of the current staging the following changes were done:
- init bootinfo variable in <common/device-tree/bootinfo.c> with BOOTINFO_INIT;
- update the code of dt_unreserved_regions():
CONFIG_STATIC_SHM related changes and getting of reserved_mem bootinfo_get_shmem() ??
- update the code of meminfo_overlap_check():
add check ( INVALID_PADDR == bank_start ) to if case.
- update the code of check_reserved_regions_overlap():
CONFIG_STATIC_SHM related changes.
- struct bootinfo was updated ( CONFIG_STATIC_SHM changes )
- add shared_meminfo ( because of CONFIG_STATIC_SHM )
- struct struct membanks was update with __struct group so <xen/kernel> is neeeded to be included in bootfdt.h
- move BOOTINFO_ACPI_INIT, BOOTINFO_SHMEM_INIT, BOOTINFO_INIT to generic bootfdt.h
- bootinfo_get_reserved_mem(), bootinfo_get_mem(), bootinfo_get_acpi(), bootinfo_get_shmem() and bootinfo_get_shmem_extra() were moved to xen/bootfdt.h
- s/arm32/CONFIG_SEPARATE_XENHEAP/
- add inclusion of <xen/macros.h> because there are function in <xen/bootfdt.h> which are using container_of().
---
Changes in v4:
- create new xen/include/bootinfo.h rather than relying on arch's asm/setup.h to provide required definitions for bootinfo.c
- build bootinfo.c as .init.o
- clean up and sort bootinfo.c's #includes
- use CONFIG_SEPARATE_XENHEAP rather than CONFIG_ARM_32 to guard xenheap-specific behavior of populate_boot_allocator
- (MAINTAINERS) include all of common/device-tree rather than just bootinfo.c
--- MAINTAINERS | 2 + xen/arch/arm/include/asm/setup.h | 187 +----------- xen/arch/arm/setup.c | 432 ---------------------------- xen/common/Makefile | 1 + xen/common/device-tree/Makefile | 1 + xen/common/device-tree/bootinfo.c | 459 ++++++++++++++++++++++++++++++ xen/include/xen/bootfdt.h | 196 +++++++++++++ 7 files changed, 660 insertions(+), 618 deletions(-) create mode 100644 xen/common/device-tree/Makefile create mode 100644 xen/common/device-tree/bootinfo.c create mode 100644 xen/include/xen/bootfdt.h
MAINTAINERS +2 -0
@@ -295,9 +295,11 @@ M: Stefano Stabellini <[email protected]> M: Julien Grall <[email protected]> S: Supported F: xen/common/libfdt/ +F: xen/common/device-tree/ F: xen/common/device_tree.c F: xen/common/dt-overlay.c F: xen/include/xen/libfdt/ +F: xen/include/xen/bootfdt.h F: xen/include/xen/device_tree.h F: xen/drivers/passthrough/device_tree.c
xen/arch/arm/include/asm/setup.h +1 -186
215 lines not on this page · raw message
xen/arch/arm/setup.c +0 -432
456 lines not on this page · raw message
xen/common/Makefile +1 -0
@@ -77,6 +77,7 @@ obj-$(CONFIG_UBSAN) += ubsan/ obj-$(CONFIG_NEEDS_LIBELF) += libelf/ obj-$(CONFIG_HAS_DEVICE_TREE) += libfdt/ +obj-$(CONFIG_HAS_DEVICE_TREE) += device-tree/ CONF_FILE := $(if $(patsubst /%,,$(KCONFIG_CONFIG)),$(objtree)/)$(KCONFIG_CONFIG) $(obj)/config.gz: $(CONF_FILE)
xen/common/device-tree/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y += bootinfo.init.o
xen/common/device-tree/bootinfo.c new file +459 -0
459 lines not on this page · raw message
xen/include/xen/bootfdt.h new file +196 -0
196 lines not on this page · raw message
Signature · 1 line
2.45.2
Re: [PATCH v1 1/5] xen/device-tree: Move Arm's setup.c bootinfo functions to common
Quoted 21 lines · Oleksii Kurochko
From: Shawn Anastasio <[email protected]>
Arm's
setup.ccontains a collection of functions for parsing memory map and other boot information from a device tree. Since these routines are generally useful on any architecture that supports device tree booting, move them into xen/common/device-tree.Suggested-by Julien Grall <[email protected]>Signed-off-by Shawn Anastasio <[email protected]>Signed-off-by Oleksii Kurochko <[email protected]>---
Changes in V5:
- addxen/include/xen/bootfdt.htoMAINTAINERSfile.
- drop message "Early device tree parsing and".
- After rebase on top of the current staging the following changes were done:
- init bootinfo variable in <common/device-tree/bootinfo.c> withBOOTINFO_INIT;
- update the code ofdt_unreserved_regions():
CONFIG_STATIC_SHMrelated changes and getting ofreserved_membootinfo_get_shmem()??
- update the code ofmeminfo_overlap_check():add check ( INVALID_PADDR == bank_start ) to if case.
Quoted 12 lines
- update the code of
check_reserved_regions_overlap():
CONFIG_STATIC_SHMrelated changes.
- struct bootinfo was updated (CONFIG_STATIC_SHMchanges )
- addshared_meminfo( because ofCONFIG_STATIC_SHM)
- struct struct membanks was update with__structgroup so <xen/kernel> is neeeded to be included inbootfdt.h
- moveBOOTINFO_ACPI_INIT,BOOTINFO_SHMEM_INIT,BOOTINFO_INITto genericbootfdt.h
-bootinfo_get_reserved_mem(),bootinfo_get_mem(),bootinfo_get_acpi(),bootinfo_get_shmem()andbootinfo_get_shmem_extra()were moved toxen/bootfdt.h
- s/arm32/CONFIG_SEPARATE_XENHEAP/
- add inclusion of <xen/macros.h> because there are function in <xen/bootfdt.h> which are usingcontainer_of().
Just to mention it: This is confusing. The series is tagged "v1". I understand you took Shawn's work, which had already undergone revisions. But then imo you want to at least clarify how your v1 relates to his v4 or v5, i.e. then making clear to the reader whether all of the changes above were actually done by you on top of an earlier v4, or whether you took the earlier v5 verbatim.
But anyway, this will need looking at by Arm folks.
Jan
Re: [PATCH v1 1/5] xen/device-tree: Move Arm's setup.c bootinfo functions to common
Quoted 46 lines · Jan Beulich
Quoted 36 lines · Oleksii Kurochko
From: Shawn Anastasio <[email protected]>
Arm's
setup.ccontains a collection of functions for parsing memory map
and other boot information from a device tree. Since these routines are
generally useful on any architecture that supports device tree booting,
move them into xen/common/device-tree.Suggested-by Julien Grall <[email protected]>Signed-off-by Shawn Anastasio <[email protected]>Signed-off-by Oleksii Kurochko <[email protected]>---
Changes in V5:
- addxen/include/xen/bootfdt.htoMAINTAINERSfile.
- drop message "Early device tree parsing and".
- After rebase on top of the current staging the following changes were done:
- init bootinfo variable in <common/device-tree/bootinfo.c> withBOOTINFO_INIT;
- update the code ofdt_unreserved_regions():
CONFIG_STATIC_SHMrelated changes and getting ofreserved_mem
bootinfo_get_shmem()??
- update the code ofmeminfo_overlap_check():
add check (INVALID_PADDR==bank_start) to if case.
- update the code ofcheck_reserved_regions_overlap():
CONFIG_STATIC_SHMrelated changes.
- struct bootinfo was updated (CONFIG_STATIC_SHMchanges )
- addshared_meminfo( because ofCONFIG_STATIC_SHM)
- struct struct membanks was update with__structgroup so <xen/kernel> is
neeeded to be included inbootfdt.h
- moveBOOTINFO_ACPI_INIT,BOOTINFO_SHMEM_INIT,BOOTINFO_INITto genericbootfdt.hQuoted 8 lines
-
bootinfo_get_reserved_mem(),bootinfo_get_mem(),bootinfo_get_acpi(),
bootinfo_get_shmem()andbootinfo_get_shmem_extra()were moved toxen/bootfdt.h
- s/arm32/CONFIG_SEPARATE_XENHEAP/
- add inclusion of <xen/macros.h> because there are function in <xen/bootfdt.h> which
are usingcontainer_of().
Quoted 9 lines
Just to mention it: This is confusing. The series is tagged "v1". I understand
you took Shawn's work, which had already undergone revisions. But then imo you
want to at least clarify how your v1 relates to his v4 or v5, i.e. then making
clear to the reader whether all of the changes above were actually done by you
on top of an earlier v4, or whether you took the earlier v5 verbatim.
That is why I wrote "Changes in v5" to show that these changes were done on top of v4 version of Shawn's series, so what is mentioned in v5 here it is what was done by me.
I'll reword that and probably I shouldn't drop "Changes in v4,3,2,1" from Shawn's patch.
~ Oleksii
Re: [PATCH v1 1/5] xen/device-tree: Move Arm's setup.c bootinfo functions to common
Quoted 56 lines · Oleksii
Quoted 46 lines · Jan Beulich
Quoted 36 lines · Oleksii Kurochko
From: Shawn Anastasio <[email protected]>
Arm's
setup.ccontains a collection of functions for parsing memory map
and other boot information from a device tree. Since these routines are
generally useful on any architecture that supports device tree booting,
move them into xen/common/device-tree.Suggested-by Julien Grall <[email protected]>Signed-off-by Shawn Anastasio <[email protected]>Signed-off-by Oleksii Kurochko <[email protected]>---
Changes in V5:
- addxen/include/xen/bootfdt.htoMAINTAINERSfile.
- drop message "Early device tree parsing and".
- After rebase on top of the current staging the following changes were done:
- init bootinfo variable in <common/device-tree/bootinfo.c> withBOOTINFO_INIT;
- update the code ofdt_unreserved_regions():
CONFIG_STATIC_SHMrelated changes and getting ofreserved_mem
bootinfo_get_shmem()??
- update the code ofmeminfo_overlap_check():
add check (INVALID_PADDR==bank_start) to if case.
- update the code ofcheck_reserved_regions_overlap():
CONFIG_STATIC_SHMrelated changes.
- struct bootinfo was updated (CONFIG_STATIC_SHMchanges )
- addshared_meminfo( because ofCONFIG_STATIC_SHM)
- struct struct membanks was update with__structgroup so <xen/kernel> is
neeeded to be included inbootfdt.h
- moveBOOTINFO_ACPI_INIT,BOOTINFO_SHMEM_INIT,BOOTINFO_INITto genericbootfdt.hQuoted 8 lines
-
bootinfo_get_reserved_mem(),bootinfo_get_mem(),bootinfo_get_acpi(),
bootinfo_get_shmem()andbootinfo_get_shmem_extra()were moved toxen/bootfdt.h
- s/arm32/CONFIG_SEPARATE_XENHEAP/
- add inclusion of <xen/macros.h> because there are function in <xen/bootfdt.h> which
are usingcontainer_of().Quoted 9 lines
Just to mention it: This is confusing. The series is tagged "v1". I understand
you took Shawn's work, which had already undergone revisions. But then imo you
want to at least clarify how your v1 relates to his v4 or v5, i.e. then making
clear to the reader whether all of the changes above were actually done by you
on top of an earlier v4, or whether you took the earlier v5 verbatim.
Quoted 3 lines
That is why I wrote "Changes in v5" to show that these changes were done on top of v4 version of Shawn's series, so what is mentioned in v5 here it is what was done by me.
Except that what you sent is v1, not v5.
Quoted 2 lines
I'll reword that and probably I shouldn't drop "Changes in v4,3,2,1" from Shawn's patch.
I don't think you should drop anything. You want to clarify relationship of the version of your series with that of Shawn's earlier one. Or you'd want to continue numbering from what the previous series had, yet that may then also end up confusing if Shawn resumed work there.
Jan
Re: [PATCH v1 1/5] xen/device-tree: Move Arm's setup.c bootinfo functions to common
Quoted 80 lines · Jan Beulich
Quoted 68 lines · Oleksii
Quoted 54 lines · Jan Beulich
Quoted 44 lines · Oleksii Kurochko
From: Shawn Anastasio <[email protected]>
Arm's
setup.ccontains a collection of functions for parsing memory
map
and other boot information from a device tree. Since these routines
are
generally useful on any architecture that supports device tree booting,
move them into xen/common/device-tree.Suggested-by Julien Grall <[email protected]>Signed-off-by Shawn AnastasioSigned-off-by Oleksii Kurochko <[email protected]>---
Changes in V5:
- addxen/include/xen/bootfdt.htoMAINTAINERSfile.
- drop message "Early device tree parsing and".
- After rebase on top of the current staging the following changes
were done:
- init bootinfo variable in <common/device-tree/bootinfo.c> withBOOTINFO_INIT;
- update the code ofdt_unreserved_regions():
CONFIG_STATIC_SHMrelated changes and getting ofreserved_mem
bootinfo_get_shmem()??
- update the code ofmeminfo_overlap_check():
add check (INVALID_PADDR==bank_start) to if case.
- update the code ofcheck_reserved_regions_overlap():
CONFIG_STATIC_SHMrelated changes.
- struct bootinfo was updated (CONFIG_STATIC_SHMchanges )
- addshared_meminfo( because ofCONFIG_STATIC_SHM)
- struct struct membanks was update with__structgroup so <xen/kernel> is
neeeded to be included inbootfdt.h
- moveBOOTINFO_ACPI_INIT,BOOTINFO_SHMEM_INIT,BOOTINFO_INITto
genericbootfdt.h
-bootinfo_get_reserved_mem(),bootinfo_get_mem(),bootinfo_get_acpi(),Quoted 8 lines
bootinfo_get_shmem()andbootinfo_get_shmem_extra()were moved
toxen/bootfdt.h
- s/arm32/CONFIG_SEPARATE_XENHEAP/
- add inclusion of <xen/macros.h> because there are function in
<xen/bootfdt.h> which
are usingcontainer_of().Quoted 13 lines
Just to mention it: This is confusing. The series is tagged "v1". I
understand
you took Shawn's work, which had already undergone revisions. But then imo you
want to at least clarify how your v1 relates to his v4 or v5, i.e.
then making
clear to the reader whether all of the changes above were actually
done by you
on top of an earlier v4, or whether you took the earlier v5 verbatim.Quoted 4 lines
That is why I wrote "Changes in v5" to show that these changes were done on top of v4 version of Shawn's series, so what is mentioned in v5
here it is what was done by me.Except that what you sent is v1, not v5.
Quoted 3 lines
I'll reword that and probably I shouldn't drop "Changes in v4,3,2,1"
from Shawn's patch.
Quoted 7 lines
I don't think you should drop anything. You want to clarify relationship
of the version of your series with that of Shawn's earlier one. Or you'd
want to continue numbering from what the previous series had, yet that
may then also end up confusing if Shawn resumed work there.
Oh, I understood now what you meant. The Patch should be with the name:
[PATCH *v5* 1/5] xen/device-tree: Move Arm's setup.c bootinfo functions to common
I will update that. Thanks.
~ Oleksii
PATCH 2/5 xen/common: Move Arm's bootfdt.c to common
In reply to Oleksii KurochkoFrom: Shawn Anastasio <[email protected]>
Move Arm's bootfdt.c to xen/common so that it can be used by other device tree architectures like PPC and RISCV.
---
Changes in v5:
- add guard #ifdef CONFIG_STATIC_SHM around inclusion of <asm/static-shmem.h> in common/device-tree/bootfdt.c.
- add stub for process_shm_node() in case CONFIG_STATIC_SHM isn't enabled.
- add guard around #ifdef CONFIG_STATIC_SHM aroud early_print_info_shmem() in early_print_info().
---
Changes in v4:
- move function prototypes to patch 2's xen/include/bootfdt.h
- clean up #includes
--- xen/arch/arm/Makefile | 1 - xen/arch/arm/bootfdt.c | 622 ------------------------------ xen/arch/arm/include/asm/setup.h | 13 - xen/common/device-tree/Makefile | 1 + xen/common/device-tree/bootfdt.c | 635 +++++++++++++++++++++++++++++++ xen/include/xen/bootfdt.h | 14 + 6 files changed, 650 insertions(+), 636 deletions(-) delete mode 100644 xen/arch/arm/bootfdt.c create mode 100644 xen/common/device-tree/bootfdt.c
xen/arch/arm/Makefile +0 -1
@@ -10,7 +10,6 @@ obj-$(CONFIG_TEE) += tee/ obj-$(CONFIG_HAS_VPCI) += vpci.o obj-$(CONFIG_HAS_ALTERNATIVE) += alternative.o -obj-y += bootfdt.init.o obj-y += cpuerrata.o obj-y += cpufeature.o obj-y += decode.o
xen/arch/arm/bootfdt.c deleted +0 -622
622 lines not on this page · raw message
xen/arch/arm/include/asm/setup.h +0 -13
@@ -39,19 +39,6 @@ void fw_unreserved_regions(paddr_t s, paddr_t e,void (*cb)(paddr_t ps,paddr_t pe), unsigned int first); -bool check_reserved_regions_overlap (paddr_t region_start,paddr_t region_size); - -struct bootmodule *add_boot_module (bootmodule_kind kind, -paddr_t start,paddr_t size,bool domU); -struct bootmodule *boot_module_find_by_kind (bootmodule_kind kind); -struct bootmodule *boot_module_find_by_addr_and_kind (bootmodule_kind kind, -paddr_t start); -void add_boot_cmdline (const char *name,const char *cmdline, -bootmodule_kind kind,paddr_t start,bool domU); -struct bootcmdline *boot_cmdline_find_by_kind (bootmodule_kind kind); -struct bootcmdline *boot_cmdline_find_by_name (const char *name); -const char *boot_module_kind_as_string (bootmodule_kind kind); -void init_pdx (void );void setup_mm (void );
xen/common/device-tree/Makefile +1 -0
@@ -1 +1,2 @@ +obj-y += bootfdt.init.o obj-y += bootinfo.init.o
xen/common/device-tree/bootfdt.c new file +635 -0
635 lines not on this page · raw message
xen/include/xen/bootfdt.h +14 -0
@@ -158,6 +158,20 @@ struct bootinfo {extern struct bootinfo bootinfo; +bool check_reserved_regions_overlap (paddr_t region_start, +paddr_t region_size); + +struct bootmodule *add_boot_module (bootmodule_kind kind, +paddr_t start,paddr_t size,bool domU); +struct bootmodule *boot_module_find_by_kind (bootmodule_kind kind); +struct bootmodule *boot_module_find_by_addr_and_kind (bootmodule_kind kind, +paddr_t start); +void add_boot_cmdline (const char *name,const char *cmdline, +bootmodule_kind kind,paddr_t start,bool domU); +struct bootcmdline *boot_cmdline_find_by_kind (bootmodule_kind kind); +struct bootcmdline *boot_cmdline_find_by_name (const char *name); +const char *boot_module_kind_as_string (bootmodule_kind kind); +void populate_boot_allocator (void );size_t boot_fdt_info (const void *fdt,paddr_t paddr);
Signature · 1 line
2.45.2
PATCH 3/5 xen/riscv: enable CONFIG_HAS_DEVICE_TREE
In reply to Oleksii Kurochko--- xen/arch/riscv/Kconfig | 1 + 1 file changed, 1 insertion(+)
xen/arch/riscv/Kconfig +1 -0
@@ -5,6 +5,7 @@ config RISCV config RISCV_64 def_bool y select 64BIT + select HAS_DEVICE_TREE select GENERIC_BUG_FRAME config ARCH_DEFCONFIG
Signature · 1 line
2.45.2
Re: [PATCH v1 3/5] xen/riscv: enable CONFIG_HAS_DEVICE_TREE
xen/arch/riscv/Kconfig config RISCV · line 11
Quoted 10 lines · Oleksii Kurochko
xen/arch/riscv/Kconfig +1
-0@@ -5,6 +5,7 @@ config RISCV config RISCV_64 def_bool y select 64BIT + select HAS_DEVICE_TREE select GENERIC_BUG_FRAME config ARCH_DEFCONFIG
Same question here as for a change in the earlier series: Why here and not for RISCV?
Plus, nit: Please keep the list of selects sorted alphabetically.
Jan
PATCH 4/5 xen/riscv: introduce device tree maping function
In reply to Oleksii Kurochko--- xen/arch/riscv/include/asm/config.h | 6 +++++ xen/arch/riscv/include/asm/mm.h | 2 ++ xen/arch/riscv/mm.c | 37 +++++++++++++++++++++++++---- 3 files changed, 40 insertions(+), 5 deletions(-)
xen/arch/riscv/include/asm/config.h +6 -0
@@ -74,6 +74,9 @@#error "unsupported RV_STAGE1_MODE"#endif +#define XEN_SIZE MB(2) +#define XEN_VIRT_END (XEN_VIRT_START + XEN_SIZE) +#define DIRECTMAP_SLOT_END 509#define DIRECTMAP_SLOT_START 200#define DIRECTMAP_VIRT_START SLOTN(DIRECTMAP_SLOT_START)
@@ -99,6 +102,9 @@#define VMAP_VIRT_START SLOTN(VMAP_SLOT_START)#define VMAP_VIRT_SIZE GB(1) +#define BOOT_FDT_VIRT_START XEN_VIRT_END +#define BOOT_FDT_VIRT_SIZE MB(4) +#else #error "RV32 isn't supported"#endif
xen/arch/riscv/include/asm/mm.h +2 -0
@@ -255,4 +255,6 @@ static inline unsigned int arch_get_dma_bitsize(void) return 32; /* TODO */ } +void *early_fdt_map (paddr_t fdt_paddr); +#endif /* _ASM_RISCV_MM_H */
xen/arch/riscv/mm.c +32 -5
@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ +#include <xen/bootfdt.h> #include <xen/bug.h> #include <xen/compiler.h> #include <xen/init.h>
@@ -7,7 +8,9 @@#include <xen/macros.h> #include <xen/mm.h> #include <xen/pfn.h> +#include <xen/libfdt/libfdt.h> #include <xen/sections.h> +#include <xen/sizes.h> #include <asm/early_printk.h> #include <asm/csr.h>
@@ -20,7 +23,7 @@ struct mmu_desc {unsigned int pgtbl_count;pte_t *next_pgtbl;pte_t *pgtbl_base; -}; +} mmu_desc = { CONFIG_PAGING_LEVELS, 0, NULL, 0 };static unsigned long __ro_after_init phys_offset;
@@ -39,9 +42,11 @@ static unsigned long __ro_after_init phys_offset;* isn't 2 MB aligned. * * CONFIG_PAGING_LEVELS page tables are needed for the identity mapping, -* except that the root page table is shared with the initial mapping +* except that the root page table is shared with the initial mapping. +* +* CONFIG_PAGING_LEVELS page tables are needed for device tree mapping. */ -#define PGTBL_INITIAL_COUNT ((CONFIG_PAGING_LEVELS - 1) * 2 + 1) +#define PGTBL_INITIAL_COUNT ((CONFIG_PAGING_LEVELS - 1) * 3 + 1 + 1) pte_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) stage1_pgtbl_root[PAGETABLE_ENTRIES ];
@@ -207,8 +212,6 @@ static bool __init check_pgtbl_mode_support(struct mmu_desc *mmu_desc,*/ void __init setup_initial_pagetables (void ) { -struct mmu_desc mmu_desc = {CONFIG_PAGING_LEVELS ,0 ,NULL ,NULL }; -/* * Access to _start, _end is always PC-relative thereby when access * them we will get load adresses of start and end of Xen.
@@ -296,6 +299,30 @@ unsigned long __init calc_phys_offset(void)return phys_offset; } +void *__init early_fdt_map (paddr_t fdt_paddr) +{ +unsigned long dt_phys_base = fdt_paddr; +unsigned long dt_virt_base; +unsigned long dt_virt_size; + +BUILD_BUG_ON (MIN_FDT_ALIGN <8 ); +if ( !fdt_paddr || fdt_paddr %MIN_FDT_ALIGN || fdt_paddr %SZ_2M || +fdt_totalsize (fdt_paddr) >BOOT_FDT_VIRT_SIZE ) +return NULL ; + +BUILD_BUG_ON (BOOT_FDT_VIRT_START %SZ_2M ); + + dt_virt_base =BOOT_FDT_VIRT_START ; + dt_virt_size =BOOT_FDT_VIRT_SIZE ; + +/* Map device tree */ +setup_initial_mapping (&mmu_desc, dt_virt_base, + dt_virt_base + dt_virt_size, + dt_phys_base); + +return (void *)dt_virt_base; +} +void put_page (struct page_info *page) {BUG_ON ("unimplemented" );
Signature · 1 line
2.45.2
Re: [PATCH v1 4/5] xen/riscv: introduce device tree maping function
Quoted 6 lines · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>--- xen/arch/riscv/include/asm/config.h | 6 +++++ xen/arch/riscv/include/asm/mm.h | 2 ++ xen/arch/riscv/mm.c | 37 +++++++++++++++++++++++++---- 3 files changed, 40 insertions(+), 5 deletions(-)
I don't think a change like this can come without any description.
xen/arch/riscv/include/asm/config.h line 78
Quoted 8 lines
xen/arch/riscv/include/asm/config.h +2
-0@@ -74,6 +74,9 @@#error "unsupported RV_STAGE1_MODE"#endif +#define XEN_SIZE MB(2) +#define XEN_VIRT_END (XEN_VIRT_START + XEN_SIZE)
Probably wants accompanying by an assertion in the linker script. Or else how would one notice when Xen grows bigger than this?
xen/arch/riscv/include/asm/config.h line 106
Quoted 6 lines
xen/arch/riscv/include/asm/config.h +2
-0@@ -99,6 +102,9 @@#define VMAP_VIRT_START SLOTN(VMAP_SLOT_START)#define VMAP_VIRT_SIZE GB(1) +#define BOOT_FDT_VIRT_START XEN_VIRT_END +#define BOOT_FDT_VIRT_SIZE MB(4)
Is the 4 selected arbitrarily, or derived from something?
Also maybe better to keep these #define-s sorted by address? (As to "keep":
I didn't check whether they currently are.)
xen/arch/riscv/include/asm/mm.h static inline unsigned int arch_get_dma_bitsize(void) · line 258
Quoted 7 lines
xen/arch/riscv/include/asm/mm.h +1
-0@@ -255,4 +255,6 @@ static inline unsigned int arch_get_dma_bitsize(void)return 32 ;/* TODO */ } +void *early_fdt_map (paddr_t fdt_paddr);
Nit: * and blank want to change places.
Quoted 10 lines
xen/arch/riscv/mm.c +1
-0@@ -1,5 +1,6 @@/* SPDX-License-Identifier: GPL-2.0-only */ +#include <xen/bootfdt.h> #include <xen/bug.h> #include <xen/compiler.h> #include <xen/init.h>
xen/arch/riscv/mm.c line 11
Quoted 4 lines
xen/arch/riscv/mm.c +1
-0@@ -7,7 +8,9 @@#include <xen/macros.h> #include <xen/mm.h> #include <xen/pfn.h> +#include <xen/libfdt/libfdt.h>
This wants to move up, to retain sorting.
xen/arch/riscv/mm.c struct mmu_desc { · line 26
Quoted 11 lines
xen/arch/riscv/mm.c +2
-1#include <xen/sections.h> +#include <xen/sizes.h> #include <asm/early_printk.h> #include <asm/csr.h> @@ -20,7 +23,7 @@ struct mmu_desc {unsigned int pgtbl_count;pte_t *next_pgtbl;pte_t *pgtbl_base; -}; +} mmu_desc = { CONFIG_PAGING_LEVELS, 0, NULL, 0 };
__initdata and static?
xen/arch/riscv/mm.c static unsigned long __ro_after_init phys_offset; · line 49
Quoted 11 lines
xen/arch/riscv/mm.c +4
-2@@ -39,9 +42,11 @@ static unsigned long __ro_after_init phys_offset;* isn't 2 MB aligned. * * CONFIG_PAGING_LEVELS page tables are needed for the identity mapping, -* except that the root page table is shared with the initial mapping +* except that the root page table is shared with the initial mapping. +* +* CONFIG_PAGING_LEVELS page tables are needed for device tree mapping. */ -#define PGTBL_INITIAL_COUNT ((CONFIG_PAGING_LEVELS - 1) * 2 + 1) +#define PGTBL_INITIAL_COUNT ((CONFIG_PAGING_LEVELS - 1) * 3 + 1 + 1)
Considering what would happen if two or three more of such requirements were added, maybe better
#define PGTBL_INITIAL_COUNT (CONFIG_PAGING_LEVELS * 3 - 1)
? However, why is it CONFIG_PAGING_LEVELS that's needed, and not CONFIG_PAGING_LEVELS - 1? The top level table is the same as the identity map's, isn't it?
xen/arch/riscv/mm.c unsigned long __init calc_phys_offset(void) · line 302
Quoted 5 lines
xen/arch/riscv/mm.c +1
-0@@ -296,6 +299,30 @@ unsigned long __init calc_phys_offset(void)return phys_offset; } +void *__init early_fdt_map (paddr_t fdt_paddr)
See earlier remark regarding * placement.
Jan
Re: [PATCH v1 4/5] xen/riscv: introduce device tree maping function
Quoted 11 lines · Jan Beulich
Quoted 7 lines · Oleksii Kurochko
Signed-off-by Oleksii Kurochko <[email protected]>---
xen/arch/riscv/include/asm/config.h | 6 +++++
xen/arch/riscv/include/asm/mm.h | 2 ++
xen/arch/riscv/mm.c | 37
+++++++++++++++++++++++++----3 files changed, 40 insertions(+), 5 deletions(-)I don't think a change like this can come without any description.
Quoted 12 lines
xen/arch/riscv/include/asm/config.h line 78
Quoted 8 lines
xen/arch/riscv/include/asm/config.h +0
-0@@ -74,6 +74,9 @@ #error "unsupported RV_STAGE1_MODE" #endifxen/arch/riscv/include/asm/config.h +2
-0+#define XEN_SIZE MB(2) +#define XEN_VIRT_END (XEN_VIRT_START + XEN_SIZE)Probably wants accompanying by an assertion in the linker script. Or else
how would one notice when Xen grows bigger than this?
I use XEN_SIZE in the linker script here:
ASSERT(_end - _start <= MB(2), "Xen too large for early-boot
assumptions")
Quoted 9 lines
xen/arch/riscv/include/asm/config.h line 106
Quoted 7 lines
xen/arch/riscv/include/asm/config.h +0
-0@@ -99,6 +102,9 @@ #define VMAP_VIRT_START SLOTN(VMAP_SLOT_START) #define VMAP_VIRT_SIZE GB(1)xen/arch/riscv/include/asm/config.h +2
-0+#define BOOT_FDT_VIRT_START XEN_VIRT_END +#define BOOT_FDT_VIRT_SIZE MB(4)Is the 4 selected arbitrarily, or derived from something?
Yes, it was chosen arbitrarily. I just checked that I don't have any DTBs larger than 2 MB, but decided to add a little extra space and doubled it to an additional 2 MB.
Quoted 69 lines
Also maybe better to keep these #define-s sorted by address? (As to "keep":
I didn't check whether they currently are.)Quoted 8 lines
xen/arch/riscv/include/asm/mm.h +0
-0@@ -255,4 +255,6 @@ static inline unsigned intarch_get_dma_bitsize (void)return 32; /* TODO */
}
+void*early_fdt_map(paddr_t fdt_paddr);Nit: * and blank want to change places.
Quoted 10 lines
xen/arch/riscv/mm.c +0
-0@@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */
+#include <xen/bootfdt.h>
#include <xen/bug.h>
#include <xen/compiler.h>
#include <xen/init.h>xen/arch/riscv/mm.c line 11
Quoted 4 lines
xen/arch/riscv/mm.c +1
-0@@ -7,7 +8,9 @@ #include <xen/macros.h> #include <xen/mm.h> #include <xen/pfn.h> +#include <xen/libfdt/libfdt.h> This wants to move up, to retain sorting.
xen/arch/riscv/mm.c struct mmu_desc { · line 26
Quoted 11 lines
xen/arch/riscv/mm.c +1
-0#include <xen/sections.h> +#include <xen/sizes.h>
#include <asm/early_printk.h>
#include <asm/csr.h>xen/arch/riscv/mm.c +1
-1@@ -20,7 +23,7 @@ struct mmu_desc { unsigned int pgtbl_count; pte_t *next_pgtbl; pte_t *pgtbl_base; -}; +} mmu_desc = { CONFIG_PAGING_LEVELS, 0, NULL, 0 };
__initdataand static?Quoted 16 lines
xen/arch/riscv/mm.c +0
-1@@ -39,9 +42,11 @@ static unsigned long __ro_after_init phys_offset; * isn't 2 MB aligned. * * CONFIG_PAGING_LEVELS page tables are needed for the identity mapping, - * except that the root page table is shared with the initialmapping
+ * except that the root page table is shared with the initial mapping.
+ *
+ *CONFIG_PAGING_LEVELSpage tables are needed for device tree mapping.
*/xen/arch/riscv/mm.c +1
-1-#define PGTBL_INITIAL_COUNT ((CONFIG_PAGING_LEVELS - 1) * 2 + 1) +#define PGTBL_INITIAL_COUNT ((CONFIG_PAGING_LEVELS - 1) * 3 + 1 +Quoted 1 line
1)
Considering what would happen if two or three more of such requirements
were added, maybe better
Quoted 5 lines
#define
PGTBL_INITIAL_COUNT(CONFIG_PAGING_LEVELS* 3 - 1)? However, why is it
CONFIG_PAGING_LEVELSthat's needed, and notCONFIG_PAGING_LEVELS- 1? The top level table is the same as the identity map's, isn't it?
The top level table is the same, but I just wanted to be sure that if DTB size is bigger then 2Mb then we need 2xL0 page tables.
Am I missing something?
~ Oleksii
Quoted 10 lines
Quoted 6 lines
xen/arch/riscv/mm.c +0
-0@@ -296,6 +299,30 @@ unsigned long __init calc_phys_offset(void) return phys_offset; }
+void*__initearly_fdt_map(paddr_t fdt_paddr)See earlier remark regarding * placement.
Jan
Re: [PATCH v1 4/5] xen/riscv: introduce device tree maping function
Quoted 14 lines · Oleksii
Quoted 13 lines · Jan Beulich
xen/arch/riscv/include/asm/config.h line 78
Quoted 8 lines · Oleksii Kurochko
xen/arch/riscv/include/asm/config.h +0
-0@@ -74,6 +74,9 @@ #error "unsupported RV_STAGE1_MODE" #endifxen/arch/riscv/include/asm/config.h +2
-0+#define XEN_SIZE MB(2) +#define XEN_VIRT_END (XEN_VIRT_START + XEN_SIZE)Probably wants accompanying by an assertion in the linker script. Or else
how would one notice when Xen grows bigger than this?
Quoted 3 lines
I use
XEN_SIZEin the linker script here:
ASSERT(_end -_start<= MB(2), "Xen too large for early-boot
assumptions")
And that's the problem: You want to switch to using XEN_SIZE there. There should never be two separate constant that need updating at the same time. Keep such to a single place.
Quoted 11 lines
Quoted 8 lines
xen/arch/riscv/include/asm/config.h line 106
Quoted 6 lines
xen/arch/riscv/include/asm/config.h +0
-0@@ -99,6 +102,9 @@ #define VMAP_VIRT_START SLOTN(VMAP_SLOT_START) #define VMAP_VIRT_SIZE GB(1)xen/arch/riscv/include/asm/config.h +2
-0+#define BOOT_FDT_VIRT_START XEN_VIRT_END +#define BOOT_FDT_VIRT_SIZE MB(4)Is the 4 selected arbitrarily, or derived from something?
Yes, it was chosen arbitrarily. I just checked that I don't have any DTBs larger than 2 MB, but decided to add a little extra space and doubled it to an additional 2 MB.
Code comment then, please, or at the very least mention of this in the description.
Quoted 22 lines
Quoted 22 lines
Quoted 16 lines
xen/arch/riscv/include/asm/config.h +0
-1@@ -39,9 +42,11 @@ static unsigned long __ro_after_init phys_offset; * isn't 2 MB aligned. * * CONFIG_PAGING_LEVELS page tables are needed for the identity mapping, - * except that the root page table is shared with the initialmapping
+ * except that the root page table is shared with the initial mapping.
+ *
+ *CONFIG_PAGING_LEVELSpage tables are needed for device tree mapping.
*/xen/arch/riscv/include/asm/config.h +1
-1-#define PGTBL_INITIAL_COUNT ((CONFIG_PAGING_LEVELS - 1) * 2 + 1) +#define PGTBL_INITIAL_COUNT ((CONFIG_PAGING_LEVELS - 1) * 3 + 1 +Quoted 1 line
1)
Considering what would happen if two or three more of such requirements
were added, maybe better
Quoted 7 lines
Quoted 5 lines
#define
PGTBL_INITIAL_COUNT(CONFIG_PAGING_LEVELS* 3 - 1)? However, why is it
CONFIG_PAGING_LEVELSthat's needed, and notCONFIG_PAGING_LEVELS- 1? The top level table is the same as the identity map's, isn't it?The top level table is the same, but I just wanted to be sure that if DTB size is bigger then 2Mb then we need 2xL0 page tables.
Makes sense, but then needs expressing that way (by using BOOT_FDT_VIRT_SIZE). Otherwise (see also above) think of what will happen if BOOT_FDT_VIRT_SIZE is updated without touching this expression.
Jan
PATCH 5/5 xen/riscv: map FDT
In reply to Oleksii KurochkoExcept mapping of FDT, it is also printing command line passed by a DTB and initialize bootinfo from a DTB.
--- xen/arch/riscv/riscv64/head.S | 3 +++ xen/arch/riscv/setup.c | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+)
xen/arch/riscv/riscv64/head.S +3 -0
@@ -41,6 +41,9 @@ FUNC(start) jal setup_initial_pagetables + mv a0, s1 + jal fdt_map + /* Calculate proper VA after jump from 1:1 mapping */ la a0, .L_primary_switched sub a0, a0, s2
xen/arch/riscv/setup.c +21 -0
@@ -1,7 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ +#include <xen/bootfdt.h> #include <xen/bug.h> #include <xen/compile.h> +#include <xen/device_tree.h> #include <xen/init.h> #include <xen/mm.h>
@@ -33,15 +35,34 @@ static void test_macros_from_bug_h(void)printk ("WARN is most likely working\n" ); } +void __init fdt_map (paddr_t dtb_addr) +{ + device_tree_flattened =early_fdt_map (dtb_addr); +if ( !device_tree_flattened ) + { +printk ("wrong FDT\n" ); +die (); + } +} +void __init noreturnstart_xen (unsigned long bootcpu_id,paddr_t dtb_addr) { +size_t fdt_size; +const char *cmdline; +remove_identity_mapping ();trap_init ();test_macros_from_bug_h (); + fdt_size =boot_fdt_info (device_tree_flattened, dtb_addr); + + cmdline =boot_fdt_cmdline (device_tree_flattened); +printk ("Command line: %s\n" , cmdline); +cmdline_parse (cmdline); +printk ("All set up\n" );for ( ;; )
Signature · 1 line
2.45.2
Re: [PATCH v1 5/5] xen/riscv: map FDT
Quoted 2 lines · Oleksii Kurochko
Except mapping of FDT, it is also printing command line passed by a DTB and initialize bootinfo from a DTB.
I'm glad the description isn't empty here. However, ...
xen/arch/riscv/riscv64/head.S FUNC(start) · line 49
Quoted 12 lines
xen/arch/riscv/riscv64/head.S +3
-0@@ -41,6 +41,9 @@ FUNC(start) jal setup_initial_pagetables + mv a0, s1 + jal fdt_map + /* Calculate proper VA after jump from 1:1 mapping */ la a0, .L_primary_switched sub a0, a0, s2
... it could do with clarifying why this needs calling from assembly code. Mapping the FDT clearly looks like something that wants doing from start_xen(), i.e. from C code.
Quoted 17 lines
xen/arch/riscv/riscv64/head.S +10
-0@@ -33,15 +35,34 @@ static void test_macros_from_bug_h(void) printk("WARN is most likely working\n"); } +void __init fdt_map(paddr_t dtb_addr) +{ + device_tree_flattened = early_fdt_map(dtb_addr); + if ( !device_tree_flattened ) + { + printk("wrong FDT\n"); + die(); + } +} + void __init noreturn start_xen(unsigned long bootcpu_id, paddr_t dtb_addr) {
xen/arch/riscv/riscv64/head.S static void test_macros_from_bug_h(void) · line 60
Quoted 10 lines
xen/arch/riscv/riscv64/head.S +4
-0+ size_t fdt_size; + const char *cmdline; + remove_identity_mapping(); trap_init(); test_macros_from_bug_h(); + fdt_size = boot_fdt_info(device_tree_flattened, dtb_addr);
You don't use the return value anywhere below. What use is the local var then?
Jan
Quoted 7 lines
xen/arch/riscv/riscv64/head.S +4
-0+ cmdline = boot_fdt_cmdline(device_tree_flattened); + printk("Command line: %s\n", cmdline); + cmdline_parse(cmdline); + printk("All set up\n"); for ( ;; )
Re: [PATCH v1 5/5] xen/riscv: map FDT
Quoted 6 lines · Jan Beulich
Quoted 2 lines · Oleksii Kurochko
Except mapping of FDT, it is also printing command line passed by a DTB and initialize bootinfo from a DTB.
I'm glad the description isn't empty here. However, ...
Quoted 16 lines
Quoted 4 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -41,6 +41,9 @@ FUNC(start)Quoted 8 lines
jal
setup_initial_pagetables
+ mv a0, s1
+ jalfdt_map
+
/* Calculate proper VA after jump from 1:1 mapping */ la a0, .L_primary_switched
sub a0, a0, s2... it could do with clarifying why this needs calling from assembly code. Mapping the FDT clearly looks like something that wants doing from
start_xen(), i.e. from C code.
fdt_map() expected to work while MMU is off as it is using setup_initial_mapping() which is working with physical address.
Quoted 24 lines
Quoted 24 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -33,15 +35,34 @@ static void test_macros_from_bug_h(void) printk("WARN is most likely working\n"); }xen/arch/riscv/riscv64/head.S +10
-0+void __init fdt_map(paddr_t dtb_addr) +{ + device_tree_flattened = early_fdt_map(dtb_addr); + if ( !device_tree_flattened ) + { + printk("wrong FDT\n"); + die(); + } +} +void
__initnoreturnstart_xen(unsigned long bootcpu_id, paddr_t dtb_addr){
+size_tfdt_size;
+ const char *cmdline;
+
remove_identity_mapping();
trap_init();
Quoted 8 lines
Quoted 4 lines
test_macros_from_bug_h();
+fdt_size=boot_fdt_info(device_tree_flattened, dtb_addr);You don't use the return value anywhere below. What use is the local var
then?
I returned just for debug ( to see what is the fdt size ), it can be dropped now.
~ Oleksii
Quoted 11 lines
Jan
Quoted 7 lines
+ cmdline =
boot_fdt_cmdline(device_tree_flattened); +printk("Command line: %s\n", cmdline);
+cmdline_parse(cmdline);
+
printk("All set up\n");
for ( ;; )
Re: [PATCH v1 5/5] xen/riscv: map FDT
Quoted 23 lines · Oleksii
Quoted 6 lines · Jan Beulich
Quoted 2 lines · Oleksii Kurochko
Except mapping of FDT, it is also printing command line passed by a DTB and initialize bootinfo from a DTB.
I'm glad the description isn't empty here. However, ...
Quoted 16 lines
Quoted 4 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -41,6 +41,9 @@ FUNC(start)Quoted 8 lines
jal
setup_initial_pagetables
+ mv a0, s1
+ jalfdt_map
+
/* Calculate proper VA after jump from 1:1 mapping */ la a0, .L_primary_switched
sub a0, a0, s2... it could do with clarifying why this needs calling from assembly code. Mapping the FDT clearly looks like something that wants doing from
start_xen(), i.e. from C code.
Quoted 2 lines
fdt_map()expected to work while MMU is off as it is usingsetup_initial_mapping()which is working with physical address.
Hmm, interesting. When the MMU is off, what does "map" mean? Yet then it feels I'm misunderstanding what you're meaning to tell me ...
Jan
Re: [PATCH v1 5/5] xen/riscv: map FDT
Quoted 27 lines · Jan Beulich
Quoted 26 lines · Oleksii
Quoted 25 lines · Jan Beulich
Quoted 3 lines · Oleksii Kurochko
Except mapping of FDT, it is also printing command line passed by
a DTB and initialize bootinfo from a DTB.I'm glad the description isn't empty here. However, ...
Quoted 4 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -41,6 +41,9 @@ FUNC(start)Quoted 8 lines
jal
setup_initial_pagetables
+ mv a0, s1
+ jalfdt_map
+
/* Calculate proper VA after jump from 1:1 mapping */ la a0, .L_primary_switched
sub a0, a0, s2... it could do with clarifying why this needs calling from assembly
code. Mapping the FDT clearly looks like something that wants doing
fromstart_xen(), i.e. from C code.
Quoted 5 lines
Quoted 2 lines
fdt_map()expected to work while MMU is off as it is usingsetup_initial_mapping()which is working with physical address.Hmm, interesting. When the MMU is off, what does "map" mean? Yet then it feels I'm misunderstanding what you're meaning to tell me ...
Let's look at examples of the code:
1. The first thing issue will be here:
void* __init early_fdt_map(paddr_t fdt_paddr)
{
unsigned long dt_phys_base = fdt_paddr;
unsigned long dt_virt_base;
unsigned long dt_virt_size;
BUILD_BUG_ON(MIN_FDT_ALIGN < 8);
if ( !fdt_paddr || fdt_paddr % MIN_FDT_ALIGN || fdt_paddr % SZ_2M ||
fdt_totalsize(fdt_paddr) > BOOT_FDT_VIRT_SIZE )
MMU doesn't now about virtual address of fdt_paddr as fdt_paddr wasn't mapped.
2. In setup_initial_mapping() we have HANDLE_PGTBL() where pgtbl is a pointer to physical address ( which also should be mapped in MMU if we want to access it after MMU is enabled ):
#define HANDLE_PGTBL(curr_lvl_num)
\
index = pt_index(curr_lvl_num, page_addr);
\
if ( pte_is_valid(pgtbl[index]) )
\
{
\
/* Find L{ 0-3 } table */
\
pgtbl = (pte_t *)pte_to_paddr(pgtbl[index]);
\
}
\
else
\
{
\
/* Allocate new L{0-3} page table */
\
if ( mmu_desc->pgtbl_count == PGTBL_INITIAL_COUNT )
\
{
\
early_printk("(XEN) No initial table available\n");
\
/* panic(), BUG() or ASSERT() aren't ready now. */
\
die();
\
}
\
mmu_desc->pgtbl_count++; \
pgtbl[index] = paddr_to_pte((unsigned long)mmu_desc-
Quoted 1 line
next_pgtbl, \
PTE_VALID);
\
pgtbl = mmu_desc->next_pgtbl;
\
mmu_desc->next_pgtbl += PAGETABLE_ENTRIES;
\
}So we can't use setup_initial_mapping() when MMU is enabled as there is a part of the code which uses physical address which are not mapped.
We have only mapping for for liner_start <-> load_start and the small piece of code in text section ( _ident_start ):
setup_initial_mapping(&mmu_desc,
linker_start,
linker_end,
load_start);
if ( linker_start == load_start )
return;
ident_start = (unsigned long)turn_on_mmu &XEN_PT_LEVEL_MAP_MASK(0);
ident_end = ident_start + PAGE_SIZE;
setup_initial_mapping(&mmu_desc,
ident_start,
ident_end,
ident_start);We can use setup_initial_mapping() when MMU is enabled only in case when linker_start is equal to load_start.
As an option we can consider for as a candidate for identaty mapping also section .bss.page_aligned where root and nonroot page tables are located.
Does it make sense now?
~ Oleksii
Re: [PATCH v1 5/5] xen/riscv: map FDT
Quoted 116 lines · Oleksii
Quoted 27 lines · Jan Beulich
Quoted 26 lines · Oleksii
Quoted 25 lines · Jan Beulich
Quoted 3 lines · Oleksii Kurochko
Except mapping of FDT, it is also printing command line passed by
a DTB and initialize bootinfo from a DTB.I'm glad the description isn't empty here. However, ...
Quoted 4 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -41,6 +41,9 @@ FUNC(start)Quoted 8 lines
jal
setup_initial_pagetables
+ mv a0, s1
+ jalfdt_map
+
/* Calculate proper VA after jump from 1:1 mapping */ la a0, .L_primary_switched
sub a0, a0, s2... it could do with clarifying why this needs calling from assembly
code. Mapping the FDT clearly looks like something that wants doing
fromstart_xen(), i.e. from C code.Quoted 5 lines
Quoted 2 lines
fdt_map()expected to work while MMU is off as it is usingsetup_initial_mapping()which is working with physical address.Hmm, interesting. When the MMU is off, what does "map" mean? Yet then it feels I'm misunderstanding what you're meaning to tell me ...
Let's look at examples of the code:
1. The first thing issue will be here:void* __init early_fdt_map(paddr_t fdt_paddr) { unsigned long dt_phys_base = fdt_paddr; unsigned long dt_virt_base; unsigned long dt_virt_size; BUILD_BUG_ON(MIN_FDT_ALIGN < 8); if ( !fdt_paddr || fdt_paddr % MIN_FDT_ALIGN || fdt_paddr % SZ_2M || fdt_totalsize(fdt_paddr) > BOOT_FDT_VIRT_SIZE )MMU doesn't now about virtual address of
fdt_paddrasfdt_paddrwasn't mapped.2. In
setup_initial_mapping()we haveHANDLE_PGTBL()where pgtbl is a pointer to physical address ( which also should be mapped in MMU if we want to access it after MMU is enabled ):#define HANDLE_PGTBL(curr_lvl_num) \ index = pt_index(curr_lvl_num, page_addr); \ if ( pte_is_valid(pgtbl[index]) ) \ { \ /* Find L{ 0-3 } table */ \ pgtbl = (pte_t *)pte_to_paddr(pgtbl[index]); \ } \ else \ { \ /* Allocate new L{0-3} page table */ \ if ( mmu_desc->pgtbl_count == PGTBL_INITIAL_COUNT ) \ { \ early_printk("(XEN) No initial table available\n"); \ /* panic(), BUG() or ASSERT() aren't ready now. */ \ die(); \ } \ mmu_desc->pgtbl_count++; \ pgtbl[index] = paddr_to_pte((unsigned long)mmu_desc- >next_pgtbl, \ PTE_VALID); \ pgtbl = mmu_desc->next_pgtbl; \ mmu_desc->next_pgtbl += PAGETABLE_ENTRIES; \ }So we can't use
setup_initial_mapping()when MMU is enabled as there is a part of the code which uses physical address which are not mapped.We have only mapping for for
liner_start<->load_startand the small piece of code in text section (_ident_start):setup_initial_mapping(&mmu_desc, linker_start, linker_end, load_start); if ( linker_start == load_start ) return; ident_start = (unsigned long)turn_on_mmu &XEN_PT_LEVEL_MAP_MASK(0); ident_end = ident_start + PAGE_SIZE; setup_initial_mapping(&mmu_desc, ident_start, ident_end, ident_start);
Quoted 8 lines
We can use
setup_initial_mapping()when MMU is enabled only in case whenlinker_startis equal toload_start.As an option we can consider for as a candidate for identaty mapping also section .bss.page_aligned where root and nonroot page tables are located.
Does it make sense now?
I think so, yet at the same time it only changes the question: Why is it that you absolutely need to use setup_initial_mapping()? Surely down the road there are going to be more thing that need mapping relatively early, but after the MMU was enabled.
Jan
Re: [PATCH v1 5/5] xen/riscv: map FDT
Add Julien as he asked basically the same question in another thread.
Quoted 157 lines · Jan Beulich
Quoted 156 lines · Oleksii
Quoted 29 lines · Jan Beulich
Quoted 28 lines · Oleksii
Quoted 27 lines · Jan Beulich
Quoted 4 lines · Oleksii Kurochko
Except mapping of FDT, it is also printing command line passed
by
a DTB and initialize bootinfo from a DTB.I'm glad the description isn't empty here. However, ...
Quoted 5 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -41,6 +41,9 @@ FUNC(start)
jalsetup_initial_pagetablesQuoted 8 lines
+ mv a0, s1
+ jalfdt_map
+
/* Calculate proper VA after jump from 1:1 mapping */
la a0, .L_primary_switched
sub a0, a0, s2... it could do with clarifying why this needs calling from assembly
code. Mapping the FDT clearly looks like something that wants doing
fromstart_xen(), i.e. from C code.Quoted 6 lines
Quoted 2 lines
fdt_map()expected to work while MMU is off as it is usingsetup_initial_mapping()which is working with physical address.Hmm, interesting. When the MMU is off, what does "map" mean? Yet then
it feels I'm misunderstanding what you're meaning to tell me ...Let's look at examples of the code:
1. The first thing issue will be here:
void*__initearly_fdt_map(paddr_t fdt_paddr)
{
unsigned longdt_phys_base=fdt_paddr;
unsigned longdt_virt_base;
unsigned longdt_virt_size;
BUILD_BUG_ON(MIN_FDT_ALIGN < 8);
if ( !fdt_paddr ||fdt_paddr%MIN_FDT_ALIGN||fdt_paddr%SZ_2M
||
fdt_totalsize(fdt_paddr)>BOOT_FDT_VIRT_SIZE) MMU doesn't now about virtual address offdt_paddrasfdt_paddrwasn't
mapped.2. In
setup_initial_mapping()we haveHANDLE_PGTBL()where pgtbl is a
pointer to physical address ( which also should be mapped in MMU if we
want to access it after MMU is enabled ):
#defineHANDLE_PGTBL(curr_lvl_num)
\
index = pt_index(curr_lvl_num,page_addr);
\
if (pte_is_valid(pgtbl[index])
)
\
{
\
/* Find L{ 0-3 } table
*/
\
pgtbl = (pte_t
*)pte_to_paddr(pgtbl[index]);
\
}
\
else
\
{
\
/* Allocate new L{0-3} page table
*/
\
if (mmu_desc->pgtbl_count==PGTBL_INITIAL_COUNT)
\
{
\
early_printk("(XEN) No initial table available\n");
\
/*panic(),BUG()orASSERT()aren't ready now. */
\die();
\
}
\
mmu_desc-Quoted 1 line
pgtbl_count++;
\
pgtbl[index] = paddr_to_pte((unsigned long)mmu_desc- >next_pgtbl, \PTE_VALID);
\
pgtbl = mmu_desc-Quoted 1 line
next_pgtbl;\
mmu_desc->next_pgtbl+=PAGETABLE_ENTRIES;
\
}
So we can't usesetup_initial_mapping()when MMU is enabled as there is
a part of the code which uses physical address which are not mapped.We have only mapping for for
liner_start<->load_startand the small
piece of code in text section (_ident_start):
setup_initial_mapping(&mmu_desc,
linker_start,
linker_end,
load_start);if (
linker_start==load_start)
return;
ident_start= (unsigned long)turn_on_mmu&XEN_PT_LEVEL_MAP_MASK(0);
ident_end=ident_start+PAGE_SIZE;setup_initial_mapping(&mmu_desc,
ident_start,
ident_end,
ident_start);We can use
setup_initial_mapping()when MMU is enabled only in case whenlinker_startis equal toload_start.As an option we can consider for as a candidate for identaty mapping
also section .bss.page_aligned where root and nonroot page tables are
located.
Quoted 5 lines
Quoted 1 line
Does it make sense now?
I think so, yet at the same time it only changes the question: Why is it
that you absolutely need to usesetup_initial_mapping()?
There is no strict requirement to use setup_initial_mapping(). That function is available to me at the moment, and I haven't found a better option other than reusing what I currently have.
If not to use setup_initial_mapping() then it is needed to introduce xen_{un}map_table(), create_xen_table(), xen_pt_next_level(), xen_pt_update{_entry}(), map_pages_to_xen(). What I did a little bit later here:
https://gitlab.com/xen-project/people/olkur/xen/-/commit/a4619d0902e0a012ac2f709d31621a8d499bca97
Am I confusing something?
Could you please recommend me how to better?
Quoted 4 lines
Surely down the
road there are going to be more thing that need mapping relatively early,
but after the MMU was enabled.
For sure, but for mapping other things it would be introduced setup_mm() and necessary functions to implementinitialization and handling of mm.
~ Oleksii
Re: [PATCH v1 5/5] xen/riscv: map FDT
Hi,
Quoted 1 line · Oleksii
Add Julien as he asked basically the same question in another thread.
Thanks!
Quoted 7 lines · Jan Beulich
Quoted 5 lines · Oleksii
Quoted 4 lines · Jan Beulich
Quoted 3 lines · Oleksii
Quoted 2 lines · Jan Beulich
Quoted 1 line · Oleksii Kurochko
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Does it make sense now?
I think so, yet at the same time it only changes the question: Why is it
that you absolutely need to usesetup_initial_mapping()?There is no strict requirement to use
setup_initial_mapping(). That function is available to me at the moment, and I haven't found a better option other than reusing what I currently have.
I am not very familiar with the code base for RISC-V, but looking at the context in the patch, it seems you will still have the identity mapping mapped until start_xen().
I assume we don't exactly know where the loader will put Xen in memory. Which means that the region may clash with your defined runtime regions (such as the FDT). Did I misunderstand anything?
That's one of the reason on Arm we are trying to enable the MMU very early. The only thing we setup is a mapping for Xen (and earlyprintk) all the rest will be mapped once the MMU is on.
With that, the only thing you need to take care off the runtime Xen address overlapping with the identity mapping.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 5/5] xen/riscv: map FDT
Quoted 26 lines · Julien Grall
Hi,
Quoted 2 lines · Oleksii
Add Julien as he asked basically the same question in another thread.
Thanks!
Quoted 9 lines · Jan Beulich
Quoted 7 lines · Oleksii
Quoted 5 lines · Jan Beulich
Quoted 3 lines · Oleksii
Quoted 2 lines · Jan Beulich
Quoted 1 line · Oleksii Kurochko
Does it make sense now?
Quoted 8 lines
Quoted 4 lines
I think so, yet at the same time it only changes the question:
Why is
it
that you absolutely need to usesetup_initial_mapping()?There is no strict requirement to use
setup_initial_mapping(). That function is available to me at the moment, and I haven't found a better
option other than reusing what I currently have.
Quoted 5 lines
I am not very familiar with the code base for RISC-V, but looking at the
context in the patch, it seems you will still have the identity mapping
mapped untilstart_xen().
We have identity mapping only for a small piece of .text section:
. = ALIGN(IDENT_AREA_SIZE);
_ident_start = .;
*(.text.ident)
_ident_end = .;All other will be identically mapped only in case of linker address is equal to load address.
Quoted 6 lines
I assume we don't exactly know where the loader will put Xen in memory.
Which means that the region may clash with your defined runtime regions
(such as the FDT). Did I misunderstand anything?
I am not really get what is the issue here.
If we are speaking about physical regions then loader will guarantee that Xen and FDT regions don't overlap.
If we are speaking about virtual regions then Xen will check that nothing is overlaped. And the virtual regions are mapped so high so I am not sure that loader will put something there. ( FDT in Xen is mapped to 0xffffffffc0200000 ).
Could you please clarify what I am missing?
Quoted 4 lines
That's one of the reason on Arm we are trying to enable the MMU very early. The only thing we setup is a mapping for Xen (and earlyprintk) all the rest will be mapped once the MMU is on.
It makes sense. Then I have to introduce map_pages_to_xen() first and then early_fdt_map().
~ Oleksii
Quoted 3 lines
With that, the only thing you need to take care off the runtime Xen address overlapping with the identity mapping.
Re: [PATCH v1 5/5] xen/riscv: map FDT
Hi Oleksii,
Quoted 47 lines · Oleksii
Quoted 26 lines · Julien Grall
Hi,
Quoted 2 lines · Oleksii
Add Julien as he asked basically the same question in another thread.
Thanks!
Quoted 9 lines · Jan Beulich
Quoted 7 lines · Oleksii
Quoted 5 lines · Jan Beulich
Quoted 3 lines · Oleksii
Quoted 2 lines · Jan Beulich
Quoted 1 line · Oleksii Kurochko
Does it make sense now?
Quoted 8 lines
Quoted 4 lines
I think so, yet at the same time it only changes the question:
Why is
it
that you absolutely need to usesetup_initial_mapping()?There is no strict requirement to use
setup_initial_mapping(). That function is available to me at the moment, and I haven't found a better
option other than reusing what I currently have.Quoted 5 lines
I am not very familiar with the code base for RISC-V, but looking at the
context in the patch, it seems you will still have the identity mapping
mapped untilstart_xen().We have identity mapping only for a small piece of .text section:
. = ALIGN(IDENT_AREA_SIZE); _ident_start = .; *(.text.ident) _ident_end = .;All other will be identically mapped only in case of linker address is equal to load address.
Quoted 6 lines
I assume we don't exactly know where the loader will put Xen in memory.
Which means that the region may clash with your defined runtime regions
(such as the FDT). Did I misunderstand anything?
Quoted 4 lines
I am not really get what is the issue here.
If we are speaking about physical regions then loader will guarantee that Xen and FDT regions don't overlap.
Sure. But I was referring to...
Quoted 3 lines
If we are speaking about virtual regions then Xen will check that nothing is overlaped.
... this part. The more regions you mapped with MMU off, the more work you have to do to ensure nothing will clash.
Quoted 3 lines
And the virtual regions are mapped so high so I
am not sure that loader will put something there. ( FDT in Xen is mapped to0xffffffffc0200000)
Never say never :). On Arm, some 64-bit HW (such as ADLink AVA platform) has the RAM starting very high and load Xen around 8TB. For Arm, we still decided to put a limit (10TB) where Xen can be loaded but this is mainly done for convenience (otherwise it is a bit more complicated to get off the identity mapping).
We still have a check in place to ensure that Xen is not loaded above 10TB. If you map the FDT within the same L1.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 5/5] xen/riscv: map FDT
Quoted 1 line · Julien Grall
Hi Oleksii,
Hi Julien,
Quoted 63 lines · Oleksii
Quoted 52 lines · Julien Grall
Quoted 29 lines
Hi,
Quoted 2 lines · Oleksii
Add Julien as he asked basically the same question in another thread.
Thanks!
Quoted 14 lines · Jan Beulich
Quoted 12 lines · Oleksii
Quoted 5 lines · Jan Beulich
Quoted 3 lines · Oleksii
Quoted 2 lines · Jan Beulich
Quoted 1 line · Oleksii Kurochko
Does it make sense now?
I think so, yet at the same time it only changes the question:
Why is
it
that you absolutely need to usesetup_initial_mapping()?Quoted 6 lines
There is no strict requirement to use
setup_initial_mapping(). That
function is available to me at the moment, and I haven't found a
better
option other than reusing what I currently have.Quoted 6 lines
I am not very familiar with the code base for RISC-V, but looking at
the
context in the patch, it seems you will still have the identity mapping
mapped untilstart_xen().We have identity mapping only for a small piece of .text section:
. =ALIGN(IDENT_AREA_SIZE);
_ident_start= .;
*(.text.ident)
_ident_end= .;All other will be identically mapped only in case of linker address is
equal to load address.Quoted 6 lines
I assume we don't exactly know where the loader will put Xen in memory.
Which means that the region may clash with your defined runtime regions
(such as the FDT). Did I misunderstand anything?Quoted 5 lines
I am not really get what is the issue here.
If we are speaking about physical regions then loader will guarantee
that Xen and FDT regions don't overlap.Sure. But I was referring to...
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
If we are speaking about virtual regions then Xen will check that nothing is overlaped.
... this part. The more regions you mapped with MMU off, the more work
you have to do to ensure nothing will clash.
Yes, agree here. Then I have to look at what I need now to introduce map_pages_to_xen().
Thanks for clarifying.
Quoted 4 lines
Quoted 4 lines
And the virtual regions are mapped so high so I
am not sure that loader will put something there. ( FDT in Xen is mapped to0xffffffffc0200000)
Quoted 8 lines
Never say never :). On Arm, some 64-bit HW (such as ADLink AVA platform)
has the RAM starting very high and load Xen around 8TB. For Arm, we still decided to put a limit (10TB) where Xen can be loaded but this is
mainly done for convenience (otherwise it is a bit more complicated to
get off the identity mapping).
Oh, it is very high. I couldn't even expect.
~ Oleksii
Quoted 6 lines
We still have a check in place to ensure that Xen is not loaded above 10TB. If you map the FDT within the same L1.
Cheers,
Re: [PATCH v1 5/5] xen/riscv: map FDT
In reply to OleksiiQuoted 167 lines · Oleksii
Quoted 157 lines · Jan Beulich
Quoted 156 lines · Oleksii
Quoted 29 lines · Jan Beulich
Quoted 28 lines · Oleksii
Quoted 27 lines · Jan Beulich
Quoted 4 lines · Oleksii Kurochko
Except mapping of FDT, it is also printing command line passed
by
a DTB and initialize bootinfo from a DTB.I'm glad the description isn't empty here. However, ...
Quoted 5 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -41,6 +41,9 @@ FUNC(start)
jalsetup_initial_pagetablesQuoted 8 lines
+ mv a0, s1
+ jalfdt_map
+
/* Calculate proper VA after jump from 1:1 mapping */
la a0, .L_primary_switched
sub a0, a0, s2... it could do with clarifying why this needs calling from assembly
code. Mapping the FDT clearly looks like something that wants doing
fromstart_xen(), i.e. from C code.Quoted 6 lines
Quoted 2 lines
fdt_map()expected to work while MMU is off as it is usingsetup_initial_mapping()which is working with physical address.Hmm, interesting. When the MMU is off, what does "map" mean? Yet then
it feels I'm misunderstanding what you're meaning to tell me ...Let's look at examples of the code:
1. The first thing issue will be here:
void*__initearly_fdt_map(paddr_t fdt_paddr)
{
unsigned longdt_phys_base=fdt_paddr;
unsigned longdt_virt_base;
unsigned longdt_virt_size;
BUILD_BUG_ON(MIN_FDT_ALIGN < 8);
if ( !fdt_paddr ||fdt_paddr%MIN_FDT_ALIGN||fdt_paddr%SZ_2M
||
fdt_totalsize(fdt_paddr)>BOOT_FDT_VIRT_SIZE) MMU doesn't now about virtual address offdt_paddrasfdt_paddrwasn't
mapped.2. In
setup_initial_mapping()we haveHANDLE_PGTBL()where pgtbl is a
pointer to physical address ( which also should be mapped in MMU if we
want to access it after MMU is enabled ):
#defineHANDLE_PGTBL(curr_lvl_num)
\
index = pt_index(curr_lvl_num,page_addr);
\
if (pte_is_valid(pgtbl[index])
)
\
{
\
/* Find L{ 0-3 } table
*/
\
pgtbl = (pte_t
*)pte_to_paddr(pgtbl[index]);
\
}
\
else
\
{
\
/* Allocate new L{0-3} page table
*/
\
if (mmu_desc->pgtbl_count==PGTBL_INITIAL_COUNT)
\
{
\
early_printk("(XEN) No initial table available\n");
\
/*panic(),BUG()orASSERT()aren't ready now. */
\die();
\
}
\
mmu_desc-Quoted 1 line
pgtbl_count++;
\
pgtbl[index] = paddr_to_pte((unsigned long)mmu_desc- >next_pgtbl, \PTE_VALID);
\
pgtbl = mmu_desc-Quoted 1 line
next_pgtbl;\
mmu_desc->next_pgtbl+=PAGETABLE_ENTRIES;
\
}
So we can't usesetup_initial_mapping()when MMU is enabled as there is
a part of the code which uses physical address which are not mapped.We have only mapping for for
liner_start<->load_startand the small
piece of code in text section (_ident_start):
setup_initial_mapping(&mmu_desc,
linker_start,
linker_end,
load_start);if (
linker_start==load_start)
return;
ident_start= (unsigned long)turn_on_mmu&XEN_PT_LEVEL_MAP_MASK(0);
ident_end=ident_start+PAGE_SIZE;setup_initial_mapping(&mmu_desc,
ident_start,
ident_end,
ident_start);We can use
setup_initial_mapping()when MMU is enabled only in case whenlinker_startis equal toload_start.As an option we can consider for as a candidate for identaty mapping
also section .bss.page_aligned where root and nonroot page tables are
located.Quoted 5 lines
Quoted 1 line
Does it make sense now?
I think so, yet at the same time it only changes the question: Why is it
that you absolutely need to usesetup_initial_mapping()?There is no strict requirement to use
setup_initial_mapping(). That function is available to me at the moment, and I haven't found a better option other than reusing what I currently have.
Quoted 8 lines
If not to use
setup_initial_mapping()then it is needed to introduce xen_{un}map_table(),create_xen_table(),xen_pt_next_level(), xen_pt_update{_entry}(),map_pages_to_xen(). What I did a little bit later here:
https://gitlab.com/xen-project/people/olkur/xen/-/commit/a4619d0902e0a012ac2f709d31621a8d499bca97
Am I confusing something?Could you please recommend me how to better?
I think you've sorted this for yourself already, judging from subsequent communication on this thread, where you indicate you'll introduce map_pages_to_xen() first. That's the way I'd have expected you to go.
Jan
Re: [PATCH v1 5/5] xen/riscv: map FDT
In reply to OleksiiHi,
Quoted 23 lines · Oleksii
Quoted 12 lines · Jan Beulich
Quoted 2 lines · Oleksii Kurochko
Except mapping of FDT, it is also printing command line passed by a DTB and initialize bootinfo from a DTB.
I'm glad the description isn't empty here. However, ...
Quoted 6 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -41,6 +41,9 @@ FUNC(start) jal setup_initial_pagetablesQuoted 10 lines
xen/arch/riscv/riscv64/head.S FUNC(start) · line 49
Quoted 6 lines
xen/arch/riscv/riscv64/head.S +3
-0+ mv a0, s1 + jal fdt_map + /* Calculate proper VA after jump from 1:1 mapping */ la a0, .L_primary_switched sub a0, a0, s2... it could do with clarifying why this needs calling from assembly code. Mapping the FDT clearly looks like something that wants doing from
start_xen(), i.e. from C code.
Quoted 2 lines
fdt_map()expected to work while MMU is off as it is usingsetup_initial_mapping()which is working with physical address.
Somewhat related to what Jan is asking. You only seem to part the FDT in start_xen(). So why do you need to call fdt_map() that early?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v1 5/5] xen/riscv: map FDT
Quoted 1 line · Julien Grall
Hi,
Hi Julien,
Quoted 28 lines · Oleksii
Quoted 26 lines · Jan Beulich
Quoted 25 lines · Oleksii Kurochko
Quoted 3 lines
Except mapping of FDT, it is also printing command line passed by
a DTB and initialize bootinfo from a DTB.I'm glad the description isn't empty here. However, ...
Quoted 4 lines
xen/arch/riscv/riscv64/head.S +0
-0@@ -41,6 +41,9 @@ FUNC(start)Quoted 8 lines
jal
setup_initial_pagetables
+ mv a0, s1
+ jalfdt_map
+
/* Calculate proper VA after jump from 1:1 mapping */ la a0, .L_primary_switched
sub a0, a0, s2... it could do with clarifying why this needs calling from assembly
code. Mapping the FDT clearly looks like something that wants doing
fromstart_xen(), i.e. from C code.
Quoted 6 lines
Quoted 2 lines
fdt_map()expected to work while MMU is off as it is usingsetup_initial_mapping()which is working with physical address.Somewhat related to what Jan is asking. You only seem to part the FDT in
start_xen(). So why do you need to callfdt_map()that early?
Let's continue our discussion in another thread ( I added you there ).
But the answer on your question is here:
https://lore.kernel.org/xen-devel/[email protected]/T/#m2890200a53c6ea2101e0f9e9ea77f589bd187e26
And here:https://lore.kernel.org/xen-devel/[email protected]/T/#m4e20792121b97465db7081cc4c1e27bdb15cdd51
Let me know if the link above answers your question.
~ Oleksii
Missed to write in the cover letter that this patch series is based on:
[PATCH for 4.20 v9 0/5] RISCV basic exception handling implementation
~ Oleksii
Quoted 48 lines · Oleksii Kurochko
Current patch series introduces device tree mapping for RISC-V.
Also, it introduces common stuff for working with fdt which is based on the patches from [1]:
[PATCH v4 2/6] xen/device-tree: Move Arm'ssetup.cbootinfo functions to common
[PATCH v4 3/6] xen/common: Move Arm'sbootfdt.c
All changes which were done on top of Shawn's patches please find in "Changes" section
of each patch.[1]
https://lore.kernel.org/xen-devel/[email protected]/Oleksii Kurochko (3):
xen/riscv: enableCONFIG_HAS_DEVICE_TREExen/riscv: introduce device tree maping function xen/riscv: map FDTShawn Anastasio (2):
xen/device-tree: Move Arm'ssetup.cbootinfo functions to common xen/common: Move Arm'sbootfdt.cto commonMAINTAINERS | 2 + xen/arch/arm/Makefile | 1 - xen/arch/arm/bootfdt.c | 622 -------------------------- -
xen/arch/arm/include/asm/setup.h | 200 +-------- xen/arch/arm/setup.c | 432 ------------------- xen/arch/riscv/Kconfig | 1 +xen/arch/riscv/include/asm/config.h| 6 + xen/arch/riscv/include/asm/mm.h | 2 + xen/arch/riscv/mm.c | 37 +- xen/arch/riscv/riscv64/head.S | 3 + xen/arch/riscv/setup.c | 21 + xen/common/Makefile | 1 + xen/common/device-tree/Makefile | 2 + xen/common/device-tree/bootfdt.c | 635
++++++++++++++++++++++++++++
xen/common/device-tree/bootinfo.c | 459 ++++++++++++++++++++ xen/include/xen/bootfdt.h | 210 +++++++++16 files changed, 1375 insertions(+), 1259 deletions(-)delete mode 100644
xen/arch/arm/bootfdt.ccreate mode 100644 xen/common/device-tree/Makefile create mode 100644xen/common/device-tree/bootfdt.ccreate mode 100644xen/common/device-tree/bootinfo.ccreate mode 100644xen/include/xen/bootfdt.h