To enable DOMAIN_BUILD_HELPERS for RISC-V the following is introduced: - Add a global p2m_ipa_bits variable, initialized to PADDR_BITS, to represent the maximum supported IPA size as find_unallocated_memory() requires it. - Define default guest RAM layout parameters in the public RISC-V header as it is required by allocate_memory().
Signed-off-by: Oleksii Kurochko <[email protected]> --- xen/arch/riscv/Kconfig | 1 + xen/arch/riscv/include/asm/p2m.h | 3 +++ xen/arch/riscv/p2m.c | 6 ++++++ xen/include/public/arch-riscv.h | 8 ++++++++ 4 files changed, 18 insertions(+) diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig index 89876b32175d..12b337365f1f 100644 --- a/xen/arch/riscv/Kconfig +++ b/xen/arch/riscv/Kconfig @@ -1,5 +1,6 @@ config RISCV def_bool y + select DOMAIN_BUILD_HELPERS select FUNCTION_ALIGNMENT_16B select GENERIC_BUG_FRAME select GENERIC_UART_INIT diff --git a/xen/arch/riscv/include/asm/p2m.h b/xen/arch/riscv/include/asm/p2m.h index c68494593fd9..083549ef9640 100644 --- a/xen/arch/riscv/include/asm/p2m.h +++ b/xen/arch/riscv/include/asm/p2m.h @@ -44,6 +44,9 @@ #define P2M_LEVEL_MASK(p2m, lvl) \ (P2M_TABLE_OFFSET(p2m, lvl) << P2M_GFN_LEVEL_SHIFT(lvl)) +/* Holds the bit size of IPAs in p2m tables */ +extern unsigned int p2m_ipa_bits; + #define paddr_bits PADDR_BITS /* Get host p2m table */ diff --git a/xen/arch/riscv/p2m.c b/xen/arch/riscv/p2m.c index f5b03e1e3264..62bd8a2f602f 100644 --- a/xen/arch/riscv/p2m.c +++ b/xen/arch/riscv/p2m.c @@ -51,6 +51,12 @@ static struct gstage_mode_desc __ro_after_init max_gstage_mode = { .name = "Bare", }; +/* + * Set to the maximum configured support for IPA bits, so the number of IPA bits can be + * restricted by external entity (e.g. IOMMU). + */ +unsigned int __read_mostly p2m_ipa_bits = PADDR_BITS; + static void p2m_free_page(struct p2m_domain *p2m, struct page_info *pg); static inline void p2m_free_metadata_page(struct p2m_domain *p2m, diff --git a/xen/include/public/arch-riscv.h b/xen/include/public/arch-riscv.h index 360d8e6871ba..91cee3096041 100644 --- a/xen/include/public/arch-riscv.h +++ b/xen/include/public/arch-riscv.h @@ -50,6 +50,14 @@ typedef uint64_t xen_ulong_t; #if defined(__XEN__) || defined(__XEN_TOOLS__) +#define GUEST_RAM_BANKS 1 + +#define GUEST_RAM0_BASE xen_mk_ullong(0x80000000) /* 2GB of low RAM @ 2GB */ +#define GUEST_RAM0_SIZE xen_mk_ullong(0x80000000) + +#define GUEST_RAM_BANK_BASES { GUEST_RAM0_BASE } +#define GUEST_RAM_BANK_SIZES { GUEST_RAM0_SIZE } + struct vcpu_guest_context { }; typedef struct vcpu_guest_context vcpu_guest_context_t; -- 2.52.0
