|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [PATCH v2 13/16] Save/Restore Support: Add suspend/restore support for Grant Tables.
Signed-off-by: Bruno Alvisio <bruno.alvisio@xxxxxxxxx>
---
Changed since v1:
- Moved suspend/resume _gnttab to arch specific files
---
arch/x86/mm.c | 34 ++++++++++++++++++++++++++++++++++
gnttab.c | 10 ++++++++++
include/gnttab.h | 4 ++++
kernel.c | 4 ++++
4 files changed, 52 insertions(+)
diff --git a/arch/x86/mm.c b/arch/x86/mm.c
index 1b163ac..2597c5b 100644
--- a/arch/x86/mm.c
+++ b/arch/x86/mm.c
@@ -917,6 +917,40 @@ grant_entry_v1_t *arch_init_gnttab(int nr_grant_frames)
return map_frames(frames, nr_grant_frames);
}
+void arch_suspend_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_frames)
+{
+#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 arch_resume_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_frames)
+{
+ struct gnttab_setup_table setup;
+ unsigned long frames[nr_grant_frames];
+#ifdef CONFIG_PARAVIRT
+ int i;
+#endif
+ 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
+ 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
+}
+
unsigned long alloc_virt_kernel(unsigned n_pages)
{
unsigned long addr;
diff --git a/gnttab.c b/gnttab.c
index 3f0e35f..6978a9b 100644
--- a/gnttab.c
+++ b/gnttab.c
@@ -194,3 +194,13 @@ fini_gnttab(void)
HYPERVISOR_grant_table_op(GNTTABOP_setup_table, &setup, 1);
}
+
+void suspend_gnttab(void)
+{
+ arch_suspend_gnttab(gnttab_table, NR_GRANT_FRAMES);
+}
+
+void resume_gnttab(void)
+{
+ arch_resume_gnttab(gnttab_table, NR_GRANT_FRAMES);
+}
diff --git a/include/gnttab.h b/include/gnttab.h
index a9d8e09..974cb89 100644
--- a/include/gnttab.h
+++ b/include/gnttab.h
@@ -12,6 +12,10 @@ 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);
+void arch_suspend_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_frames);
+void arch_resume_gnttab(grant_entry_v1_t *gnttab_table, int nr_grant_frames);
#endif /* !__GNTTAB_H__ */
diff --git a/kernel.c b/kernel.c
index d078e0a..933cbcd 100644
--- a/kernel.c
+++ b/kernel.c
@@ -121,6 +121,8 @@ void pre_suspend(void)
{
local_irq_disable();
+ suspend_gnttab();
+
fini_time();
suspend_console();
@@ -134,6 +136,8 @@ void post_suspend(int canceled)
init_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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |