### vPMU
-Virtual Performance Management Unit for HVM guests
+Virtual Performance Management Unit
- Status, x86: Supported, Not security supported
+ Status, x86 HVM: Supported, Not security supported
+ Status, ARM: Experimental
+
+On ARM, support for accessing PMU registers from the guests.
+There is no interrupt support and Xen will not save/restore
+the register values on context switches.
+
+Disabled by default.
+On ARM, enable with guest parameter.
+On x86, enable with hypervisor command line option.
-Disabled by default (enable with hypervisor command line option).
This feature is not security supported: see https://xenbits.xen.org/xsa/advisory-163.html
### Argo: Inter-domain message delivery by hypercall
B<NOTE>: Acceptable values are platform specific. For Intel Processor
Trace, this value must be a power of 2 between 4k and 16M.
+=item B<vpmu=BOOLEAN>
+
+Currently ARM only.
+
+Specifies whether to enable the access to PMU registers by disabling
+the PMU traps.
+
+The PMU registers are not virtualized and the physical registers are directly
+accessible when this parameter is enabled. There is no interrupt support and
+Xen will not save/restore the register values on context switches.
+
+vPMU, by design and purpose, exposes system level performance
+information to the guest. Only to be used by sufficiently privileged
+domains. This feature is currently in experimental state.
+
+If this option is not specified then it will default to B<false>.
+
=back
=head2 Devices
}
x.Altp2M = Altp2MMode(xc.altp2m)
x.VmtraceBufKb = int(xc.vmtrace_buf_kb)
+if err := x.Vpmu.fromC(&xc.vpmu);err != nil {
+return fmt.Errorf("converting field Vpmu: %v", err)
+}
return nil}
}
xc.altp2m = C.libxl_altp2m_mode(x.Altp2M)
xc.vmtrace_buf_kb = C.int(x.VmtraceBufKb)
+if err := x.Vpmu.toC(&xc.vpmu); err != nil {
+return fmt.Errorf("converting field Vpmu: %v", err)
+}
return nil
}
}
Altp2M Altp2MMode
VmtraceBufKb int
+Vpmu Defbool
}
type DomainBuildInfoTypeUnion interface {
*/
#define LIBXL_HAVE_PHYSINFO_CAP_VPMU 1
+/*
+ * LIBXL_HAVE_VPMU indicates that libxl_domain_build_info has a vpmu parameter,
+ * which allows to enable the access to PMU registers.
+ */
+#define LIBXL_HAVE_VPMU 1
+
/*
* libxl ABI compatibility
*
}
libxl_defbool_setdefault(&b_info->device_model_stubdomain, false);
+ libxl_defbool_setdefault(&b_info->vpmu, false);
if (libxl_defbool_val(b_info->device_model_stubdomain) &&
!b_info->device_model_ssidref)
create.flags |= XEN_DOMCTL_CDF_nested_virt;
}
+ if (libxl_defbool_val(b_info->vpmu))
+ create.flags |= XEN_DOMCTL_CDF_vpmu;
+
assert(info->passthrough != LIBXL_PASSTHROUGH_DEFAULT);
LOG(DETAIL, "passthrough: %s",
libxl_passthrough_to_string(info->passthrough));
goto error_out;
}
+ if (libxl_defbool_val(d_config->b_info.vpmu) && !physinfo.cap_vpmu) {
+ ret = ERROR_INVAL;
+ LOGD(ERROR, domid, "vPMU not supported on this platform");
+ goto error_out;
+ }
+
ret = 0;
error_out:
return ret;
# Use zero value to disable this feature.
("vmtrace_buf_kb", integer),
+ ("vpmu", libxl_defbool),
+
], dir=DIR_IN,
copy_deprecated_fn="libxl__domain_build_info_copy_deprecated",
)
| CDF_IOMMU
| CDF_NESTED_VIRT
| CDF_VPCI
+ | CDF_VPMU
type domain_create_iommu_opts =
| IOMMU_NO_SHAREPT
| CDF_IOMMU
| CDF_NESTED_VIRT
| CDF_VPCI
+ | CDF_VPMU
type domain_create_iommu_opts =
| IOMMU_NO_SHAREPT
"If it fixes an issue you are having please report to "
"xen-devel@lists.xenproject.org.\n");
+ xlu_cfg_get_defbool(config, "vpmu", &b_info->vpmu, 0);
+
xlu_cfg_destroy(config);
}
* timer. The interrupt needs to be injected into the guest. */
WRITE_SYSREG(n->arch.cntkctl, CNTKCTL_EL1);
virt_timer_restore(n);
+
+ WRITE_SYSREG(n->arch.mdcr_el2, MDCR_EL2);
}
/* Update per-VCPU guest runstate shared memory area (if registered). */
v->arch.hcr_el2 = get_default_hcr_flags();
+ v->arch.mdcr_el2 = HDCR_TDRA | HDCR_TDOSA | HDCR_TDA;
+ if ( !(v->domain->options & XEN_DOMCTL_CDF_vpmu) )
+ v->arch.mdcr_el2 |= HDCR_TPM | HDCR_TPMCR;
+
if ( (rc = vcpu_vgic_init(v)) != 0 )
goto fail;
int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
{
unsigned int max_vcpus;
+ unsigned int flags_required = (XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap);
+ unsigned int flags_optional = (XEN_DOMCTL_CDF_iommu | XEN_DOMCTL_CDF_vpci |
+ XEN_DOMCTL_CDF_vpmu);
- /* HVM and HAP must be set. IOMMU and VPCI may or may not be */
- if ( (config->flags & ~XEN_DOMCTL_CDF_iommu & ~XEN_DOMCTL_CDF_vpci) !=
- (XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap) )
+ if ( (config->flags & ~flags_optional) != flags_required )
{
dprintk(XENLOG_INFO, "Unsupported configuration %#x\n",
config->flags);
printk("Brought up %ld CPUs\n", (long)num_online_cpus());
/* TODO: smp_cpus_done(); */
+ /* This should be done in a vpmu driver but we do not have one yet. */
+ vpmu_is_available = cpu_has_pmu;
+
/*
* The IOMMU subsystem must be initialized before P2M as we need
* to gather requirements regarding the maximum IPA bits supported by
bool hvm = config->flags & XEN_DOMCTL_CDF_hvm;
bool hap = config->flags & XEN_DOMCTL_CDF_hap;
bool iommu = config->flags & XEN_DOMCTL_CDF_iommu;
+ bool vpmu = config->flags & XEN_DOMCTL_CDF_vpmu;
if ( config->flags &
~(XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap |
XEN_DOMCTL_CDF_s3_integrity | XEN_DOMCTL_CDF_oos_off |
XEN_DOMCTL_CDF_xs_domain | XEN_DOMCTL_CDF_iommu |
- XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpci) )
+ XEN_DOMCTL_CDF_nested_virt | XEN_DOMCTL_CDF_vpci |
+ XEN_DOMCTL_CDF_vpmu) )
{
dprintk(XENLOG_INFO, "Unknown CDF flags %#x\n", config->flags);
return -EINVAL;
return -EINVAL;
}
+ if ( vpmu && !vpmu_is_available )
+ {
+ dprintk(XENLOG_INFO, "vpmu requested but cannot be enabled this way\n");
+ return -EINVAL;
+ }
+
return arch_sanitise_domain_config(config);
}
/* HYP configuration */
register_t hcr_el2;
+ register_t mdcr_el2;
uint32_t teecr, teehbr; /* ThumbEE, 32-bit guests only */
#ifdef CONFIG_ARM_32
#define _XEN_DOMCTL_CDF_nested_virt 6
#define XEN_DOMCTL_CDF_nested_virt (1U << _XEN_DOMCTL_CDF_nested_virt)
#define XEN_DOMCTL_CDF_vpci (1U << 7)
+/* Should we expose the vPMU to the guest? */
+#define XEN_DOMCTL_CDF_vpmu (1U << 8)
/* Max XEN_DOMCTL_CDF_* constant. Used for ABI checking. */
-#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_vpci
+#define XEN_DOMCTL_CDF_MAX XEN_DOMCTL_CDF_vpmu
uint32_t flags;