|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v2 02/26] xen/riscv: Implement ARCH_PAGING_MEMPOOL
The p2m_freelist is used to allocate pages for the P2M. To initialize
this list, domain_p2m_set_allocation() may be called from construct_domU()
in the common Dom0less code, so RISC-V provides an implementation and
enables CONFIG_ARCH_PAGING_MEMPOOL unconditionally.
Additionally, implement arch_{set,get}_paging_mempool_size(). They are
not directly used yet, but are required to support the
XEN_DOMCTL_{get,set}_paging_mempool_size hypercalls.
Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
---
Changes in v2:
- Turn on CONFIG_ARCH_PAGING_MEMPOOL=y unconditionally and drop all ifdef-s
related to this config.
- Optimize check inside arch_set_paging_mempool_size which verify size
argument.
- Use pfn_to_paddr() inside arch_get_paging_mempool_size() instead of open
coding the stuff.
- Drop ASSERT() from arch_set_paging_mempool_size() as it is impossible to
have here preempted = true and rc != -ERESTART.
---
---
xen/arch/riscv/Kconfig | 1 +
xen/arch/riscv/p2m.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig
index 41426c205292..48520588fe40 100644
--- a/xen/arch/riscv/Kconfig
+++ b/xen/arch/riscv/Kconfig
@@ -1,5 +1,6 @@
config RISCV
def_bool y
+ select ARCH_PAGING_MEMPOOL
select DOMAIN_BUILD_HELPERS
select FUNCTION_ALIGNMENT_16B
select GENERIC_BUG_FRAME
diff --git a/xen/arch/riscv/p2m.c b/xen/arch/riscv/p2m.c
index 41d6d3d5e699..bed997bd9d5a 100644
--- a/xen/arch/riscv/p2m.c
+++ b/xen/arch/riscv/p2m.c
@@ -1606,3 +1606,27 @@ struct page_info *get_page_from_gfn(struct domain *d,
unsigned long gfn,
return p2m_get_page_from_gfn(p2m_get_hostp2m(d), _gfn(gfn), t);
}
+
+int arch_set_paging_mempool_size(struct domain *d, uint64_t size)
+{
+ unsigned long pages = PFN_DOWN(size);
+ int rc;
+
+ /* Non page-sized request or 32-bit overflow? */
+ if ( pfn_to_paddr(pages) != size )
+ return -EINVAL;
+
+ spin_lock(&d->arch.paging.lock);
+ rc = p2m_set_allocation(d, pages, true);
+ spin_unlock(&d->arch.paging.lock);
+
+ return rc;
+}
+
+/* Return the size of the pool, in bytes. */
+int arch_get_paging_mempool_size(struct domain *d, uint64_t *size)
+{
+ *size = pfn_to_paddr(ACCESS_ONCE(d->arch.paging.total_pages));
+
+ return 0;
+}
--
2.54.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |