hypfs_diag.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Hypervisor filesystem for Linux on s390. Diag 204 and 224
  4. * implementation.
  5. *
  6. * Copyright IBM Corp. 2006, 2008
  7. * Author(s): Michael Holzheu <holzheu@de.ibm.com>
  8. */
  9. #define KMSG_COMPONENT "hypfs"
  10. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  11. #include <linux/types.h>
  12. #include <linux/errno.h>
  13. #include <linux/slab.h>
  14. #include <linux/string.h>
  15. #include <linux/vmalloc.h>
  16. #include <linux/mm.h>
  17. #include <asm/diag.h>
  18. #include <asm/ebcdic.h>
  19. #include "hypfs.h"
  20. #define TMP_SIZE 64 /* size of temporary buffers */
  21. #define DBFS_D204_HDR_VERSION 0
  22. static char *diag224_cpu_names; /* diag 224 name table */
  23. static enum diag204_sc diag204_store_sc; /* used subcode for store */
  24. static enum diag204_format diag204_info_type; /* used diag 204 data format */
  25. static void *diag204_buf; /* 4K aligned buffer for diag204 data */
  26. static void *diag204_buf_vmalloc; /* vmalloc pointer for diag204 data */
  27. static int diag204_buf_pages; /* number of pages for diag204 data */
  28. static struct dentry *dbfs_d204_file;
  29. /*
  30. * DIAG 204 member access functions.
  31. *
  32. * Since we have two different diag 204 data formats for old and new s390
  33. * machines, we do not access the structs directly, but use getter functions for
  34. * each struct member instead. This should make the code more readable.
  35. */
  36. /* Time information block */
  37. static inline int info_blk_hdr__size(enum diag204_format type)
  38. {
  39. if (type == DIAG204_INFO_SIMPLE)
  40. return sizeof(struct diag204_info_blk_hdr);
  41. else /* DIAG204_INFO_EXT */
  42. return sizeof(struct diag204_x_info_blk_hdr);
  43. }
  44. static inline __u8 info_blk_hdr__npar(enum diag204_format type, void *hdr)
  45. {
  46. if (type == DIAG204_INFO_SIMPLE)
  47. return ((struct diag204_info_blk_hdr *)hdr)->npar;
  48. else /* DIAG204_INFO_EXT */
  49. return ((struct diag204_x_info_blk_hdr *)hdr)->npar;
  50. }
  51. static inline __u8 info_blk_hdr__flags(enum diag204_format type, void *hdr)
  52. {
  53. if (type == DIAG204_INFO_SIMPLE)
  54. return ((struct diag204_info_blk_hdr *)hdr)->flags;
  55. else /* DIAG204_INFO_EXT */
  56. return ((struct diag204_x_info_blk_hdr *)hdr)->flags;
  57. }
  58. static inline __u16 info_blk_hdr__pcpus(enum diag204_format type, void *hdr)
  59. {
  60. if (type == DIAG204_INFO_SIMPLE)
  61. return ((struct diag204_info_blk_hdr *)hdr)->phys_cpus;
  62. else /* DIAG204_INFO_EXT */
  63. return ((struct diag204_x_info_blk_hdr *)hdr)->phys_cpus;
  64. }
  65. /* Partition header */
  66. static inline int part_hdr__size(enum diag204_format type)
  67. {
  68. if (type == DIAG204_INFO_SIMPLE)
  69. return sizeof(struct diag204_part_hdr);
  70. else /* DIAG204_INFO_EXT */
  71. return sizeof(struct diag204_x_part_hdr);
  72. }
  73. static inline __u8 part_hdr__rcpus(enum diag204_format type, void *hdr)
  74. {
  75. if (type == DIAG204_INFO_SIMPLE)
  76. return ((struct diag204_part_hdr *)hdr)->cpus;
  77. else /* DIAG204_INFO_EXT */
  78. return ((struct diag204_x_part_hdr *)hdr)->rcpus;
  79. }
  80. static inline void part_hdr__part_name(enum diag204_format type, void *hdr,
  81. char *name)
  82. {
  83. if (type == DIAG204_INFO_SIMPLE)
  84. memcpy(name, ((struct diag204_part_hdr *)hdr)->part_name,
  85. DIAG204_LPAR_NAME_LEN);
  86. else /* DIAG204_INFO_EXT */
  87. memcpy(name, ((struct diag204_x_part_hdr *)hdr)->part_name,
  88. DIAG204_LPAR_NAME_LEN);
  89. EBCASC(name, DIAG204_LPAR_NAME_LEN);
  90. name[DIAG204_LPAR_NAME_LEN] = 0;
  91. strim(name);
  92. }
  93. /* CPU info block */
  94. static inline int cpu_info__size(enum diag204_format type)
  95. {
  96. if (type == DIAG204_INFO_SIMPLE)
  97. return sizeof(struct diag204_cpu_info);
  98. else /* DIAG204_INFO_EXT */
  99. return sizeof(struct diag204_x_cpu_info);
  100. }
  101. static inline __u8 cpu_info__ctidx(enum diag204_format type, void *hdr)
  102. {
  103. if (type == DIAG204_INFO_SIMPLE)
  104. return ((struct diag204_cpu_info *)hdr)->ctidx;
  105. else /* DIAG204_INFO_EXT */
  106. return ((struct diag204_x_cpu_info *)hdr)->ctidx;
  107. }
  108. static inline __u16 cpu_info__cpu_addr(enum diag204_format type, void *hdr)
  109. {
  110. if (type == DIAG204_INFO_SIMPLE)
  111. return ((struct diag204_cpu_info *)hdr)->cpu_addr;
  112. else /* DIAG204_INFO_EXT */
  113. return ((struct diag204_x_cpu_info *)hdr)->cpu_addr;
  114. }
  115. static inline __u64 cpu_info__acc_time(enum diag204_format type, void *hdr)
  116. {
  117. if (type == DIAG204_INFO_SIMPLE)
  118. return ((struct diag204_cpu_info *)hdr)->acc_time;
  119. else /* DIAG204_INFO_EXT */
  120. return ((struct diag204_x_cpu_info *)hdr)->acc_time;
  121. }
  122. static inline __u64 cpu_info__lp_time(enum diag204_format type, void *hdr)
  123. {
  124. if (type == DIAG204_INFO_SIMPLE)
  125. return ((struct diag204_cpu_info *)hdr)->lp_time;
  126. else /* DIAG204_INFO_EXT */
  127. return ((struct diag204_x_cpu_info *)hdr)->lp_time;
  128. }
  129. static inline __u64 cpu_info__online_time(enum diag204_format type, void *hdr)
  130. {
  131. if (type == DIAG204_INFO_SIMPLE)
  132. return 0; /* online_time not available in simple info */
  133. else /* DIAG204_INFO_EXT */
  134. return ((struct diag204_x_cpu_info *)hdr)->online_time;
  135. }
  136. /* Physical header */
  137. static inline int phys_hdr__size(enum diag204_format type)
  138. {
  139. if (type == DIAG204_INFO_SIMPLE)
  140. return sizeof(struct diag204_phys_hdr);
  141. else /* DIAG204_INFO_EXT */
  142. return sizeof(struct diag204_x_phys_hdr);
  143. }
  144. static inline __u8 phys_hdr__cpus(enum diag204_format type, void *hdr)
  145. {
  146. if (type == DIAG204_INFO_SIMPLE)
  147. return ((struct diag204_phys_hdr *)hdr)->cpus;
  148. else /* DIAG204_INFO_EXT */
  149. return ((struct diag204_x_phys_hdr *)hdr)->cpus;
  150. }
  151. /* Physical CPU info block */
  152. static inline int phys_cpu__size(enum diag204_format type)
  153. {
  154. if (type == DIAG204_INFO_SIMPLE)
  155. return sizeof(struct diag204_phys_cpu);
  156. else /* DIAG204_INFO_EXT */
  157. return sizeof(struct diag204_x_phys_cpu);
  158. }
  159. static inline __u16 phys_cpu__cpu_addr(enum diag204_format type, void *hdr)
  160. {
  161. if (type == DIAG204_INFO_SIMPLE)
  162. return ((struct diag204_phys_cpu *)hdr)->cpu_addr;
  163. else /* DIAG204_INFO_EXT */
  164. return ((struct diag204_x_phys_cpu *)hdr)->cpu_addr;
  165. }
  166. static inline __u64 phys_cpu__mgm_time(enum diag204_format type, void *hdr)
  167. {
  168. if (type == DIAG204_INFO_SIMPLE)
  169. return ((struct diag204_phys_cpu *)hdr)->mgm_time;
  170. else /* DIAG204_INFO_EXT */
  171. return ((struct diag204_x_phys_cpu *)hdr)->mgm_time;
  172. }
  173. static inline __u64 phys_cpu__ctidx(enum diag204_format type, void *hdr)
  174. {
  175. if (type == DIAG204_INFO_SIMPLE)
  176. return ((struct diag204_phys_cpu *)hdr)->ctidx;
  177. else /* DIAG204_INFO_EXT */
  178. return ((struct diag204_x_phys_cpu *)hdr)->ctidx;
  179. }
  180. /* Diagnose 204 functions */
  181. /*
  182. * For the old diag subcode 4 with simple data format we have to use real
  183. * memory. If we use subcode 6 or 7 with extended data format, we can (and
  184. * should) use vmalloc, since we need a lot of memory in that case. Currently
  185. * up to 93 pages!
  186. */
  187. static void diag204_free_buffer(void)
  188. {
  189. if (!diag204_buf)
  190. return;
  191. if (diag204_buf_vmalloc) {
  192. vfree(diag204_buf_vmalloc);
  193. diag204_buf_vmalloc = NULL;
  194. } else {
  195. free_pages((unsigned long) diag204_buf, 0);
  196. }
  197. diag204_buf = NULL;
  198. }
  199. static void *page_align_ptr(void *ptr)
  200. {
  201. return (void *) PAGE_ALIGN((unsigned long) ptr);
  202. }
  203. static void *diag204_alloc_vbuf(int pages)
  204. {
  205. /* The buffer has to be page aligned! */
  206. diag204_buf_vmalloc = vmalloc(array_size(PAGE_SIZE, (pages + 1)));
  207. if (!diag204_buf_vmalloc)
  208. return ERR_PTR(-ENOMEM);
  209. diag204_buf = page_align_ptr(diag204_buf_vmalloc);
  210. diag204_buf_pages = pages;
  211. return diag204_buf;
  212. }
  213. static void *diag204_alloc_rbuf(void)
  214. {
  215. diag204_buf = (void*)__get_free_pages(GFP_KERNEL,0);
  216. if (!diag204_buf)
  217. return ERR_PTR(-ENOMEM);
  218. diag204_buf_pages = 1;
  219. return diag204_buf;
  220. }
  221. static void *diag204_get_buffer(enum diag204_format fmt, int *pages)
  222. {
  223. if (diag204_buf) {
  224. *pages = diag204_buf_pages;
  225. return diag204_buf;
  226. }
  227. if (fmt == DIAG204_INFO_SIMPLE) {
  228. *pages = 1;
  229. return diag204_alloc_rbuf();
  230. } else {/* DIAG204_INFO_EXT */
  231. *pages = diag204((unsigned long)DIAG204_SUBC_RSI |
  232. (unsigned long)DIAG204_INFO_EXT, 0, NULL);
  233. if (*pages <= 0)
  234. return ERR_PTR(-ENOSYS);
  235. else
  236. return diag204_alloc_vbuf(*pages);
  237. }
  238. }
  239. /*
  240. * diag204_probe() has to find out, which type of diagnose 204 implementation
  241. * we have on our machine. Currently there are three possible scanarios:
  242. * - subcode 4 + simple data format (only one page)
  243. * - subcode 4-6 + extended data format
  244. * - subcode 4-7 + extended data format
  245. *
  246. * Subcode 5 is used to retrieve the size of the data, provided by subcodes
  247. * 6 and 7. Subcode 7 basically has the same function as subcode 6. In addition
  248. * to subcode 6 it provides also information about secondary cpus.
  249. * In order to get as much information as possible, we first try
  250. * subcode 7, then 6 and if both fail, we use subcode 4.
  251. */
  252. static int diag204_probe(void)
  253. {
  254. void *buf;
  255. int pages, rc;
  256. buf = diag204_get_buffer(DIAG204_INFO_EXT, &pages);
  257. if (!IS_ERR(buf)) {
  258. if (diag204((unsigned long)DIAG204_SUBC_STIB7 |
  259. (unsigned long)DIAG204_INFO_EXT, pages, buf) >= 0) {
  260. diag204_store_sc = DIAG204_SUBC_STIB7;
  261. diag204_info_type = DIAG204_INFO_EXT;
  262. goto out;
  263. }
  264. if (diag204((unsigned long)DIAG204_SUBC_STIB6 |
  265. (unsigned long)DIAG204_INFO_EXT, pages, buf) >= 0) {
  266. diag204_store_sc = DIAG204_SUBC_STIB6;
  267. diag204_info_type = DIAG204_INFO_EXT;
  268. goto out;
  269. }
  270. diag204_free_buffer();
  271. }
  272. /* subcodes 6 and 7 failed, now try subcode 4 */
  273. buf = diag204_get_buffer(DIAG204_INFO_SIMPLE, &pages);
  274. if (IS_ERR(buf)) {
  275. rc = PTR_ERR(buf);
  276. goto fail_alloc;
  277. }
  278. if (diag204((unsigned long)DIAG204_SUBC_STIB4 |
  279. (unsigned long)DIAG204_INFO_SIMPLE, pages, buf) >= 0) {
  280. diag204_store_sc = DIAG204_SUBC_STIB4;
  281. diag204_info_type = DIAG204_INFO_SIMPLE;
  282. goto out;
  283. } else {
  284. rc = -ENOSYS;
  285. goto fail_store;
  286. }
  287. out:
  288. rc = 0;
  289. fail_store:
  290. diag204_free_buffer();
  291. fail_alloc:
  292. return rc;
  293. }
  294. static int diag204_do_store(void *buf, int pages)
  295. {
  296. int rc;
  297. rc = diag204((unsigned long) diag204_store_sc |
  298. (unsigned long) diag204_info_type, pages, buf);
  299. return rc < 0 ? -ENOSYS : 0;
  300. }
  301. static void *diag204_store(void)
  302. {
  303. void *buf;
  304. int pages, rc;
  305. buf = diag204_get_buffer(diag204_info_type, &pages);
  306. if (IS_ERR(buf))
  307. goto out;
  308. rc = diag204_do_store(buf, pages);
  309. if (rc)
  310. return ERR_PTR(rc);
  311. out:
  312. return buf;
  313. }
  314. /* Diagnose 224 functions */
  315. static int diag224_get_name_table(void)
  316. {
  317. /* memory must be below 2GB */
  318. diag224_cpu_names = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
  319. if (!diag224_cpu_names)
  320. return -ENOMEM;
  321. if (diag224(diag224_cpu_names)) {
  322. free_page((unsigned long) diag224_cpu_names);
  323. return -EOPNOTSUPP;
  324. }
  325. EBCASC(diag224_cpu_names + 16, (*diag224_cpu_names + 1) * 16);
  326. return 0;
  327. }
  328. static void diag224_delete_name_table(void)
  329. {
  330. free_page((unsigned long) diag224_cpu_names);
  331. }
  332. static int diag224_idx2name(int index, char *name)
  333. {
  334. memcpy(name, diag224_cpu_names + ((index + 1) * DIAG204_CPU_NAME_LEN),
  335. DIAG204_CPU_NAME_LEN);
  336. name[DIAG204_CPU_NAME_LEN] = 0;
  337. strim(name);
  338. return 0;
  339. }
  340. struct dbfs_d204_hdr {
  341. u64 len; /* Length of d204 buffer without header */
  342. u16 version; /* Version of header */
  343. u8 sc; /* Used subcode */
  344. char reserved[53];
  345. } __attribute__ ((packed));
  346. struct dbfs_d204 {
  347. struct dbfs_d204_hdr hdr; /* 64 byte header */
  348. char buf[]; /* d204 buffer */
  349. } __attribute__ ((packed));
  350. static int dbfs_d204_create(void **data, void **data_free_ptr, size_t *size)
  351. {
  352. struct dbfs_d204 *d204;
  353. int rc, buf_size;
  354. void *base;
  355. buf_size = PAGE_SIZE * (diag204_buf_pages + 1) + sizeof(d204->hdr);
  356. base = vzalloc(buf_size);
  357. if (!base)
  358. return -ENOMEM;
  359. d204 = page_align_ptr(base + sizeof(d204->hdr)) - sizeof(d204->hdr);
  360. rc = diag204_do_store(d204->buf, diag204_buf_pages);
  361. if (rc) {
  362. vfree(base);
  363. return rc;
  364. }
  365. d204->hdr.version = DBFS_D204_HDR_VERSION;
  366. d204->hdr.len = PAGE_SIZE * diag204_buf_pages;
  367. d204->hdr.sc = diag204_store_sc;
  368. *data = d204;
  369. *data_free_ptr = base;
  370. *size = d204->hdr.len + sizeof(struct dbfs_d204_hdr);
  371. return 0;
  372. }
  373. static struct hypfs_dbfs_file dbfs_file_d204 = {
  374. .name = "diag_204",
  375. .data_create = dbfs_d204_create,
  376. .data_free = vfree,
  377. };
  378. __init int hypfs_diag_init(void)
  379. {
  380. int rc;
  381. if (diag204_probe()) {
  382. pr_err("The hardware system does not support hypfs\n");
  383. return -ENODATA;
  384. }
  385. if (diag204_info_type == DIAG204_INFO_EXT)
  386. hypfs_dbfs_create_file(&dbfs_file_d204);
  387. if (MACHINE_IS_LPAR) {
  388. rc = diag224_get_name_table();
  389. if (rc) {
  390. pr_err("The hardware system does not provide all "
  391. "functions required by hypfs\n");
  392. debugfs_remove(dbfs_d204_file);
  393. return rc;
  394. }
  395. }
  396. return 0;
  397. }
  398. void hypfs_diag_exit(void)
  399. {
  400. debugfs_remove(dbfs_d204_file);
  401. diag224_delete_name_table();
  402. diag204_free_buffer();
  403. hypfs_dbfs_remove_file(&dbfs_file_d204);
  404. }
  405. /*
  406. * Functions to create the directory structure
  407. * *******************************************
  408. */
  409. static int hypfs_create_cpu_files(struct dentry *cpus_dir, void *cpu_info)
  410. {
  411. struct dentry *cpu_dir;
  412. char buffer[TMP_SIZE];
  413. void *rc;
  414. snprintf(buffer, TMP_SIZE, "%d", cpu_info__cpu_addr(diag204_info_type,
  415. cpu_info));
  416. cpu_dir = hypfs_mkdir(cpus_dir, buffer);
  417. rc = hypfs_create_u64(cpu_dir, "mgmtime",
  418. cpu_info__acc_time(diag204_info_type, cpu_info) -
  419. cpu_info__lp_time(diag204_info_type, cpu_info));
  420. if (IS_ERR(rc))
  421. return PTR_ERR(rc);
  422. rc = hypfs_create_u64(cpu_dir, "cputime",
  423. cpu_info__lp_time(diag204_info_type, cpu_info));
  424. if (IS_ERR(rc))
  425. return PTR_ERR(rc);
  426. if (diag204_info_type == DIAG204_INFO_EXT) {
  427. rc = hypfs_create_u64(cpu_dir, "onlinetime",
  428. cpu_info__online_time(diag204_info_type,
  429. cpu_info));
  430. if (IS_ERR(rc))
  431. return PTR_ERR(rc);
  432. }
  433. diag224_idx2name(cpu_info__ctidx(diag204_info_type, cpu_info), buffer);
  434. rc = hypfs_create_str(cpu_dir, "type", buffer);
  435. return PTR_ERR_OR_ZERO(rc);
  436. }
  437. static void *hypfs_create_lpar_files(struct dentry *systems_dir, void *part_hdr)
  438. {
  439. struct dentry *cpus_dir;
  440. struct dentry *lpar_dir;
  441. char lpar_name[DIAG204_LPAR_NAME_LEN + 1];
  442. void *cpu_info;
  443. int i;
  444. part_hdr__part_name(diag204_info_type, part_hdr, lpar_name);
  445. lpar_name[DIAG204_LPAR_NAME_LEN] = 0;
  446. lpar_dir = hypfs_mkdir(systems_dir, lpar_name);
  447. if (IS_ERR(lpar_dir))
  448. return lpar_dir;
  449. cpus_dir = hypfs_mkdir(lpar_dir, "cpus");
  450. if (IS_ERR(cpus_dir))
  451. return cpus_dir;
  452. cpu_info = part_hdr + part_hdr__size(diag204_info_type);
  453. for (i = 0; i < part_hdr__rcpus(diag204_info_type, part_hdr); i++) {
  454. int rc;
  455. rc = hypfs_create_cpu_files(cpus_dir, cpu_info);
  456. if (rc)
  457. return ERR_PTR(rc);
  458. cpu_info += cpu_info__size(diag204_info_type);
  459. }
  460. return cpu_info;
  461. }
  462. static int hypfs_create_phys_cpu_files(struct dentry *cpus_dir, void *cpu_info)
  463. {
  464. struct dentry *cpu_dir;
  465. char buffer[TMP_SIZE];
  466. void *rc;
  467. snprintf(buffer, TMP_SIZE, "%i", phys_cpu__cpu_addr(diag204_info_type,
  468. cpu_info));
  469. cpu_dir = hypfs_mkdir(cpus_dir, buffer);
  470. if (IS_ERR(cpu_dir))
  471. return PTR_ERR(cpu_dir);
  472. rc = hypfs_create_u64(cpu_dir, "mgmtime",
  473. phys_cpu__mgm_time(diag204_info_type, cpu_info));
  474. if (IS_ERR(rc))
  475. return PTR_ERR(rc);
  476. diag224_idx2name(phys_cpu__ctidx(diag204_info_type, cpu_info), buffer);
  477. rc = hypfs_create_str(cpu_dir, "type", buffer);
  478. return PTR_ERR_OR_ZERO(rc);
  479. }
  480. static void *hypfs_create_phys_files(struct dentry *parent_dir, void *phys_hdr)
  481. {
  482. int i;
  483. void *cpu_info;
  484. struct dentry *cpus_dir;
  485. cpus_dir = hypfs_mkdir(parent_dir, "cpus");
  486. if (IS_ERR(cpus_dir))
  487. return cpus_dir;
  488. cpu_info = phys_hdr + phys_hdr__size(diag204_info_type);
  489. for (i = 0; i < phys_hdr__cpus(diag204_info_type, phys_hdr); i++) {
  490. int rc;
  491. rc = hypfs_create_phys_cpu_files(cpus_dir, cpu_info);
  492. if (rc)
  493. return ERR_PTR(rc);
  494. cpu_info += phys_cpu__size(diag204_info_type);
  495. }
  496. return cpu_info;
  497. }
  498. int hypfs_diag_create_files(struct dentry *root)
  499. {
  500. struct dentry *systems_dir, *hyp_dir;
  501. void *time_hdr, *part_hdr;
  502. int i, rc;
  503. void *buffer, *ptr;
  504. buffer = diag204_store();
  505. if (IS_ERR(buffer))
  506. return PTR_ERR(buffer);
  507. systems_dir = hypfs_mkdir(root, "systems");
  508. if (IS_ERR(systems_dir)) {
  509. rc = PTR_ERR(systems_dir);
  510. goto err_out;
  511. }
  512. time_hdr = (struct x_info_blk_hdr *)buffer;
  513. part_hdr = time_hdr + info_blk_hdr__size(diag204_info_type);
  514. for (i = 0; i < info_blk_hdr__npar(diag204_info_type, time_hdr); i++) {
  515. part_hdr = hypfs_create_lpar_files(systems_dir, part_hdr);
  516. if (IS_ERR(part_hdr)) {
  517. rc = PTR_ERR(part_hdr);
  518. goto err_out;
  519. }
  520. }
  521. if (info_blk_hdr__flags(diag204_info_type, time_hdr) &
  522. DIAG204_LPAR_PHYS_FLG) {
  523. ptr = hypfs_create_phys_files(root, part_hdr);
  524. if (IS_ERR(ptr)) {
  525. rc = PTR_ERR(ptr);
  526. goto err_out;
  527. }
  528. }
  529. hyp_dir = hypfs_mkdir(root, "hyp");
  530. if (IS_ERR(hyp_dir)) {
  531. rc = PTR_ERR(hyp_dir);
  532. goto err_out;
  533. }
  534. ptr = hypfs_create_str(hyp_dir, "type", "LPAR Hypervisor");
  535. if (IS_ERR(ptr)) {
  536. rc = PTR_ERR(ptr);
  537. goto err_out;
  538. }
  539. rc = 0;
  540. err_out:
  541. return rc;
  542. }