ia64/xen-unstable

view xen/arch/x86/hvm/save.c @ 19838:95f051cb70b4

x86 hvm: Fix printf format specifier

Signed-off-by: Jun Koi <junkoi2004@gmail.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 25 13:12:32 2009 +0100 (2009-06-25)
parents 81edfffb3aff
children
line source
1 /*
2 * hvm/save.c: Save and restore HVM guest's emulated hardware state.
3 *
4 * Copyright (c) 2004, Intel Corporation.
5 * Copyright (c) 2007, XenSource Inc.
6 * Copyright (c) 2007, Isaku Yamahata <yamahata at valinux co jp>
7 * VA Linux Systems Japan K.K.
8 * split x86 specific part
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms and conditions of the GNU General Public License,
12 * version 2, as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 * Place - Suite 330, Boston, MA 02111-1307 USA.
22 */
24 #include <asm/hvm/support.h>
25 #include <public/hvm/save.h>
27 void arch_hvm_save(struct domain *d, struct hvm_save_header *hdr)
28 {
29 uint32_t eax, ebx, ecx, edx;
31 /* Save some CPUID bits */
32 cpuid(1, &eax, &ebx, &ecx, &edx);
33 hdr->cpuid = eax;
35 /* Save guest's preferred TSC. */
36 hdr->gtsc_khz = d->arch.hvm_domain.gtsc_khz;
37 }
39 int arch_hvm_load(struct domain *d, struct hvm_save_header *hdr)
40 {
41 uint32_t eax, ebx, ecx, edx;
43 if ( hdr->magic != HVM_FILE_MAGIC )
44 {
45 gdprintk(XENLOG_ERR,
46 "HVM restore: bad magic number %#"PRIx32"\n", hdr->magic);
47 return -1;
48 }
50 if ( hdr->version != HVM_FILE_VERSION )
51 {
52 gdprintk(XENLOG_ERR,
53 "HVM restore: unsupported version %u\n", hdr->version);
54 return -1;
55 }
57 cpuid(1, &eax, &ebx, &ecx, &edx);
58 /* TODO: need to define how big a difference is acceptable? */
59 if ( hdr->cpuid != eax )
60 gdprintk(XENLOG_WARNING, "HVM restore: saved CPUID (%#"PRIx32") "
61 "does not match host (%#"PRIx32").\n", hdr->cpuid, eax);
63 /* Restore guest's preferred TSC frequency. */
64 d->arch.hvm_domain.gtsc_khz = hdr->gtsc_khz;
66 if ( hdr->gtsc_khz && hvm_gtsc_need_scale(d) )
67 {
68 hvm_enable_rdtsc_exiting(d);
69 gdprintk(XENLOG_WARNING, "Domain %d expects freq %uMHz "
70 "but host's freq is %luMHz: trap and emulate rdtsc\n",
71 d->domain_id, hdr->gtsc_khz / 1000, opt_softtsc ? 1000ul :
72 cpu_khz / 1000);
73 }
75 /* VGA state is not saved/restored, so we nobble the cache. */
76 d->arch.hvm_domain.stdvga.cache = 0;
78 return 0;
79 }
81 /*
82 * Local variables:
83 * mode: C
84 * c-set-style: "BSD"
85 * c-basic-offset: 4
86 * tab-width: 4
87 * indent-tabs-mode: nil
88 * End:
89 */