aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/hvm/i8254.c
diff options
context:
space:
mode:
authorTim Deegan <Tim.Deegan@xensource.com>2007-01-31 10:27:10 +0000
committerTim Deegan <Tim.Deegan@xensource.com>2007-01-31 10:27:10 +0000
commit674ccf326621592d655c3137cb2799a815857c58 (patch)
tree4001252fea388d4e27db25a2cab94b974b78be61 /xen/arch/x86/hvm/i8254.c
parentff0b3cef8ddd22fa2cce178c2bc894a966f8a0bb (diff)
downloadxen-674ccf326621592d655c3137cb2799a815857c58.tar.gz
xen-674ccf326621592d655c3137cb2799a815857c58.tar.bz2
xen-674ccf326621592d655c3137cb2799a815857c58.zip
[HVM] Save/restore: clean up marshalling code
- All entries are now defined as structs and saved/restored in self-contained operations. - Save/restore operations are type-safe, to tie each entry's typecode to a particular struct and its length. - Save/restore handlers are registered once per host instead of per domain. - Detect buffer overrun before it happens and abort. Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
Diffstat (limited to 'xen/arch/x86/hvm/i8254.c')
-rw-r--r--xen/arch/x86/hvm/i8254.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/xen/arch/x86/hvm/i8254.c b/xen/arch/x86/hvm/i8254.c
index 2fe8ad5f5f..5473f914f4 100644
--- a/xen/arch/x86/hvm/i8254.c
+++ b/xen/arch/x86/hvm/i8254.c
@@ -411,28 +411,24 @@ static void pit_info(PITState *pit)
}
#endif
-static void pit_save(hvm_domain_context_t *h, void *opaque)
+static int pit_save(struct domain *d, hvm_domain_context_t *h)
{
- struct domain *d = opaque;
PITState *pit = &d->arch.hvm_domain.pl_time.vpit;
pit_info(pit);
/* Save the PIT hardware state */
- hvm_put_struct(h, &pit->hw);
+ return hvm_save_entry(PIT, 0, h, &pit->hw);
}
-static int pit_load(hvm_domain_context_t *h, void *opaque, int version_id)
+static int pit_load(struct domain *d, hvm_domain_context_t *h)
{
- struct domain *d = opaque;
PITState *pit = &d->arch.hvm_domain.pl_time.vpit;
int i;
- if (version_id != 1)
- return -EINVAL;
-
/* Restore the PIT hardware state */
- hvm_get_struct(h, &pit->hw);
+ if ( hvm_load_entry(PIT, h, &pit->hw) )
+ return 1;
/* Recreate platform timers from hardware state. There will be some
* time jitter here, but the wall-clock will have jumped massively, so
@@ -447,6 +443,8 @@ static int pit_load(hvm_domain_context_t *h, void *opaque, int version_id)
return 0;
}
+HVM_REGISTER_SAVE_RESTORE(PIT, pit_save, pit_load);
+
static void pit_reset(void *opaque)
{
PITState *pit = opaque;
@@ -474,7 +472,6 @@ void pit_init(struct vcpu *v, unsigned long cpu_khz)
pt++; pt->vcpu = v;
pt++; pt->vcpu = v;
- hvm_register_savevm(v->domain, "xen_hvm_i8254", PIT_BASE, 1, pit_save, pit_load, v->domain);
register_portio_handler(v->domain, PIT_BASE, 4, handle_pit_io);
/* register the speaker port */
register_portio_handler(v->domain, 0x61, 1, handle_speaker_io);