ia64/xen-unstable

changeset 16400:e6acebec04a2

[IA64] vti save-restore: save/restore opt_feature status

Make hvm domain save/restore support opt_feature.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Tue Nov 20 09:21:27 2007 -0700 (2007-11-20)
parents 6fc79cb7934d
children 87afd05bd254
files xen/arch/ia64/vmx/mmio.c xen/include/public/arch-ia64/hvm/save.h
line diff
     1.1 --- a/xen/arch/ia64/vmx/mmio.c	Tue Nov 20 09:14:43 2007 -0700
     1.2 +++ b/xen/arch/ia64/vmx/mmio.c	Tue Nov 20 09:21:27 2007 -0700
     1.3 @@ -37,6 +37,8 @@
     1.4  #include <asm/viosapic.h>
     1.5  #include <asm/vlsapic.h>
     1.6  #include <asm/hvm/vacpi.h>
     1.7 +#include <asm/hvm/support.h>
     1.8 +#include <public/hvm/save.h>
     1.9  
    1.10  #define HVM_BUFFERED_IO_RANGE_NR 1
    1.11  
    1.12 @@ -261,6 +263,76 @@ static inline void set_os_type(VCPU *v, 
    1.13      }
    1.14  }
    1.15  
    1.16 +static void __vmx_identity_mapping_save(int on,
    1.17 +        const struct identity_mapping* im,
    1.18 +        struct hvm_hw_ia64_identity_mapping *im_save)
    1.19 +{
    1.20 +    im_save->on = !!on;
    1.21 +    if (!on) {
    1.22 +        im_save->pgprot = 0;
    1.23 +        im_save->key    = 0;
    1.24 +    } else {
    1.25 +        im_save->pgprot = im->pgprot;
    1.26 +        im_save->key    = im->key;
    1.27 +    }
    1.28 +}
    1.29 +
    1.30 +static int vmx_identity_mappings_save(struct domain *d,
    1.31 +                                      hvm_domain_context_t *h)
    1.32 +{
    1.33 +    const struct opt_feature *optf = &d->arch.opt_feature;
    1.34 +    struct hvm_hw_ia64_identity_mappings im_save;
    1.35 +
    1.36 +    __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG4,
    1.37 +                                &optf->im_reg4, &im_save.im_reg4);
    1.38 +    __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG5,
    1.39 +                                &optf->im_reg5, &im_save.im_reg5);
    1.40 +    __vmx_identity_mapping_save(optf->mask & XEN_IA64_OPTF_IDENT_MAP_REG7,
    1.41 +                                &optf->im_reg7, &im_save.im_reg7);
    1.42 +
    1.43 +    return hvm_save_entry(OPT_FEATURE_IDENTITY_MAPPINGS, 0, h, &im_save);
    1.44 +}
    1.45 +
    1.46 +static int __vmx_identity_mapping_load(struct domain *d, unsigned long cmd,
    1.47 +        const struct hvm_hw_ia64_identity_mapping *im_load)
    1.48 +{
    1.49 +    struct xen_ia64_opt_feature optf;
    1.50 +
    1.51 +    optf.cmd    = cmd;
    1.52 +    optf.on     = im_load->on;
    1.53 +    optf.pgprot = im_load->pgprot;
    1.54 +    optf.key    = im_load->key;
    1.55 +
    1.56 +    return domain_opt_feature(d, &optf);
    1.57 +}
    1.58 +
    1.59 +static int vmx_identity_mappings_load(struct domain *d,
    1.60 +                                      hvm_domain_context_t *h)
    1.61 +{
    1.62 +    struct hvm_hw_ia64_identity_mappings im_load;
    1.63 +    int rc;
    1.64 +
    1.65 +    if (hvm_load_entry(OPT_FEATURE_IDENTITY_MAPPINGS, h, &im_load))
    1.66 +        return -EINVAL;
    1.67 +
    1.68 +    rc = __vmx_identity_mapping_load(d, XEN_IA64_OPTF_IDENT_MAP_REG4,
    1.69 +                                     &im_load.im_reg4);
    1.70 +    if (rc)
    1.71 +        return rc;
    1.72 +    rc = __vmx_identity_mapping_load(d, XEN_IA64_OPTF_IDENT_MAP_REG5,
    1.73 +                                     &im_load.im_reg5);
    1.74 +    if (rc)
    1.75 +        return rc;
    1.76 +    rc = __vmx_identity_mapping_load(d, XEN_IA64_OPTF_IDENT_MAP_REG7,
    1.77 +                                     &im_load.im_reg7);
    1.78 +
    1.79 +    return rc;
    1.80 +}
    1.81 +
    1.82 +HVM_REGISTER_SAVE_RESTORE(OPT_FEATURE_IDENTITY_MAPPINGS, 
    1.83 +                          vmx_identity_mappings_save,
    1.84 +                          vmx_identity_mappings_load,
    1.85 +                          1, HVMSR_PER_DOM);
    1.86  
    1.87  static void legacy_io_access(VCPU *vcpu, u64 pa, u64 *val, size_t s, int dir)
    1.88  {
     2.1 --- a/xen/include/public/arch-ia64/hvm/save.h	Tue Nov 20 09:14:43 2007 -0700
     2.2 +++ b/xen/include/public/arch-ia64/hvm/save.h	Tue Nov 20 09:21:27 2007 -0700
     2.3 @@ -162,25 +162,35 @@ struct hvm_hw_ia64_vacpi {
     2.4  };
     2.5  DECLARE_HVM_SAVE_TYPE(VACPI, 7, struct hvm_hw_ia64_vacpi);
     2.6  // update last_gtime and setup timer of struct vacpi
     2.7 -#endif
     2.8  
     2.9 -#if 0
    2.10  /*
    2.11 - * guest os type
    2.12 - * XXX Xen guest os specific optimization
    2.13 - *     This isn't hvm specific so this should be addressed genericly
    2.14 - *     including paravirtualized domain.
    2.15 + * opt_feature: identity mapping of region 4, 5 and 7.
    2.16 + * With the c/s 16396:d2935f9c217f of xen-ia64-devel.hg,
    2.17 + * opt_feature hypercall supports only region 4,5,7 identity mappings.
    2.18 + * structure hvm_hw_ia64_identity_mappings only supports them.
    2.19 + * The new structure, struct hvm_hw_ia64_identity_mappings, is created to
    2.20 + * avoid to keep up with change of the xen/ia64 internal structure, struct
    2.21 + * opt_feature.
    2.22 + *
    2.23 + * If it is enhanced in the future, new structure will be created.
    2.24   */
    2.25 -struct hvm_hw_ia64_gos {
    2.26 -    uint64_t	gos_type;
    2.27 +struct hvm_hw_ia64_identity_mapping {
    2.28 +    uint64_t on;        /* on/off */
    2.29 +    uint64_t pgprot;    /* The page protection bit mask of the pte. */
    2.30 +    uint64_t key;       /* A protection key. */
    2.31  };
    2.32 -DECLARE_HVM_SAVE_TYPE(GOS_TYPE, 8, struct hvm_hw_ia64_gos);
    2.33 -#endif
    2.34 +
    2.35 +struct hvm_hw_ia64_identity_mappings {
    2.36 +    struct hvm_hw_ia64_identity_mapping im_reg4;/* Region 4 identity mapping */
    2.37 +    struct hvm_hw_ia64_identity_mapping im_reg5;/* Region 5 identity mapping */
    2.38 +    struct hvm_hw_ia64_identity_mapping im_reg7;/* Region 7 identity mapping */
    2.39 +};
    2.40 +DECLARE_HVM_SAVE_TYPE(OPT_FEATURE_IDENTITY_MAPPINGS, 8, struct hvm_hw_ia64_identity_mappings);
    2.41  
    2.42  /* 
    2.43   * Largest type-code in use
    2.44   */
    2.45 -#define HVM_SAVE_CODE_MAX       7
    2.46 +#define HVM_SAVE_CODE_MAX       8
    2.47  
    2.48  #endif /* __XEN_PUBLIC_HVM_SAVE_IA64_H__ */
    2.49