|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v8 2/5] xen/riscv: introduce setup_initial_pages
On 22.05.2023 14:18, Oleksii Kurochko wrote:
> The idea was taken from xvisor but the following changes
> were done:
> * Use only a minimal part of the code enough to enable MMU
> * rename {_}setup_initial_pagetables functions
> * add an argument for setup_initial_mapping to have
> an opportunity to make set PTE flags.
> * update setup_initial_pagetables function to map sections
> with correct PTE flags.
> * Rewrite enable_mmu() to C.
> * map linker addresses range to load addresses range without
> 1:1 mapping. It will be 1:1 only in case when
> load_start_addr is equal to linker_start_addr.
> * add safety checks such as:
> * Xen size is less than page size
> * linker addresses range doesn't overlap load addresses
> range
> * Rework macros {THIRD,SECOND,FIRST,ZEROETH}_{SHIFT,MASK}
> * change PTE_LEAF_DEFAULT to RW instead of RWX.
> * Remove phys_offset as it is not used now
> * Remove alignment of {map, pa}_start &= XEN_PT_LEVEL_MAP_MASK(0);
> in setup_inital_mapping() as they should be already aligned.
> Make a check that {map_pa}_start are aligned.
> * Remove clear_pagetables() as initial pagetables will be
> zeroed during bss initialization
> * Remove __attribute__((section(".entry")) for setup_initial_pagetables()
> as there is no such section in xen.lds.S
> * Update the argument of pte_is_valid() to "const pte_t *p"
> * Add check that Xen's load address is aligned at 4k boundary
> * Refactor setup_initial_pagetables() so it is mapping linker
> address range to load address range. After setup needed
> permissions for specific section ( such as .text, .rodata, etc )
> otherwise RW permission will be set by default.
> * Add function to check that requested SATP_MODE is supported
>
> Origin: git@xxxxxxxxxx:xvisor/xvisor.git 9be2fdd7
> Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
with one more nit and a remark:
> --- /dev/null
> +++ b/xen/arch/riscv/include/asm/page.h
> @@ -0,0 +1,61 @@
> +#ifndef _ASM_RISCV_PAGE_H
> +#define _ASM_RISCV_PAGE_H
> +
> +#include <xen/const.h>
> +#include <xen/types.h>
> +
> +#include <asm/mm.h>
> +#include <asm/page-bits.h>
> +
> +#define VPN_MASK ((unsigned long)(PAGETABLE_ENTRIES - 1))
Just as a remark - this could also be just
#define VPN_MASK (PAGETABLE_ENTRIES - 1UL)
> --- /dev/null
> +++ b/xen/arch/riscv/mm.c
> @@ -0,0 +1,277 @@
> +#include <xen/compiler.h>
> +#include <xen/init.h>
> +#include <xen/kernel.h>
> +#include <xen/pfn.h>
> +
> +#include <asm/early_printk.h>
> +#include <asm/csr.h>
> +#include <asm/current.h>
> +#include <asm/mm.h>
> +#include <asm/page.h>
> +#include <asm/processor.h>
> +
> +struct mmu_desc {
> + unsigned int num_levels;
> + unsigned int pgtbl_count;
> + pte_t *next_pgtbl;
> + pte_t *pgtbl_base;
> +};
> +
> +extern unsigned char cpu0_boot_stack[STACK_SIZE];
> +
> +#define PHYS_OFFSET ((unsigned long)_start - XEN_VIRT_START)
> +#define LOAD_TO_LINK(addr) ((addr) - PHYS_OFFSET)
> +#define LINK_TO_LOAD(addr) ((addr) + PHYS_OFFSET)
> +
> +
Nit: No double blank lines please.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |