From: Bruno Alvisio <bruno.alvisio@gmail.com>
To: minios-devel@lists.xenproject.org, xen-devel@lists.xenproject.org
Cc: jgross@suse.com, samuel.thibault@ens-lyon.org, wei.liu2@citrix.com
Subject: [PATCH v2 13/16] Save/Restore Support: Add suspend/restore support for Grant Tables.
Date: Tue, 13 Feb 2018 18:27:36 -0800 [thread overview]
Message-ID: <1518575259-71141-14-git-send-email-bruno.alvisio@gmail.com> (raw)
In-Reply-To: <1518575259-71141-1-git-send-email-bruno.alvisio@gmail.com>
Signed-off-by: Bruno Alvisio <bruno.alvisio@gmail.com>
---
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)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-02-14 2:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-14 2:27 [PATCH v2 00/16] Save/Restore Support for mini-OS PVH Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 01/16] Save/Restore Support: Refactor HYPERVISOR_suspend hypercall Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 02/16] Save/Restore Support: Refactor trap_init() and setup vector callbacks Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 03/16] Save/Restore Support: Declare kernel and arch pre/post suspend functions Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 04/16] Save/Restore Support: Add xenbus_release_wait_for_watch Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 05/16] Save/Restore Support: Add kernel shutdown logic to shutdown.c Bruno Alvisio
2018-02-14 8:19 ` Juergen Gross
2018-02-14 2:27 ` [PATCH v2 06/16] Save/Restore Support: Moved shutdown thread " Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 07/16] Save/Restore Support: Add unmap_shared_info Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 08/16] Save/Restore Support: Add arch_mm_pre|post_suspend Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 09/16] Save/Restore Support: Disable/enable IRQs during suspend/restore Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 10/16] Save/Restore Support: Add suspend/resume support for timers Bruno Alvisio
2018-02-14 8:20 ` Juergen Gross
2018-02-14 2:27 ` [PATCH v2 11/16] Save/Restore Support: Add suspend/restore support for console Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 12/16] Save/Restore Support: Add support for suspend/restore events Bruno Alvisio
2018-02-14 2:27 ` Bruno Alvisio [this message]
2018-02-14 12:42 ` [PATCH v2 13/16] Save/Restore Support: Add suspend/restore support for Grant Tables Juergen Gross
2018-02-14 2:27 ` [PATCH v2 14/16] Save/Restore Support: Add suspend/restore support for xenbus Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 15/16] Save/Restore Support: Add suspend/restore support for netfront Bruno Alvisio
2018-02-14 2:27 ` [PATCH v2 16/16] Save/Restore Support: Implement code for arch suspend/resume Bruno Alvisio
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1518575259-71141-14-git-send-email-bruno.alvisio@gmail.com \
--to=bruno.alvisio@gmail.com \
--cc=jgross@suse.com \
--cc=minios-devel@lists.xenproject.org \
--cc=samuel.thibault@ens-lyon.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).