* [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions
2013-06-05 5:46 [PATCH RFC 0/4] arm: regarding live migration Jaeyong Yoo
@ 2013-06-05 5:46 ` Jaeyong Yoo
2013-06-05 9:17 ` Ian Campbell
0 siblings, 1 reply; 5+ messages in thread
From: Jaeyong Yoo @ 2013-06-05 5:46 UTC (permalink / raw)
To: xen-devel; +Cc: Jaeyong Yoo
Signed-off-by: Jaeyong Yoo <jaeyong.yoo@samsung.com>
---
xen/arch/arm/hvm/Makefile | 1 +
xen/arch/arm/hvm/save.c | 69 ++++++++++++++++++++++++++++++++
xen/include/public/arch-arm/hvm/save.h | 16 ++++++++
3 files changed, 86 insertions(+)
create mode 100644 xen/arch/arm/hvm/save.c
diff --git a/xen/arch/arm/hvm/Makefile b/xen/arch/arm/hvm/Makefile
index 6ee4054..ad38e09 100644
--- a/xen/arch/arm/hvm/Makefile
+++ b/xen/arch/arm/hvm/Makefile
@@ -1 +1,2 @@
obj-y += hvm.o
+obj-y += save.o
diff --git a/xen/arch/arm/hvm/save.c b/xen/arch/arm/hvm/save.c
new file mode 100644
index 0000000..b92f593
--- /dev/null
+++ b/xen/arch/arm/hvm/save.c
@@ -0,0 +1,69 @@
+/*
+ * hvm/save.c: Save and restore HVM guest's emulated hardware state for ARM.
+ *
+ * Copyright (c) 2013, Samsung Electronics.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place - Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include <xen/types.h>
+#include <xen/hvm/save.h>
+#include <public/arch-arm/hvm/save.h>
+#include <asm/processor.h>
+#include <xen/sched.h>
+
+void arch_hvm_save(struct domain *d, struct hvm_save_header *hdr)
+{
+ hdr->cpuid = READ_SYSREG32(MIDR_EL1);
+}
+
+int arch_hvm_load(struct domain *d, struct hvm_save_header *hdr)
+{
+ uint32_t cpuid;
+
+ if ( hdr->magic != HVM_FILE_MAGIC )
+ {
+ printk(XENLOG_G_ERR "HVM%d restore: bad magic number %#"PRIx32"\n",
+ d->domain_id, hdr->magic);
+ return -1;
+ }
+
+ if ( hdr->version != HVM_FILE_VERSION )
+ {
+ printk(XENLOG_G_ERR "HVM%d restore: unsupported version %u\n",
+ d->domain_id, hdr->version);
+ return -1;
+ }
+
+ cpuid = READ_SYSREG32(MIDR_EL1);
+ if ( hdr->cpuid != cpuid )
+ {
+ printk(XENLOG_G_INFO "HVM%d restore: VM saved on one CPU "
+ "(%#"PRIx32") and restored on another (%#"PRIx32").\n",
+ d->domain_id, hdr->cpuid, cpuid);
+ return -1;
+ }
+
+ return 0;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/public/arch-arm/hvm/save.h b/xen/include/public/arch-arm/hvm/save.h
index 75b8e65..570809e 100644
--- a/xen/include/public/arch-arm/hvm/save.h
+++ b/xen/include/public/arch-arm/hvm/save.h
@@ -26,6 +26,22 @@
#ifndef __XEN_PUBLIC_HVM_SAVE_ARM_H__
#define __XEN_PUBLIC_HVM_SAVE_ARM_H__
+/*
+ * Save/restore header: general info about the save file.
+ */
+
+#define HVM_FILE_MAGIC 0x92385520
+#define HVM_FILE_VERSION 0x00000001
+
+struct hvm_save_header {
+ uint32_t magic; /* Must be HVM_FILE_MAGIC */
+ uint32_t version; /* File format version */
+ uint64_t changeset; /* Version of Xen that saved this file */
+ uint32_t cpuid; /* CPUID[0x01][%eax] on the saving machine */
+};
+
+DECLARE_HVM_SAVE_TYPE(HEADER, 1, struct hvm_save_header);
+
#endif
/*
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions
2013-06-05 5:46 ` [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions Jaeyong Yoo
@ 2013-06-05 9:17 ` Ian Campbell
0 siblings, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2013-06-05 9:17 UTC (permalink / raw)
To: Jaeyong Yoo; +Cc: xen-devel
> diff --git a/xen/include/public/arch-arm/hvm/save.h b/xen/include/public/arch-arm/hvm/save.h
> index 75b8e65..570809e 100644
> --- a/xen/include/public/arch-arm/hvm/save.h
> +++ b/xen/include/public/arch-arm/hvm/save.h
> @@ -26,6 +26,22 @@
> #ifndef __XEN_PUBLIC_HVM_SAVE_ARM_H__
> #define __XEN_PUBLIC_HVM_SAVE_ARM_H__
>
> +/*
> + * Save/restore header: general info about the save file.
> + */
> +
> +#define HVM_FILE_MAGIC 0x92385520
> +#define HVM_FILE_VERSION 0x00000001
> +
> +struct hvm_save_header {
> + uint32_t magic; /* Must be HVM_FILE_MAGIC */
> + uint32_t version; /* File format version */
> + uint64_t changeset; /* Version of Xen that saved this file */
> + uint32_t cpuid; /* CPUID[0x01][%eax] on the saving machine */
The comment here looks x86 to be specific.
Need to consider whether MIDR is sufficient for the safety check we have
or whether it is appropriate in the header at all, perhaps it should be
in a separate cpu features save header?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions
@ 2013-06-05 10:27 Jaeyong Yoo
0 siblings, 0 replies; 5+ messages in thread
From: Jaeyong Yoo @ 2013-06-05 10:27 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xen.org
[-- Attachment #1: Type: text/html, Size: 2755 bytes --]
[-- Attachment #2: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions
[not found] <85.CD.07473.B821FA15@epcpsbgx2.samsung.com>
@ 2013-06-05 10:40 ` Ian Campbell
0 siblings, 0 replies; 5+ messages in thread
From: Ian Campbell @ 2013-06-05 10:40 UTC (permalink / raw)
To: jaeyong.yoo; +Cc: xen-devel@lists.xen.org
On Wed, 2013-06-05 at 10:27 +0000, Jaeyong Yoo wrote:
> To sum up, regisers are MIDR, REVIDR, ID_PFR0, and ID_PFR1
>
> I think if we use all of them for safety check, it is sufficient.
>
> (Maybe it is too much?)
Perhaps we should leave this to one side for now and revisit once we
have a working save/restore and understand the constraints upon it a bit
better?
Ian.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions
@ 2013-06-05 10:46 Jaeyong Yoo
0 siblings, 0 replies; 5+ messages in thread
From: Jaeyong Yoo @ 2013-06-05 10:46 UTC (permalink / raw)
To: Ian Campbell; +Cc: xen-devel@lists.xen.org
> > I think if we use all of them for safety check, it is sufficient.
> >
> > (Maybe it is too much?)
>
> Perhaps we should leave this to one side for now and revisit once we
> have a working save/restore and understand the constraints upon it a bit
> better?
Sure, of course.
Jaeyong
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-06-05 10:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-05 10:46 [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions Jaeyong Yoo
[not found] <85.CD.07473.B821FA15@epcpsbgx2.samsung.com>
2013-06-05 10:40 ` Ian Campbell
-- strict thread matches above, loose matches on Subject: below --
2013-06-05 10:27 Jaeyong Yoo
2013-06-05 5:46 [PATCH RFC 0/4] arm: regarding live migration Jaeyong Yoo
2013-06-05 5:46 ` [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions Jaeyong Yoo
2013-06-05 9:17 ` Ian Campbell
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).