On 12.07.2024 18:22, Oleksii Kurochko wrote:
> --- /dev/null
> +++ b/xen/arch/riscv/include/asm/pmap.h
> @@ -0,0 +1,28 @@
> +#ifndef __ASM_PMAP_H__
> +#define __ASM_PMAP_H__
> +
> +#include <xen/bug.h>
> +#include <xen/mm.h>
> +
> +#include <asm/fixmap.h>
> +
> +static inline void arch_pmap_map(unsigned int slot, mfn_t mfn)
> +{
> + pte_t *entry = &xen_fixmap[slot];
> + pte_t pte;
> +
> + ASSERT(!pte_is_valid(*entry));
> +
> + pte = mfn_to_xen_entry(mfn, PAGE_HYPERVISOR_RW);
> + pte.pte |= PTE_LEAF_DEFAULT;
> + write_pte(entry, pte);
> +}
> +
> +static inline void arch_pmap_unmap(unsigned int slot)
> +{
> + pte_t pte = {};
> +
> + write_pte(&xen_fixmap[slot], pte);
> +}
Why are these not using set_fixmap() / clear_fixmap() respectively?
> --- a/xen/arch/riscv/mm.c
> +++ b/xen/arch/riscv/mm.c
> @@ -370,3 +370,17 @@ int map_pages_to_xen(unsigned long virt,
> BUG_ON("unimplemented");
> return -1;
> }
> +
> +static inline pte_t mfn_to_pte(mfn_t mfn)
This name suggests (to me) that you're getting _the_ (single) PTE for
a given MFN. However, what the function is doing is make a PTE using
the given MFN. On x86 at least the common way to name such a function
would be pte_from_mfn().
> +{
> + unsigned long pte = mfn_x(mfn) << PTE_PPN_SHIFT;
> + return (pte_t){ .pte = pte};
Nit: Blank missing.
Jan