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

[Minios-devel] [PATCH RFC 13/16] Save/Restore Support: Add suspend/restore support for Grant Tables.



Signed-off-by: Bruno Alvisio <bruno.alvisio@xxxxxxxxx>
---
 gnttab.c         | 33 +++++++++++++++++++++++++++++++++
 include/gnttab.h |  2 ++
 kernel.c         |  4 ++++
 3 files changed, 39 insertions(+)

diff --git a/gnttab.c b/gnttab.c
index 3f0e35f..a91c2e1 100644
--- a/gnttab.c
+++ b/gnttab.c
@@ -194,3 +194,36 @@ fini_gnttab(void)
 
     HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
 }
+
+void suspend_gnttab(void)
+{
+#ifdef CONFIG_PARAVIRT
+    int i;
+
+    for (i = 0; i < NR_GRANT_FRAMES; i++) {
+        HYPERVISOR_update_va_mapping((unsigned long)(((char *)gnttab_table) + 
PAGE_SIZE*i),
+                (pte_t){0x0<<PAGE_SHIFT}, UVMF_INVLPG);
+    }
+#endif
+    return;
+}
+
+void resume_gnttab(void)
+{
+    struct gnttab_setup_table setup;
+    unsigned long frames[NR_GRANT_FRAMES];
+
+    setup.dom = DOMID_SELF;
+    setup.nr_frames = NR_GRANT_FRAMES;
+    set_xen_guest_handle(setup.frame_list, frames);
+
+    HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
+
+#ifdef CONFIG_PARAVIRT
+    int i;
+    for (i = 0; i < NR_GRANT_FRAMES; i++) {
+        HYPERVISOR_update_va_mapping((unsigned long)(((char *)gnttab_table) + 
PAGE_SIZE*i),
+                (pte_t){(frames[i] << PAGE_SHIFT) | L1_PROT}, UVMF_INVLPG);
+    }
+#endif
+}
\ No newline at end of file
diff --git a/include/gnttab.h b/include/gnttab.h
index a9d8e09..56f5159 100644
--- a/include/gnttab.h
+++ b/include/gnttab.h
@@ -12,6 +12,8 @@ unsigned long gnttab_end_transfer(grant_ref_t gref);
 int gnttab_end_access(grant_ref_t ref);
 const char *gnttabop_error(int16_t status);
 void fini_gnttab(void);
+void suspend_gnttab(void);
+void resume_gnttab(void);
 grant_entry_v1_t *arch_init_gnttab(int nr_grant_frames);
 
 #endif /* !__GNTTAB_H__ */
diff --git a/kernel.c b/kernel.c
index c6ff9f3..a563f60 100644
--- a/kernel.c
+++ b/kernel.c
@@ -121,6 +121,8 @@ void pre_suspend(void)
 {
     local_irq_disable();
 
+    suspend_gnttab();
+
     suspend_time();
 
     suspend_console();
@@ -134,6 +136,8 @@ void post_suspend(int canceled)
 
     resume_time();
 
+    resume_gnttab();
+
     local_irq_enable();
 }
 
-- 
2.3.2 (Apple Git-55)


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

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