# HG changeset patch # User yamahata@xxxxxxxxxxxxx # Date 1195554243 -32400 # Node ID 07e7930a8faf2cbd260aad7ff7e2b0bb32c18195 # Parent c886374409acdddcf38d428f115faab65489df19 make hvm domain save/resote supports opt_feature. PATCHNAME: hvm_save_restore_opt_feature Signed-off-by: Isaku Yamahata diff -r c886374409ac -r 07e7930a8faf xen/arch/ia64/vmx/mmio.c --- a/xen/arch/ia64/vmx/mmio.c Tue Nov 20 18:41:47 2007 +0900 +++ b/xen/arch/ia64/vmx/mmio.c Tue Nov 20 19:24:03 2007 +0900 @@ -37,6 +37,8 @@ #include #include #include +#include +#include #define HVM_BUFFERED_IO_RANGE_NR 1 @@ -261,6 +263,76 @@ static inline void set_os_type(VCPU *v, } } +static void __vmx_identity_mapping_save(int on, + const struct identity_mapping* im, + struct hvm_hw_ia64_identity_mapping *im_save) +{ + im_save->on = !!on; + if (!on) { + im_save->pgprot = 0; + im_save->key = 0; + } else { + im_save->pgprot = im->pgprot; + im_save->key = im->key; + } +} + +static int vmx_identity_mappings_save(struct domain *d, + hvm_domain_context_t *h) +{ + const struct opt_feature *optf = &d->arch.opt_feature; + struct hvm_hw_ia64_identity_mappings im_save; + + __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4, + &optf->im_reg4, &im_save.im_reg4); + __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5, + &optf->im_reg5, &im_save.im_reg5); + __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7, + &optf->im_reg7, &im_save.im_reg7); + + return hvm_save_entry(OPT_FEATURE_IDENTITY_MAPPINGS, 0, h, &im_save); +} + +static int __vmx_identity_mapping_load(struct domain *d, unsigned long cmd, + const struct hvm_hw_ia64_identity_mapping *im_load) +{ + struct xen_ia64_opt_feature optf; + + optf.cmd = cmd; + optf.on = im_load->on; + optf.pgprot = im_load->pgprot; + optf.key = im_load->key; + + return domain_opt_feature(d, &optf); +} + +static int vmx_identity_mappings_load(struct domain *d, + hvm_domain_context_t *h) +{ + struct hvm_hw_ia64_identity_mappings im_load; + int rc; + + if (hvm_load_entry(OPT_FEATURE_IDENTITY_MAPPINGS, h, &im_load)) + return -EINVAL; + + rc = __vmx_identity_mapping_load(d, XEN_IA64_OPTF_IDENT_MAP_REG4, + &im_load.im_reg4); + if (rc) + return rc; + rc = __vmx_identity_mapping_load(d, XEN_IA64_OPTF_IDENT_MAP_REG5, + &im_load.im_reg5); + if (rc) + return rc; + rc = __vmx_identity_mapping_load(d, XEN_IA64_OPTF_IDENT_MAP_REG7, + &im_load.im_reg7); + + return rc; +} + +HVM_REGISTER_SAVE_RESTORE(OPT_FEATURE_IDENTITY_MAPPINGS, + vmx_identity_mappings_save, + vmx_identity_mappings_load, + 1, HVMSR_PER_DOM); static void legacy_io_access(VCPU *vcpu, u64 pa, u64 *val, size_t s, int dir) { diff -r c886374409ac -r 07e7930a8faf xen/include/public/arch-ia64/hvm/save.h --- a/xen/include/public/arch-ia64/hvm/save.h Tue Nov 20 18:41:47 2007 +0900 +++ b/xen/include/public/arch-ia64/hvm/save.h Tue Nov 20 19:24:03 2007 +0900 @@ -162,25 +162,35 @@ struct hvm_hw_ia64_vacpi { }; DECLARE_HVM_SAVE_TYPE(VACPI, 7, struct hvm_hw_ia64_vacpi); // update last_gtime and setup timer of struct vacpi -#endif - -#if 0 -/* - * guest os type - * XXX Xen guest os specific optimization - * This isn't hvm specific so this should be addressed genericly - * including paravirtualized domain. - */ -struct hvm_hw_ia64_gos { - uint64_t gos_type; -}; -DECLARE_HVM_SAVE_TYPE(GOS_TYPE, 8, struct hvm_hw_ia64_gos); -#endif + +/* + * opt_feature: identity mapping of region 4, 5 and 7. + * With the c/s 16396:d2935f9c217f of xen-ia64-devel.hg, + * opt_feature hypercall supports only region 4,5,7 identity mappings. + * structure hvm_hw_ia64_identity_mappings only supports them. + * The new structure, struct hvm_hw_ia64_identity_mappings, is created to + * avoid to keep up with change of the xen/ia64 internal structure, struct + * opt_feature. + * + * If it is enhanced in the future, new structure will be created. + */ +struct hvm_hw_ia64_identity_mapping { + uint64_t on; /* on/off */ + uint64_t pgprot; /* The page protection bit mask of the pte. */ + uint64_t key; /* A protection key. */ +}; + +struct hvm_hw_ia64_identity_mappings { + struct hvm_hw_ia64_identity_mapping im_reg4;/* Region 4 identity mapping */ + struct hvm_hw_ia64_identity_mapping im_reg5;/* Region 5 identity mapping */ + struct hvm_hw_ia64_identity_mapping im_reg7;/* Region 7 identity mapping */ +}; +DECLARE_HVM_SAVE_TYPE(OPT_FEATURE_IDENTITY_MAPPINGS, 8, struct hvm_hw_ia64_identity_mappings); /* * Largest type-code in use */ -#define HVM_SAVE_CODE_MAX 7 +#define HVM_SAVE_CODE_MAX 8 #endif /* __XEN_PUBLIC_HVM_SAVE_IA64_H__ */