similarity index 67%
rename from Documentation/ABI/testing/sysfs-hypervisor-pmu
rename to Documentation/ABI/testing/sysfs-hypervisor-xen
@@ -1,8 +1,19 @@
+What: /sys/hypervisor/guest_type
+Date: May 2017
+KernelVersion: 4.13
+Contact: xen-devel@lists.xenproject.org
+Description: If running under Xen:
+ Type of guest:
+ "Xen": standard guest type on arm
+ "HVM": fully virtualized guest (x86)
+ "PV": paravirtualized guest (x86)
+ "PVH": fully virtualized guest without legacy emulation (x86)
+
What: /sys/hypervisor/pmu/pmu_mode
Date: August 2015
KernelVersion: 4.3
Contact: Boris Ostrovsky <boris.ostrovsky@oracle.com>
-Description:
+Description: If running under Xen:
Describes mode that Xen's performance-monitoring unit (PMU)
uses. Accepted values are
"off" -- PMU is disabled
@@ -17,7 +28,7 @@ What: /sys/hypervisor/pmu/pmu_features
Date: August 2015
KernelVersion: 4.3
Contact: Boris Ostrovsky <boris.ostrovsky@oracle.com>
-Description:
+Description: If running under Xen:
Describes Xen PMU features (as an integer). A set bit indicates
that the corresponding feature is enabled. See
include/xen/interface/xenpmu.h for available features
@@ -13984,7 +13984,7 @@ F: arch/x86/include/asm/xen/
F: include/xen/
F: include/uapi/xen/
F: Documentation/ABI/stable/sysfs-hypervisor-xen
-F: Documentation/ABI/testing/sysfs-hypervisor-pmu
+F: Documentation/ABI/testing/sysfs-hypervisor-xen
XEN HYPERVISOR ARM
M: Stefano Stabellini <sstabellini@kernel.org>
@@ -43,6 +43,9 @@ EXPORT_SYMBOL(xen_start_info);
enum xen_domain_type xen_domain_type = XEN_NATIVE;
EXPORT_SYMBOL(xen_domain_type);
+const char *xen_guest_type = "Xen";
+EXPORT_SYMBOL_GPL(xen_guest_type);
+
struct shared_info xen_dummy_shared_info;
struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info;
@@ -47,6 +47,9 @@ EXPORT_PER_CPU_SYMBOL(xen_vcpu_id);
enum xen_domain_type xen_domain_type = XEN_NATIVE;
EXPORT_SYMBOL_GPL(xen_domain_type);
+const char *xen_guest_type = "HVM";
+EXPORT_SYMBOL_GPL(xen_guest_type);
+
unsigned long *machine_to_phys_mapping = (void *)MACH2PHYS_VIRT_START;
EXPORT_SYMBOL(machine_to_phys_mapping);
unsigned long machine_to_phys_nr;
@@ -68,9 +68,10 @@ static void __init init_hvm_pv_info(void)
xen_domain_type = XEN_HVM_DOMAIN;
/* PVH set up hypercall page in xen_prepare_pvh(). */
- if (xen_pvh_domain())
+ if (xen_pvh_domain()) {
pv_info.name = "Xen PVH";
- else {
+ xen_guest_type = "PVH";
+ } else {
u64 pfn;
uint32_t msr;
@@ -1255,6 +1255,7 @@ asmlinkage __visible void __init xen_start_kernel(void)
return;
xen_domain_type = XEN_PV_DOMAIN;
+ xen_guest_type = "PV";
xen_setup_features();
@@ -50,6 +50,18 @@ static int __init xen_sysfs_type_init(void)
return sysfs_create_file(hypervisor_kobj, &type_attr.attr);
}
+static ssize_t guest_type_show(struct hyp_sysfs_attr *attr, char *buffer)
+{
+ return sprintf(buffer, "%s\n", xen_guest_type);
+}
+
+HYPERVISOR_ATTR_RO(guest_type);
+
+static int __init xen_sysfs_guest_type_init(void)
+{
+ return sysfs_create_file(hypervisor_kobj, &guest_type_attr.attr);
+}
+
/* xen version attributes */
static ssize_t major_show(struct hyp_sysfs_attr *attr, char *buffer)
{
@@ -471,6 +483,9 @@ static int __init hyper_sysfs_init(void)
ret = xen_sysfs_type_init();
if (ret)
goto out;
+ ret = xen_sysfs_guest_type_init();
+ if (ret)
+ goto guest_type_out;
ret = xen_sysfs_version_init();
if (ret)
goto version_out;
@@ -502,6 +517,8 @@ static int __init hyper_sysfs_init(void)
comp_out:
sysfs_remove_group(hypervisor_kobj, &version_group);
version_out:
+ sysfs_remove_file(hypervisor_kobj, &guest_type_attr.attr);
+guest_type_out:
sysfs_remove_file(hypervisor_kobj, &type_attr.attr);
out:
return ret;
@@ -9,8 +9,10 @@ enum xen_domain_type {
#ifdef CONFIG_XEN
extern enum xen_domain_type xen_domain_type;
+extern const char *xen_guest_type;
#else
#define xen_domain_type XEN_NATIVE
+#define xen_guest_type "native"
#endif
#define xen_domain() (xen_domain_type != XEN_NATIVE)
Currently there is no reliable user interface inside a Xen guest to determine its type (e.g. HVM, PV or PVH). Instead of letting user mode try to determine this by various rather hacky mechanisms (parsing of boot messages before they are gone, trying to make use of known subtle differences in behavior of some instructions), add a sysfs node /sys/hypervisor/guest_type to explicitly deliver this information as it is known to the kernel. Signed-off-by: Juergen Gross <jgross@suse.com> --- V2: - remove PVHVM guest type (Andrew Cooper) - move description to Documentation/ABI/testing/sysfs-hypervisor-xen (Boris Ostrovsky) - make xen_guest_type const char * (Jan Beulich) - modify standard ARM guest type to "Xen" --- .../{sysfs-hypervisor-pmu => sysfs-hypervisor-xen} | 15 +++++++++++++-- MAINTAINERS | 2 +- arch/arm/xen/enlighten.c | 3 +++ arch/x86/xen/enlighten.c | 3 +++ arch/x86/xen/enlighten_hvm.c | 5 +++-- arch/x86/xen/enlighten_pv.c | 1 + drivers/xen/sys-hypervisor.c | 17 +++++++++++++++++ include/xen/xen.h | 2 ++ 8 files changed, 43 insertions(+), 5 deletions(-) rename Documentation/ABI/testing/{sysfs-hypervisor-pmu => sysfs-hypervisor-xen} (67%)