1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2cff7e81bSJeremy Fitzhardinge /*
3cff7e81bSJeremy Fitzhardinge * copyright (c) 2006 IBM Corporation
4cff7e81bSJeremy Fitzhardinge * Authored by: Mike D. Day <ncmike@us.ibm.com>
5cff7e81bSJeremy Fitzhardinge */
6cff7e81bSJeremy Fitzhardinge
75a0e3ad6STejun Heo #include <linux/slab.h>
8cff7e81bSJeremy Fitzhardinge #include <linux/kernel.h>
946894f17SPaul Gortmaker #include <linux/init.h>
10cff7e81bSJeremy Fitzhardinge #include <linux/kobject.h>
11609b0b8cSIan Campbell #include <linux/err.h>
12cff7e81bSJeremy Fitzhardinge
13cff7e81bSJeremy Fitzhardinge #include <asm/xen/hypervisor.h>
14cff7e81bSJeremy Fitzhardinge #include <asm/xen/hypercall.h>
15cff7e81bSJeremy Fitzhardinge
161ccbf534SJeremy Fitzhardinge #include <xen/xen.h>
17cff7e81bSJeremy Fitzhardinge #include <xen/xenbus.h>
18cff7e81bSJeremy Fitzhardinge #include <xen/interface/xen.h>
19cff7e81bSJeremy Fitzhardinge #include <xen/interface/version.h>
205f141548SBoris Ostrovsky #ifdef CONFIG_XEN_HAVE_VPMU
215f141548SBoris Ostrovsky #include <xen/interface/xenpmu.h>
225f141548SBoris Ostrovsky #endif
23cff7e81bSJeremy Fitzhardinge
24cff7e81bSJeremy Fitzhardinge #define HYPERVISOR_ATTR_RO(_name) \
25cff7e81bSJeremy Fitzhardinge static struct hyp_sysfs_attr _name##_attr = __ATTR_RO(_name)
26cff7e81bSJeremy Fitzhardinge
27cff7e81bSJeremy Fitzhardinge #define HYPERVISOR_ATTR_RW(_name) \
28982e4430Szhanglianjie static struct hyp_sysfs_attr _name##_attr = __ATTR_RW(_name)
29cff7e81bSJeremy Fitzhardinge
30cff7e81bSJeremy Fitzhardinge struct hyp_sysfs_attr {
31cff7e81bSJeremy Fitzhardinge struct attribute attr;
32cff7e81bSJeremy Fitzhardinge ssize_t (*show)(struct hyp_sysfs_attr *, char *);
33cff7e81bSJeremy Fitzhardinge ssize_t (*store)(struct hyp_sysfs_attr *, const char *, size_t);
34415dab3cSPer Bilse union {
35cff7e81bSJeremy Fitzhardinge void *hyp_attr_data;
36415dab3cSPer Bilse unsigned long hyp_attr_value;
37415dab3cSPer Bilse };
38cff7e81bSJeremy Fitzhardinge };
39cff7e81bSJeremy Fitzhardinge
type_show(struct hyp_sysfs_attr * attr,char * buffer)40cff7e81bSJeremy Fitzhardinge static ssize_t type_show(struct hyp_sysfs_attr *attr, char *buffer)
41cff7e81bSJeremy Fitzhardinge {
42cff7e81bSJeremy Fitzhardinge return sprintf(buffer, "xen\n");
43cff7e81bSJeremy Fitzhardinge }
44cff7e81bSJeremy Fitzhardinge
45cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(type);
46cff7e81bSJeremy Fitzhardinge
xen_sysfs_type_init(void)47cff7e81bSJeremy Fitzhardinge static int __init xen_sysfs_type_init(void)
48cff7e81bSJeremy Fitzhardinge {
49cff7e81bSJeremy Fitzhardinge return sysfs_create_file(hypervisor_kobj, &type_attr.attr);
50cff7e81bSJeremy Fitzhardinge }
51cff7e81bSJeremy Fitzhardinge
guest_type_show(struct hyp_sysfs_attr * attr,char * buffer)524a4c29c9SJuergen Gross static ssize_t guest_type_show(struct hyp_sysfs_attr *attr, char *buffer)
534a4c29c9SJuergen Gross {
544a4c29c9SJuergen Gross const char *type;
554a4c29c9SJuergen Gross
564a4c29c9SJuergen Gross switch (xen_domain_type) {
574a4c29c9SJuergen Gross case XEN_NATIVE:
584a4c29c9SJuergen Gross /* ARM only. */
594a4c29c9SJuergen Gross type = "Xen";
604a4c29c9SJuergen Gross break;
614a4c29c9SJuergen Gross case XEN_PV_DOMAIN:
624a4c29c9SJuergen Gross type = "PV";
634a4c29c9SJuergen Gross break;
644a4c29c9SJuergen Gross case XEN_HVM_DOMAIN:
654a4c29c9SJuergen Gross type = xen_pvh_domain() ? "PVH" : "HVM";
664a4c29c9SJuergen Gross break;
674a4c29c9SJuergen Gross default:
684a4c29c9SJuergen Gross return -EINVAL;
694a4c29c9SJuergen Gross }
704a4c29c9SJuergen Gross
714a4c29c9SJuergen Gross return sprintf(buffer, "%s\n", type);
724a4c29c9SJuergen Gross }
734a4c29c9SJuergen Gross
744a4c29c9SJuergen Gross HYPERVISOR_ATTR_RO(guest_type);
754a4c29c9SJuergen Gross
xen_sysfs_guest_type_init(void)764a4c29c9SJuergen Gross static int __init xen_sysfs_guest_type_init(void)
774a4c29c9SJuergen Gross {
784a4c29c9SJuergen Gross return sysfs_create_file(hypervisor_kobj, &guest_type_attr.attr);
794a4c29c9SJuergen Gross }
804a4c29c9SJuergen Gross
81cff7e81bSJeremy Fitzhardinge /* xen version attributes */
major_show(struct hyp_sysfs_attr * attr,char * buffer)82cff7e81bSJeremy Fitzhardinge static ssize_t major_show(struct hyp_sysfs_attr *attr, char *buffer)
83cff7e81bSJeremy Fitzhardinge {
84cff7e81bSJeremy Fitzhardinge int version = HYPERVISOR_xen_version(XENVER_version, NULL);
85cff7e81bSJeremy Fitzhardinge if (version)
86cff7e81bSJeremy Fitzhardinge return sprintf(buffer, "%d\n", version >> 16);
87cff7e81bSJeremy Fitzhardinge return -ENODEV;
88cff7e81bSJeremy Fitzhardinge }
89cff7e81bSJeremy Fitzhardinge
90cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(major);
91cff7e81bSJeremy Fitzhardinge
minor_show(struct hyp_sysfs_attr * attr,char * buffer)92cff7e81bSJeremy Fitzhardinge static ssize_t minor_show(struct hyp_sysfs_attr *attr, char *buffer)
93cff7e81bSJeremy Fitzhardinge {
94cff7e81bSJeremy Fitzhardinge int version = HYPERVISOR_xen_version(XENVER_version, NULL);
95cff7e81bSJeremy Fitzhardinge if (version)
96cff7e81bSJeremy Fitzhardinge return sprintf(buffer, "%d\n", version & 0xff);
97cff7e81bSJeremy Fitzhardinge return -ENODEV;
98cff7e81bSJeremy Fitzhardinge }
99cff7e81bSJeremy Fitzhardinge
100cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(minor);
101cff7e81bSJeremy Fitzhardinge
extra_show(struct hyp_sysfs_attr * attr,char * buffer)102cff7e81bSJeremy Fitzhardinge static ssize_t extra_show(struct hyp_sysfs_attr *attr, char *buffer)
103cff7e81bSJeremy Fitzhardinge {
104cff7e81bSJeremy Fitzhardinge int ret = -ENOMEM;
105cff7e81bSJeremy Fitzhardinge char *extra;
106cff7e81bSJeremy Fitzhardinge
107cff7e81bSJeremy Fitzhardinge extra = kmalloc(XEN_EXTRAVERSION_LEN, GFP_KERNEL);
108cff7e81bSJeremy Fitzhardinge if (extra) {
109cff7e81bSJeremy Fitzhardinge ret = HYPERVISOR_xen_version(XENVER_extraversion, extra);
110cff7e81bSJeremy Fitzhardinge if (!ret)
111cff7e81bSJeremy Fitzhardinge ret = sprintf(buffer, "%s\n", extra);
112cff7e81bSJeremy Fitzhardinge kfree(extra);
113cff7e81bSJeremy Fitzhardinge }
114cff7e81bSJeremy Fitzhardinge
115cff7e81bSJeremy Fitzhardinge return ret;
116cff7e81bSJeremy Fitzhardinge }
117cff7e81bSJeremy Fitzhardinge
118cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(extra);
119cff7e81bSJeremy Fitzhardinge
120cff7e81bSJeremy Fitzhardinge static struct attribute *version_attrs[] = {
121cff7e81bSJeremy Fitzhardinge &major_attr.attr,
122cff7e81bSJeremy Fitzhardinge &minor_attr.attr,
123cff7e81bSJeremy Fitzhardinge &extra_attr.attr,
124cff7e81bSJeremy Fitzhardinge NULL
125cff7e81bSJeremy Fitzhardinge };
126cff7e81bSJeremy Fitzhardinge
127ead1d014SJan Beulich static const struct attribute_group version_group = {
128cff7e81bSJeremy Fitzhardinge .name = "version",
129cff7e81bSJeremy Fitzhardinge .attrs = version_attrs,
130cff7e81bSJeremy Fitzhardinge };
131cff7e81bSJeremy Fitzhardinge
xen_sysfs_version_init(void)132cff7e81bSJeremy Fitzhardinge static int __init xen_sysfs_version_init(void)
133cff7e81bSJeremy Fitzhardinge {
134cff7e81bSJeremy Fitzhardinge return sysfs_create_group(hypervisor_kobj, &version_group);
135cff7e81bSJeremy Fitzhardinge }
136cff7e81bSJeremy Fitzhardinge
137cff7e81bSJeremy Fitzhardinge /* UUID */
138cff7e81bSJeremy Fitzhardinge
uuid_show_fallback(struct hyp_sysfs_attr * attr,char * buffer)1395c13f806SDaniel De Graaf static ssize_t uuid_show_fallback(struct hyp_sysfs_attr *attr, char *buffer)
140cff7e81bSJeremy Fitzhardinge {
141cff7e81bSJeremy Fitzhardinge char *vm, *val;
142cff7e81bSJeremy Fitzhardinge int ret;
143cff7e81bSJeremy Fitzhardinge extern int xenstored_ready;
144cff7e81bSJeremy Fitzhardinge
145cff7e81bSJeremy Fitzhardinge if (!xenstored_ready)
146cff7e81bSJeremy Fitzhardinge return -EBUSY;
147cff7e81bSJeremy Fitzhardinge
148cff7e81bSJeremy Fitzhardinge vm = xenbus_read(XBT_NIL, "vm", "", NULL);
149cff7e81bSJeremy Fitzhardinge if (IS_ERR(vm))
150cff7e81bSJeremy Fitzhardinge return PTR_ERR(vm);
151cff7e81bSJeremy Fitzhardinge val = xenbus_read(XBT_NIL, vm, "uuid", NULL);
152cff7e81bSJeremy Fitzhardinge kfree(vm);
153cff7e81bSJeremy Fitzhardinge if (IS_ERR(val))
154cff7e81bSJeremy Fitzhardinge return PTR_ERR(val);
155cff7e81bSJeremy Fitzhardinge ret = sprintf(buffer, "%s\n", val);
156cff7e81bSJeremy Fitzhardinge kfree(val);
157cff7e81bSJeremy Fitzhardinge return ret;
158cff7e81bSJeremy Fitzhardinge }
159cff7e81bSJeremy Fitzhardinge
uuid_show(struct hyp_sysfs_attr * attr,char * buffer)1605c13f806SDaniel De Graaf static ssize_t uuid_show(struct hyp_sysfs_attr *attr, char *buffer)
1615c13f806SDaniel De Graaf {
1625c13f806SDaniel De Graaf xen_domain_handle_t uuid;
1635c13f806SDaniel De Graaf int ret;
1645c13f806SDaniel De Graaf ret = HYPERVISOR_xen_version(XENVER_guest_handle, uuid);
1655c13f806SDaniel De Graaf if (ret)
1665c13f806SDaniel De Graaf return uuid_show_fallback(attr, buffer);
1675c13f806SDaniel De Graaf ret = sprintf(buffer, "%pU\n", uuid);
1685c13f806SDaniel De Graaf return ret;
1695c13f806SDaniel De Graaf }
1705c13f806SDaniel De Graaf
171cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(uuid);
172cff7e81bSJeremy Fitzhardinge
xen_sysfs_uuid_init(void)173cff7e81bSJeremy Fitzhardinge static int __init xen_sysfs_uuid_init(void)
174cff7e81bSJeremy Fitzhardinge {
175cff7e81bSJeremy Fitzhardinge return sysfs_create_file(hypervisor_kobj, &uuid_attr.attr);
176cff7e81bSJeremy Fitzhardinge }
177cff7e81bSJeremy Fitzhardinge
178cff7e81bSJeremy Fitzhardinge /* xen compilation attributes */
179cff7e81bSJeremy Fitzhardinge
compiler_show(struct hyp_sysfs_attr * attr,char * buffer)180cff7e81bSJeremy Fitzhardinge static ssize_t compiler_show(struct hyp_sysfs_attr *attr, char *buffer)
181cff7e81bSJeremy Fitzhardinge {
182cff7e81bSJeremy Fitzhardinge int ret = -ENOMEM;
183cff7e81bSJeremy Fitzhardinge struct xen_compile_info *info;
184cff7e81bSJeremy Fitzhardinge
185cff7e81bSJeremy Fitzhardinge info = kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
186cff7e81bSJeremy Fitzhardinge if (info) {
187cff7e81bSJeremy Fitzhardinge ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
188cff7e81bSJeremy Fitzhardinge if (!ret)
189cff7e81bSJeremy Fitzhardinge ret = sprintf(buffer, "%s\n", info->compiler);
190cff7e81bSJeremy Fitzhardinge kfree(info);
191cff7e81bSJeremy Fitzhardinge }
192cff7e81bSJeremy Fitzhardinge
193cff7e81bSJeremy Fitzhardinge return ret;
194cff7e81bSJeremy Fitzhardinge }
195cff7e81bSJeremy Fitzhardinge
196cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(compiler);
197cff7e81bSJeremy Fitzhardinge
compiled_by_show(struct hyp_sysfs_attr * attr,char * buffer)198cff7e81bSJeremy Fitzhardinge static ssize_t compiled_by_show(struct hyp_sysfs_attr *attr, char *buffer)
199cff7e81bSJeremy Fitzhardinge {
200cff7e81bSJeremy Fitzhardinge int ret = -ENOMEM;
201cff7e81bSJeremy Fitzhardinge struct xen_compile_info *info;
202cff7e81bSJeremy Fitzhardinge
203cff7e81bSJeremy Fitzhardinge info = kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
204cff7e81bSJeremy Fitzhardinge if (info) {
205cff7e81bSJeremy Fitzhardinge ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
206cff7e81bSJeremy Fitzhardinge if (!ret)
207cff7e81bSJeremy Fitzhardinge ret = sprintf(buffer, "%s\n", info->compile_by);
208cff7e81bSJeremy Fitzhardinge kfree(info);
209cff7e81bSJeremy Fitzhardinge }
210cff7e81bSJeremy Fitzhardinge
211cff7e81bSJeremy Fitzhardinge return ret;
212cff7e81bSJeremy Fitzhardinge }
213cff7e81bSJeremy Fitzhardinge
214cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(compiled_by);
215cff7e81bSJeremy Fitzhardinge
compile_date_show(struct hyp_sysfs_attr * attr,char * buffer)216cff7e81bSJeremy Fitzhardinge static ssize_t compile_date_show(struct hyp_sysfs_attr *attr, char *buffer)
217cff7e81bSJeremy Fitzhardinge {
218cff7e81bSJeremy Fitzhardinge int ret = -ENOMEM;
219cff7e81bSJeremy Fitzhardinge struct xen_compile_info *info;
220cff7e81bSJeremy Fitzhardinge
221cff7e81bSJeremy Fitzhardinge info = kmalloc(sizeof(struct xen_compile_info), GFP_KERNEL);
222cff7e81bSJeremy Fitzhardinge if (info) {
223cff7e81bSJeremy Fitzhardinge ret = HYPERVISOR_xen_version(XENVER_compile_info, info);
224cff7e81bSJeremy Fitzhardinge if (!ret)
225cff7e81bSJeremy Fitzhardinge ret = sprintf(buffer, "%s\n", info->compile_date);
226cff7e81bSJeremy Fitzhardinge kfree(info);
227cff7e81bSJeremy Fitzhardinge }
228cff7e81bSJeremy Fitzhardinge
229cff7e81bSJeremy Fitzhardinge return ret;
230cff7e81bSJeremy Fitzhardinge }
231cff7e81bSJeremy Fitzhardinge
232cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(compile_date);
233cff7e81bSJeremy Fitzhardinge
234cff7e81bSJeremy Fitzhardinge static struct attribute *xen_compile_attrs[] = {
235cff7e81bSJeremy Fitzhardinge &compiler_attr.attr,
236cff7e81bSJeremy Fitzhardinge &compiled_by_attr.attr,
237cff7e81bSJeremy Fitzhardinge &compile_date_attr.attr,
238cff7e81bSJeremy Fitzhardinge NULL
239cff7e81bSJeremy Fitzhardinge };
240cff7e81bSJeremy Fitzhardinge
241ead1d014SJan Beulich static const struct attribute_group xen_compilation_group = {
242cff7e81bSJeremy Fitzhardinge .name = "compilation",
243cff7e81bSJeremy Fitzhardinge .attrs = xen_compile_attrs,
244cff7e81bSJeremy Fitzhardinge };
245cff7e81bSJeremy Fitzhardinge
xen_sysfs_compilation_init(void)2465b00b504SJuergen Gross static int __init xen_sysfs_compilation_init(void)
247cff7e81bSJeremy Fitzhardinge {
248cff7e81bSJeremy Fitzhardinge return sysfs_create_group(hypervisor_kobj, &xen_compilation_group);
249cff7e81bSJeremy Fitzhardinge }
250cff7e81bSJeremy Fitzhardinge
251cff7e81bSJeremy Fitzhardinge /* xen properties info */
252cff7e81bSJeremy Fitzhardinge
capabilities_show(struct hyp_sysfs_attr * attr,char * buffer)253cff7e81bSJeremy Fitzhardinge static ssize_t capabilities_show(struct hyp_sysfs_attr *attr, char *buffer)
254cff7e81bSJeremy Fitzhardinge {
255cff7e81bSJeremy Fitzhardinge int ret = -ENOMEM;
256cff7e81bSJeremy Fitzhardinge char *caps;
257cff7e81bSJeremy Fitzhardinge
258cff7e81bSJeremy Fitzhardinge caps = kmalloc(XEN_CAPABILITIES_INFO_LEN, GFP_KERNEL);
259cff7e81bSJeremy Fitzhardinge if (caps) {
260cff7e81bSJeremy Fitzhardinge ret = HYPERVISOR_xen_version(XENVER_capabilities, caps);
261cff7e81bSJeremy Fitzhardinge if (!ret)
262cff7e81bSJeremy Fitzhardinge ret = sprintf(buffer, "%s\n", caps);
263cff7e81bSJeremy Fitzhardinge kfree(caps);
264cff7e81bSJeremy Fitzhardinge }
265cff7e81bSJeremy Fitzhardinge
266cff7e81bSJeremy Fitzhardinge return ret;
267cff7e81bSJeremy Fitzhardinge }
268cff7e81bSJeremy Fitzhardinge
269cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(capabilities);
270cff7e81bSJeremy Fitzhardinge
changeset_show(struct hyp_sysfs_attr * attr,char * buffer)271cff7e81bSJeremy Fitzhardinge static ssize_t changeset_show(struct hyp_sysfs_attr *attr, char *buffer)
272cff7e81bSJeremy Fitzhardinge {
273cff7e81bSJeremy Fitzhardinge int ret = -ENOMEM;
274cff7e81bSJeremy Fitzhardinge char *cset;
275cff7e81bSJeremy Fitzhardinge
276cff7e81bSJeremy Fitzhardinge cset = kmalloc(XEN_CHANGESET_INFO_LEN, GFP_KERNEL);
277cff7e81bSJeremy Fitzhardinge if (cset) {
278cff7e81bSJeremy Fitzhardinge ret = HYPERVISOR_xen_version(XENVER_changeset, cset);
279cff7e81bSJeremy Fitzhardinge if (!ret)
280cff7e81bSJeremy Fitzhardinge ret = sprintf(buffer, "%s\n", cset);
281cff7e81bSJeremy Fitzhardinge kfree(cset);
282cff7e81bSJeremy Fitzhardinge }
283cff7e81bSJeremy Fitzhardinge
284cff7e81bSJeremy Fitzhardinge return ret;
285cff7e81bSJeremy Fitzhardinge }
286cff7e81bSJeremy Fitzhardinge
287cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(changeset);
288cff7e81bSJeremy Fitzhardinge
virtual_start_show(struct hyp_sysfs_attr * attr,char * buffer)289cff7e81bSJeremy Fitzhardinge static ssize_t virtual_start_show(struct hyp_sysfs_attr *attr, char *buffer)
290cff7e81bSJeremy Fitzhardinge {
291cff7e81bSJeremy Fitzhardinge int ret = -ENOMEM;
292cff7e81bSJeremy Fitzhardinge struct xen_platform_parameters *parms;
293cff7e81bSJeremy Fitzhardinge
294cff7e81bSJeremy Fitzhardinge parms = kmalloc(sizeof(struct xen_platform_parameters), GFP_KERNEL);
295cff7e81bSJeremy Fitzhardinge if (parms) {
296cff7e81bSJeremy Fitzhardinge ret = HYPERVISOR_xen_version(XENVER_platform_parameters,
297cff7e81bSJeremy Fitzhardinge parms);
298cff7e81bSJeremy Fitzhardinge if (!ret)
29937ea0fcbSIan Campbell ret = sprintf(buffer, "%"PRI_xen_ulong"\n",
30037ea0fcbSIan Campbell parms->virt_start);
301cff7e81bSJeremy Fitzhardinge kfree(parms);
302cff7e81bSJeremy Fitzhardinge }
303cff7e81bSJeremy Fitzhardinge
304cff7e81bSJeremy Fitzhardinge return ret;
305cff7e81bSJeremy Fitzhardinge }
306cff7e81bSJeremy Fitzhardinge
307cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(virtual_start);
308cff7e81bSJeremy Fitzhardinge
pagesize_show(struct hyp_sysfs_attr * attr,char * buffer)309cff7e81bSJeremy Fitzhardinge static ssize_t pagesize_show(struct hyp_sysfs_attr *attr, char *buffer)
310cff7e81bSJeremy Fitzhardinge {
311cff7e81bSJeremy Fitzhardinge int ret;
312cff7e81bSJeremy Fitzhardinge
313cff7e81bSJeremy Fitzhardinge ret = HYPERVISOR_xen_version(XENVER_pagesize, NULL);
314cff7e81bSJeremy Fitzhardinge if (ret > 0)
315cff7e81bSJeremy Fitzhardinge ret = sprintf(buffer, "%x\n", ret);
316cff7e81bSJeremy Fitzhardinge
317cff7e81bSJeremy Fitzhardinge return ret;
318cff7e81bSJeremy Fitzhardinge }
319cff7e81bSJeremy Fitzhardinge
320cff7e81bSJeremy Fitzhardinge HYPERVISOR_ATTR_RO(pagesize);
321cff7e81bSJeremy Fitzhardinge
xen_feature_show(int index,char * buffer)322cff7e81bSJeremy Fitzhardinge static ssize_t xen_feature_show(int index, char *buffer)
323cff7e81bSJeremy Fitzhardinge {
324a649b720SJeremy Fitzhardinge ssize_t ret;
325a649b720SJeremy Fitzhardinge struct xen_feature_info info;
326cff7e81bSJeremy Fitzhardinge
327a649b720SJeremy Fitzhardinge info.submap_idx = index;
328a649b720SJeremy Fitzhardinge ret = HYPERVISOR_xen_version(XENVER_get_features, &info);
329cff7e81bSJeremy Fitzhardinge if (!ret)
330a649b720SJeremy Fitzhardinge ret = sprintf(buffer, "%08x", info.submap);
331cff7e81bSJeremy Fitzhardinge
332cff7e81bSJeremy Fitzhardinge return ret;
333cff7e81bSJeremy Fitzhardinge }
334cff7e81bSJeremy Fitzhardinge
features_show(struct hyp_sysfs_attr * attr,char * buffer)335a649b720SJeremy Fitzhardinge static ssize_t features_show(struct hyp_sysfs_attr *attr, char *buffer)
336cff7e81bSJeremy Fitzhardinge {
337a649b720SJeremy Fitzhardinge ssize_t len;
338a649b720SJeremy Fitzhardinge int i;
339a649b720SJeremy Fitzhardinge
340a649b720SJeremy Fitzhardinge len = 0;
341a649b720SJeremy Fitzhardinge for (i = XENFEAT_NR_SUBMAPS-1; i >= 0; i--) {
342a649b720SJeremy Fitzhardinge int ret = xen_feature_show(i, buffer + len);
343a649b720SJeremy Fitzhardinge if (ret < 0) {
344a649b720SJeremy Fitzhardinge if (len == 0)
345a649b720SJeremy Fitzhardinge len = ret;
346a649b720SJeremy Fitzhardinge break;
347a649b720SJeremy Fitzhardinge }
348a649b720SJeremy Fitzhardinge len += ret;
349a649b720SJeremy Fitzhardinge }
350a649b720SJeremy Fitzhardinge if (len > 0)
351a649b720SJeremy Fitzhardinge buffer[len++] = '\n';
352a649b720SJeremy Fitzhardinge
353a649b720SJeremy Fitzhardinge return len;
354cff7e81bSJeremy Fitzhardinge }
355cff7e81bSJeremy Fitzhardinge
356a649b720SJeremy Fitzhardinge HYPERVISOR_ATTR_RO(features);
357cff7e81bSJeremy Fitzhardinge
buildid_show(struct hyp_sysfs_attr * attr,char * buffer)35884b76257SJuergen Gross static ssize_t buildid_show(struct hyp_sysfs_attr *attr, char *buffer)
35984b76257SJuergen Gross {
36084b76257SJuergen Gross ssize_t ret;
36184b76257SJuergen Gross struct xen_build_id *buildid;
36284b76257SJuergen Gross
36384b76257SJuergen Gross ret = HYPERVISOR_xen_version(XENVER_build_id, NULL);
36484b76257SJuergen Gross if (ret < 0) {
36584b76257SJuergen Gross if (ret == -EPERM)
36684b76257SJuergen Gross ret = sprintf(buffer, "<denied>");
36784b76257SJuergen Gross return ret;
36884b76257SJuergen Gross }
36984b76257SJuergen Gross
37084b76257SJuergen Gross buildid = kmalloc(sizeof(*buildid) + ret, GFP_KERNEL);
37184b76257SJuergen Gross if (!buildid)
37284b76257SJuergen Gross return -ENOMEM;
37384b76257SJuergen Gross
37484b76257SJuergen Gross buildid->len = ret;
37584b76257SJuergen Gross ret = HYPERVISOR_xen_version(XENVER_build_id, buildid);
37684b76257SJuergen Gross if (ret > 0)
37784b76257SJuergen Gross ret = sprintf(buffer, "%s", buildid->buf);
37884b76257SJuergen Gross kfree(buildid);
37984b76257SJuergen Gross
38084b76257SJuergen Gross return ret;
38184b76257SJuergen Gross }
38284b76257SJuergen Gross
38384b76257SJuergen Gross HYPERVISOR_ATTR_RO(buildid);
38484b76257SJuergen Gross
385cff7e81bSJeremy Fitzhardinge static struct attribute *xen_properties_attrs[] = {
386cff7e81bSJeremy Fitzhardinge &capabilities_attr.attr,
387cff7e81bSJeremy Fitzhardinge &changeset_attr.attr,
388cff7e81bSJeremy Fitzhardinge &virtual_start_attr.attr,
389cff7e81bSJeremy Fitzhardinge &pagesize_attr.attr,
390a649b720SJeremy Fitzhardinge &features_attr.attr,
39184b76257SJuergen Gross &buildid_attr.attr,
392cff7e81bSJeremy Fitzhardinge NULL
393cff7e81bSJeremy Fitzhardinge };
394cff7e81bSJeremy Fitzhardinge
395ead1d014SJan Beulich static const struct attribute_group xen_properties_group = {
396cff7e81bSJeremy Fitzhardinge .name = "properties",
397cff7e81bSJeremy Fitzhardinge .attrs = xen_properties_attrs,
398cff7e81bSJeremy Fitzhardinge };
399cff7e81bSJeremy Fitzhardinge
xen_sysfs_properties_init(void)4005b00b504SJuergen Gross static int __init xen_sysfs_properties_init(void)
401cff7e81bSJeremy Fitzhardinge {
402cff7e81bSJeremy Fitzhardinge return sysfs_create_group(hypervisor_kobj, &xen_properties_group);
403cff7e81bSJeremy Fitzhardinge }
404cff7e81bSJeremy Fitzhardinge
405415dab3cSPer Bilse #define FLAG_UNAME "unknown"
406415dab3cSPer Bilse #define FLAG_UNAME_FMT FLAG_UNAME "%02u"
407415dab3cSPer Bilse #define FLAG_UNAME_MAX sizeof(FLAG_UNAME "XX")
408415dab3cSPer Bilse #define FLAG_COUNT (sizeof(xen_start_flags) * BITS_PER_BYTE)
409415dab3cSPer Bilse static_assert(sizeof(xen_start_flags) <=
410415dab3cSPer Bilse sizeof_field(struct hyp_sysfs_attr, hyp_attr_value));
411415dab3cSPer Bilse
flag_show(struct hyp_sysfs_attr * attr,char * buffer)412415dab3cSPer Bilse static ssize_t flag_show(struct hyp_sysfs_attr *attr, char *buffer)
413415dab3cSPer Bilse {
414415dab3cSPer Bilse char *p = buffer;
415415dab3cSPer Bilse
416415dab3cSPer Bilse *p++ = '0' + ((xen_start_flags & attr->hyp_attr_value) != 0);
417415dab3cSPer Bilse *p++ = '\n';
418415dab3cSPer Bilse return p - buffer;
419415dab3cSPer Bilse }
420415dab3cSPer Bilse
421415dab3cSPer Bilse #define FLAG_NODE(flag, node) \
422415dab3cSPer Bilse [ilog2(flag)] = { \
423415dab3cSPer Bilse .attr = { .name = #node, .mode = 0444 },\
424415dab3cSPer Bilse .show = flag_show, \
425415dab3cSPer Bilse .hyp_attr_value = flag \
426415dab3cSPer Bilse }
427415dab3cSPer Bilse
428415dab3cSPer Bilse /*
429415dab3cSPer Bilse * Add new, known flags here. No other changes are required, but
430415dab3cSPer Bilse * note that each known flag wastes one entry in flag_unames[].
431415dab3cSPer Bilse * The code/complexity machinations to avoid this isn't worth it
432415dab3cSPer Bilse * for a few entries, but keep it in mind.
433415dab3cSPer Bilse */
434415dab3cSPer Bilse static struct hyp_sysfs_attr flag_attrs[FLAG_COUNT] = {
435415dab3cSPer Bilse FLAG_NODE(SIF_PRIVILEGED, privileged),
436415dab3cSPer Bilse FLAG_NODE(SIF_INITDOMAIN, initdomain)
437415dab3cSPer Bilse };
438415dab3cSPer Bilse static struct attribute_group xen_flags_group = {
439415dab3cSPer Bilse .name = "start_flags",
440415dab3cSPer Bilse .attrs = (struct attribute *[FLAG_COUNT + 1]){}
441415dab3cSPer Bilse };
442415dab3cSPer Bilse static char flag_unames[FLAG_COUNT][FLAG_UNAME_MAX];
443415dab3cSPer Bilse
xen_sysfs_flags_init(void)444415dab3cSPer Bilse static int __init xen_sysfs_flags_init(void)
445415dab3cSPer Bilse {
446415dab3cSPer Bilse for (unsigned fnum = 0; fnum != FLAG_COUNT; fnum++) {
447415dab3cSPer Bilse if (likely(flag_attrs[fnum].attr.name == NULL)) {
448415dab3cSPer Bilse sprintf(flag_unames[fnum], FLAG_UNAME_FMT, fnum);
449415dab3cSPer Bilse flag_attrs[fnum].attr.name = flag_unames[fnum];
450415dab3cSPer Bilse flag_attrs[fnum].attr.mode = 0444;
451415dab3cSPer Bilse flag_attrs[fnum].show = flag_show;
452415dab3cSPer Bilse flag_attrs[fnum].hyp_attr_value = 1 << fnum;
453415dab3cSPer Bilse }
454415dab3cSPer Bilse xen_flags_group.attrs[fnum] = &flag_attrs[fnum].attr;
455415dab3cSPer Bilse }
456415dab3cSPer Bilse return sysfs_create_group(hypervisor_kobj, &xen_flags_group);
457415dab3cSPer Bilse }
458415dab3cSPer Bilse
4595f141548SBoris Ostrovsky #ifdef CONFIG_XEN_HAVE_VPMU
4605f141548SBoris Ostrovsky struct pmu_mode {
4615f141548SBoris Ostrovsky const char *name;
4625f141548SBoris Ostrovsky uint32_t mode;
4635f141548SBoris Ostrovsky };
4645f141548SBoris Ostrovsky
4655f141548SBoris Ostrovsky static struct pmu_mode pmu_modes[] = {
4665f141548SBoris Ostrovsky {"off", XENPMU_MODE_OFF},
4675f141548SBoris Ostrovsky {"self", XENPMU_MODE_SELF},
4685f141548SBoris Ostrovsky {"hv", XENPMU_MODE_HV},
4695f141548SBoris Ostrovsky {"all", XENPMU_MODE_ALL}
4705f141548SBoris Ostrovsky };
4715f141548SBoris Ostrovsky
pmu_mode_store(struct hyp_sysfs_attr * attr,const char * buffer,size_t len)4725f141548SBoris Ostrovsky static ssize_t pmu_mode_store(struct hyp_sysfs_attr *attr,
4735f141548SBoris Ostrovsky const char *buffer, size_t len)
4745f141548SBoris Ostrovsky {
4755f141548SBoris Ostrovsky int ret;
4765f141548SBoris Ostrovsky struct xen_pmu_params xp;
4775f141548SBoris Ostrovsky int i;
4785f141548SBoris Ostrovsky
4795f141548SBoris Ostrovsky for (i = 0; i < ARRAY_SIZE(pmu_modes); i++) {
4805f141548SBoris Ostrovsky if (strncmp(buffer, pmu_modes[i].name, len - 1) == 0) {
4815f141548SBoris Ostrovsky xp.val = pmu_modes[i].mode;
4825f141548SBoris Ostrovsky break;
4835f141548SBoris Ostrovsky }
4845f141548SBoris Ostrovsky }
4855f141548SBoris Ostrovsky
4865f141548SBoris Ostrovsky if (i == ARRAY_SIZE(pmu_modes))
4875f141548SBoris Ostrovsky return -EINVAL;
4885f141548SBoris Ostrovsky
4895f141548SBoris Ostrovsky xp.version.maj = XENPMU_VER_MAJ;
4905f141548SBoris Ostrovsky xp.version.min = XENPMU_VER_MIN;
4915f141548SBoris Ostrovsky ret = HYPERVISOR_xenpmu_op(XENPMU_mode_set, &xp);
4925f141548SBoris Ostrovsky if (ret)
4935f141548SBoris Ostrovsky return ret;
4945f141548SBoris Ostrovsky
4955f141548SBoris Ostrovsky return len;
4965f141548SBoris Ostrovsky }
4975f141548SBoris Ostrovsky
pmu_mode_show(struct hyp_sysfs_attr * attr,char * buffer)4985f141548SBoris Ostrovsky static ssize_t pmu_mode_show(struct hyp_sysfs_attr *attr, char *buffer)
4995f141548SBoris Ostrovsky {
5005f141548SBoris Ostrovsky int ret;
5015f141548SBoris Ostrovsky struct xen_pmu_params xp;
5025f141548SBoris Ostrovsky int i;
5035f141548SBoris Ostrovsky uint32_t mode;
5045f141548SBoris Ostrovsky
5055f141548SBoris Ostrovsky xp.version.maj = XENPMU_VER_MAJ;
5065f141548SBoris Ostrovsky xp.version.min = XENPMU_VER_MIN;
5075f141548SBoris Ostrovsky ret = HYPERVISOR_xenpmu_op(XENPMU_mode_get, &xp);
5085f141548SBoris Ostrovsky if (ret)
5095f141548SBoris Ostrovsky return ret;
5105f141548SBoris Ostrovsky
5115f141548SBoris Ostrovsky mode = (uint32_t)xp.val;
5125f141548SBoris Ostrovsky for (i = 0; i < ARRAY_SIZE(pmu_modes); i++) {
5135f141548SBoris Ostrovsky if (mode == pmu_modes[i].mode)
5145f141548SBoris Ostrovsky return sprintf(buffer, "%s\n", pmu_modes[i].name);
5155f141548SBoris Ostrovsky }
5165f141548SBoris Ostrovsky
5175f141548SBoris Ostrovsky return -EINVAL;
5185f141548SBoris Ostrovsky }
5195f141548SBoris Ostrovsky HYPERVISOR_ATTR_RW(pmu_mode);
5205f141548SBoris Ostrovsky
pmu_features_store(struct hyp_sysfs_attr * attr,const char * buffer,size_t len)5215f141548SBoris Ostrovsky static ssize_t pmu_features_store(struct hyp_sysfs_attr *attr,
5225f141548SBoris Ostrovsky const char *buffer, size_t len)
5235f141548SBoris Ostrovsky {
5245f141548SBoris Ostrovsky int ret;
5255f141548SBoris Ostrovsky uint32_t features;
5265f141548SBoris Ostrovsky struct xen_pmu_params xp;
5275f141548SBoris Ostrovsky
5285f141548SBoris Ostrovsky ret = kstrtou32(buffer, 0, &features);
5295f141548SBoris Ostrovsky if (ret)
5305f141548SBoris Ostrovsky return ret;
5315f141548SBoris Ostrovsky
5325f141548SBoris Ostrovsky xp.val = features;
5335f141548SBoris Ostrovsky xp.version.maj = XENPMU_VER_MAJ;
5345f141548SBoris Ostrovsky xp.version.min = XENPMU_VER_MIN;
5355f141548SBoris Ostrovsky ret = HYPERVISOR_xenpmu_op(XENPMU_feature_set, &xp);
5365f141548SBoris Ostrovsky if (ret)
5375f141548SBoris Ostrovsky return ret;
5385f141548SBoris Ostrovsky
5395f141548SBoris Ostrovsky return len;
5405f141548SBoris Ostrovsky }
5415f141548SBoris Ostrovsky
pmu_features_show(struct hyp_sysfs_attr * attr,char * buffer)5425f141548SBoris Ostrovsky static ssize_t pmu_features_show(struct hyp_sysfs_attr *attr, char *buffer)
5435f141548SBoris Ostrovsky {
5445f141548SBoris Ostrovsky int ret;
5455f141548SBoris Ostrovsky struct xen_pmu_params xp;
5465f141548SBoris Ostrovsky
5475f141548SBoris Ostrovsky xp.version.maj = XENPMU_VER_MAJ;
5485f141548SBoris Ostrovsky xp.version.min = XENPMU_VER_MIN;
5495f141548SBoris Ostrovsky ret = HYPERVISOR_xenpmu_op(XENPMU_feature_get, &xp);
5505f141548SBoris Ostrovsky if (ret)
5515f141548SBoris Ostrovsky return ret;
5525f141548SBoris Ostrovsky
5535f141548SBoris Ostrovsky return sprintf(buffer, "0x%x\n", (uint32_t)xp.val);
5545f141548SBoris Ostrovsky }
5555f141548SBoris Ostrovsky HYPERVISOR_ATTR_RW(pmu_features);
5565f141548SBoris Ostrovsky
5575f141548SBoris Ostrovsky static struct attribute *xen_pmu_attrs[] = {
5585f141548SBoris Ostrovsky &pmu_mode_attr.attr,
5595f141548SBoris Ostrovsky &pmu_features_attr.attr,
5605f141548SBoris Ostrovsky NULL
5615f141548SBoris Ostrovsky };
5625f141548SBoris Ostrovsky
5635f141548SBoris Ostrovsky static const struct attribute_group xen_pmu_group = {
5645f141548SBoris Ostrovsky .name = "pmu",
5655f141548SBoris Ostrovsky .attrs = xen_pmu_attrs,
5665f141548SBoris Ostrovsky };
5675f141548SBoris Ostrovsky
xen_sysfs_pmu_init(void)5685b00b504SJuergen Gross static int __init xen_sysfs_pmu_init(void)
5695f141548SBoris Ostrovsky {
5705f141548SBoris Ostrovsky return sysfs_create_group(hypervisor_kobj, &xen_pmu_group);
5715f141548SBoris Ostrovsky }
5725f141548SBoris Ostrovsky #endif
5735f141548SBoris Ostrovsky
hyper_sysfs_init(void)574cff7e81bSJeremy Fitzhardinge static int __init hyper_sysfs_init(void)
575cff7e81bSJeremy Fitzhardinge {
576cff7e81bSJeremy Fitzhardinge int ret;
577cff7e81bSJeremy Fitzhardinge
578cff7e81bSJeremy Fitzhardinge if (!xen_domain())
579cff7e81bSJeremy Fitzhardinge return -ENODEV;
580cff7e81bSJeremy Fitzhardinge
581cff7e81bSJeremy Fitzhardinge ret = xen_sysfs_type_init();
582cff7e81bSJeremy Fitzhardinge if (ret)
583cff7e81bSJeremy Fitzhardinge goto out;
5844a4c29c9SJuergen Gross ret = xen_sysfs_guest_type_init();
5854a4c29c9SJuergen Gross if (ret)
5864a4c29c9SJuergen Gross goto guest_type_out;
587cff7e81bSJeremy Fitzhardinge ret = xen_sysfs_version_init();
588cff7e81bSJeremy Fitzhardinge if (ret)
589cff7e81bSJeremy Fitzhardinge goto version_out;
5905b00b504SJuergen Gross ret = xen_sysfs_compilation_init();
591cff7e81bSJeremy Fitzhardinge if (ret)
592cff7e81bSJeremy Fitzhardinge goto comp_out;
593cff7e81bSJeremy Fitzhardinge ret = xen_sysfs_uuid_init();
594cff7e81bSJeremy Fitzhardinge if (ret)
595cff7e81bSJeremy Fitzhardinge goto uuid_out;
5965b00b504SJuergen Gross ret = xen_sysfs_properties_init();
597cff7e81bSJeremy Fitzhardinge if (ret)
598cff7e81bSJeremy Fitzhardinge goto prop_out;
599415dab3cSPer Bilse ret = xen_sysfs_flags_init();
600415dab3cSPer Bilse if (ret)
601415dab3cSPer Bilse goto flags_out;
6025f141548SBoris Ostrovsky #ifdef CONFIG_XEN_HAVE_VPMU
6035f141548SBoris Ostrovsky if (xen_initial_domain()) {
6045b00b504SJuergen Gross ret = xen_sysfs_pmu_init();
6055f141548SBoris Ostrovsky if (ret) {
606415dab3cSPer Bilse sysfs_remove_group(hypervisor_kobj, &xen_flags_group);
607415dab3cSPer Bilse goto flags_out;
6085f141548SBoris Ostrovsky }
6095f141548SBoris Ostrovsky }
6105f141548SBoris Ostrovsky #endif
611cff7e81bSJeremy Fitzhardinge goto out;
612cff7e81bSJeremy Fitzhardinge
613415dab3cSPer Bilse flags_out:
614415dab3cSPer Bilse sysfs_remove_group(hypervisor_kobj, &xen_properties_group);
615cff7e81bSJeremy Fitzhardinge prop_out:
61646894f17SPaul Gortmaker sysfs_remove_file(hypervisor_kobj, &uuid_attr.attr);
617cff7e81bSJeremy Fitzhardinge uuid_out:
61846894f17SPaul Gortmaker sysfs_remove_group(hypervisor_kobj, &xen_compilation_group);
619cff7e81bSJeremy Fitzhardinge comp_out:
62046894f17SPaul Gortmaker sysfs_remove_group(hypervisor_kobj, &version_group);
621cff7e81bSJeremy Fitzhardinge version_out:
6224a4c29c9SJuergen Gross sysfs_remove_file(hypervisor_kobj, &guest_type_attr.attr);
6234a4c29c9SJuergen Gross guest_type_out:
62446894f17SPaul Gortmaker sysfs_remove_file(hypervisor_kobj, &type_attr.attr);
625cff7e81bSJeremy Fitzhardinge out:
626cff7e81bSJeremy Fitzhardinge return ret;
627cff7e81bSJeremy Fitzhardinge }
62846894f17SPaul Gortmaker device_initcall(hyper_sysfs_init);
629cff7e81bSJeremy Fitzhardinge
hyp_sysfs_show(struct kobject * kobj,struct attribute * attr,char * buffer)630cff7e81bSJeremy Fitzhardinge static ssize_t hyp_sysfs_show(struct kobject *kobj,
631cff7e81bSJeremy Fitzhardinge struct attribute *attr,
632cff7e81bSJeremy Fitzhardinge char *buffer)
633cff7e81bSJeremy Fitzhardinge {
634cff7e81bSJeremy Fitzhardinge struct hyp_sysfs_attr *hyp_attr;
635cff7e81bSJeremy Fitzhardinge hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
636cff7e81bSJeremy Fitzhardinge if (hyp_attr->show)
637cff7e81bSJeremy Fitzhardinge return hyp_attr->show(hyp_attr, buffer);
638cff7e81bSJeremy Fitzhardinge return 0;
639cff7e81bSJeremy Fitzhardinge }
640cff7e81bSJeremy Fitzhardinge
hyp_sysfs_store(struct kobject * kobj,struct attribute * attr,const char * buffer,size_t len)641cff7e81bSJeremy Fitzhardinge static ssize_t hyp_sysfs_store(struct kobject *kobj,
642cff7e81bSJeremy Fitzhardinge struct attribute *attr,
643cff7e81bSJeremy Fitzhardinge const char *buffer,
644cff7e81bSJeremy Fitzhardinge size_t len)
645cff7e81bSJeremy Fitzhardinge {
646cff7e81bSJeremy Fitzhardinge struct hyp_sysfs_attr *hyp_attr;
647cff7e81bSJeremy Fitzhardinge hyp_attr = container_of(attr, struct hyp_sysfs_attr, attr);
648cff7e81bSJeremy Fitzhardinge if (hyp_attr->store)
649cff7e81bSJeremy Fitzhardinge return hyp_attr->store(hyp_attr, buffer, len);
650cff7e81bSJeremy Fitzhardinge return 0;
651cff7e81bSJeremy Fitzhardinge }
652cff7e81bSJeremy Fitzhardinge
65352cf25d0SEmese Revfy static const struct sysfs_ops hyp_sysfs_ops = {
654cff7e81bSJeremy Fitzhardinge .show = hyp_sysfs_show,
655cff7e81bSJeremy Fitzhardinge .store = hyp_sysfs_store,
656cff7e81bSJeremy Fitzhardinge };
657cff7e81bSJeremy Fitzhardinge
658*4ecc96cbSThomas Weißschuh static const struct kobj_type hyp_sysfs_kobj_type = {
659cff7e81bSJeremy Fitzhardinge .sysfs_ops = &hyp_sysfs_ops,
660cff7e81bSJeremy Fitzhardinge };
661cff7e81bSJeremy Fitzhardinge
hypervisor_subsys_init(void)662cff7e81bSJeremy Fitzhardinge static int __init hypervisor_subsys_init(void)
663cff7e81bSJeremy Fitzhardinge {
664cff7e81bSJeremy Fitzhardinge if (!xen_domain())
665cff7e81bSJeremy Fitzhardinge return -ENODEV;
666cff7e81bSJeremy Fitzhardinge
667cff7e81bSJeremy Fitzhardinge hypervisor_kobj->ktype = &hyp_sysfs_kobj_type;
668cff7e81bSJeremy Fitzhardinge return 0;
669cff7e81bSJeremy Fitzhardinge }
670cff7e81bSJeremy Fitzhardinge device_initcall(hypervisor_subsys_init);
671