xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Jaeyong Yoo <jaeyong.yoo@samsung.com>
To: xen-devel@lists.xen.org
Cc: Jaeyong Yoo <jaeyong.yoo@samsung.com>
Subject: [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions
Date: Wed, 05 Jun 2013 14:46:17 +0900	[thread overview]
Message-ID: <1370411179-13570-3-git-send-email-jaeyong.yoo@samsung.com> (raw)
In-Reply-To: <1370411179-13570-1-git-send-email-jaeyong.yoo@samsung.com>

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

  parent reply	other threads:[~2013-06-05  5:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-05  5:46 [PATCH RFC 0/4] arm: regarding live migration Jaeyong Yoo
2013-06-05  5:46 ` [PATCH RFC 1/4] Create new directory for stroing hvm-related files in ARM Jaeyong Yoo
2013-06-05  5:46 ` Jaeyong Yoo [this message]
2013-06-05  9:17   ` [PATCH RFC 2/4] Implement arch_hvm_save and arch_hvm_load functions Ian Campbell
2013-06-05  5:46 ` [PATCH RFC 3/4] Implement save and restore for gic (template impl) Jaeyong Yoo
2013-06-05  9:21   ` Ian Campbell
2013-06-05  5:46 ` [PATCH RFC 4/4] Implement XEN_DOMCTL_gethvmcontext part of arch_do_domctl Jaeyong Yoo
2013-06-05  9:24   ` Ian Campbell
2013-06-05  9:13 ` [PATCH RFC 0/4] arm: regarding live migration Ian Campbell
2013-06-05  9:23   ` Ian Campbell
2013-06-05  9:26 ` Ian Campbell
  -- strict thread matches above, loose matches on Subject: below --
2013-06-05 10:27 [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
2013-06-05 10:46 Jaeyong Yoo

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=1370411179-13570-3-git-send-email-jaeyong.yoo@samsung.com \
    --to=jaeyong.yoo@samsung.com \
    --cc=xen-devel@lists.xen.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).