[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 10/17] xen/riscv: implement guest_physmap_add_entry() for mapping GFNs to MFNs




On 6/30/25 5:59 PM, Jan Beulich wrote:
On 10.06.2025 15:05, Oleksii Kurochko wrote:

      
+                              unsigned long nr, mfn_t mfn, p2m_type_t t)
+{
+    struct p2m_domain *p2m = p2m_get_hostp2m(d);
+    int rc;
+
+    p2m_write_lock(p2m);
+    rc = p2m_set_entry(p2m, start_gfn, nr, mfn, t, p2m->default_access);
+    p2m_write_unlock(p2m);
+
+    return rc;
+}
+
+int map_regions_p2mt(struct domain *d,
+                     gfn_t gfn,
+                     unsigned long nr,
+                     mfn_t mfn,
+                     p2m_type_t p2mt)
+{
+    return p2m_insert_mapping(d, gfn, nr, mfn, p2mt);
+}
What is this function doing here? The description says "for generic mapping
purposes", which really may mean anything. Plus, if and when you need it, it
wants to come with a name that fits with e.g. ...
These names are used across the common code and various architectures. Not all
architectures need to implement all of these functions.
I believe guest_physmap_add_page() (which internally calls guest_physmap_add_entry())
is needed to be implemented for all architectures, while map_regions_p2mt() is used
by Arm and the common Dom0less-related code, and because of RISC-V is going to re-use
common Dom0less code it is implementing this function too.

+int guest_physmap_add_entry(struct domain *d,
+                            gfn_t gfn,
+                            mfn_t mfn,
+                            unsigned long page_order,
+                            p2m_type_t t)
... this one, to understand their relationship / difference.
Basically, the difference is only in API and where they are expected to be used:
- guest_physmap_add_entry() to map and set a specific p2m type for a page.
- map_regions_p2mt() to map a region (mostly MMIO) in the guest p2m with
  a specific p2m type.

I added both of them here as they are implemented in a similar way.
I will re-word commit subject and message:
  xen/riscv: implement functions to map memory in guest p2m

  Introduce guest_physmap_add_entry() to map a page and assign a specific
  p2m type, and map_regions_p2mt() to map a region (typically MMIO) in
  the guest p2m with a designated p2m type.

  Currently, this functionality is not fully operational, as p2m_set_entry()
  still returns -EOPNOTSUPP.

  Additionally, introduce p2m_write_(un)lock() to protect modifications to
  the p2m page tables, along with p2m TLB flush helpers to ensure proper
  TLB invalidation (if necessary) when the p2m lock is released.

~ Oleksii

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.