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

[Xen-devel] [PATCH RFC 10/14] xen: vmx: Implement the Hypercall p2m_set_subpage



From: Zhang Yi Z <yi.z.zhang@xxxxxxxxxxxxxxx>

To utilize SPP feature, system admin should Set a Sub-page access write via
SPP Hypercall `HVMOP_set_subpage`, which will prepared the flowing things.

   (1.Got the corresponding EPT leaf entry via the guest physical address.
   (2.If it is a 4K page frame, flag the bit 61 to enable subpage protection on 
this page.
   (3.Setup spp page structure.

Signed-off-by: Zhang Yi Z <yi.z.zhang@xxxxxxxxxxxxxxx>
---
 xen/arch/x86/hvm/hvm.c       |  8 ++++++++
 xen/arch/x86/mm/mem_access.c | 15 +++++++++++++++
 xen/include/xen/mem_access.h |  2 ++
 3 files changed, 25 insertions(+)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 54cd916..afc4620 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4696,9 +4696,17 @@ long do_hvm_op(unsigned long op, 
XEN_GUEST_HANDLE_PARAM(void) arg)
 
     case HVMOP_set_subpage: {
         xen_hvm_subpage_t subpage;
+        struct domain *d;
 
         if ( copy_from_guest(&subpage, arg, 1 ) )
             return -EFAULT;
+
+        d = rcu_lock_domain_by_any_id(subpage.domid);
+        if ( d == NULL )
+            return -ESRCH;
+
+        rc = p2m_set_subpage(d, (_gfn)(subpage.gfn), subpage.access_map);
+        rcu_unlock_domain(d);
         break;
     }
 
diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
index 1b97469..fdedc4a 100644
--- a/xen/arch/x86/mm/mem_access.c
+++ b/xen/arch/x86/mm/mem_access.c
@@ -525,6 +525,21 @@ int p2m_set_spp_page_st(struct domain *d, gfn_t gfn, 
uint32_t access_map)
     return ret;
 }
 
+int p2m_set_subpage(struct domain *d, gfn_t gfn, uint32_t access_map)
+{
+    int ret;
+    ret = p2m_set_mem_spp_wp(d, gfn);
+    if ( ret < 0 )
+    {
+        printk("SPP: Set subpage ept wp failed!! %x\n", ret);
+        return ret;
+    }
+    ret = p2m_set_spp_page_st(d, gfn, access_map);
+    if ( ret < 0 )
+        printk("SPP: Set subpage table failed!! %x\n", ret);
+    return ret;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/xen/mem_access.h b/xen/include/xen/mem_access.h
index 5ab34c1..28eb70c 100644
--- a/xen/include/xen/mem_access.h
+++ b/xen/include/xen/mem_access.h
@@ -78,6 +78,8 @@ long p2m_set_mem_access_multi(struct domain *d,
  */
 int p2m_get_mem_access(struct domain *d, gfn_t gfn, xenmem_access_t *access);
 
+int p2m_set_subpage(struct domain *d, gfn_t gfn, uint32_t access_map);
+
 #ifdef CONFIG_HAS_MEM_ACCESS
 int mem_access_memop(unsigned long cmd,
                      XEN_GUEST_HANDLE_PARAM(xen_mem_access_op_t) arg);
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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