pgm_check_info.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/kernel.h>
  3. #include <linux/string.h>
  4. #include <asm/lowcore.h>
  5. #include <asm/setup.h>
  6. #include <asm/sclp.h>
  7. #include "boot.h"
  8. const char hex_asc[] = "0123456789abcdef";
  9. #define add_val_as_hex(dst, val) \
  10. __add_val_as_hex(dst, (const unsigned char *)&val, sizeof(val))
  11. static char *__add_val_as_hex(char *dst, const unsigned char *src, size_t count)
  12. {
  13. while (count--)
  14. dst = hex_byte_pack(dst, *src++);
  15. return dst;
  16. }
  17. static char *add_str(char *dst, char *src)
  18. {
  19. strcpy(dst, src);
  20. return dst + strlen(dst);
  21. }
  22. void print_pgm_check_info(void)
  23. {
  24. struct psw_bits *psw = &psw_bits(S390_lowcore.psw_save_area);
  25. unsigned short ilc = S390_lowcore.pgm_ilc >> 1;
  26. char buf[256];
  27. int row, col;
  28. char *p;
  29. add_str(buf, "Linux version ");
  30. strlcat(buf, kernel_version, sizeof(buf) - 1);
  31. strlcat(buf, "\n", sizeof(buf));
  32. sclp_early_printk(buf);
  33. p = add_str(buf, "Kernel fault: interruption code ");
  34. p = add_val_as_hex(buf + strlen(buf), S390_lowcore.pgm_code);
  35. p = add_str(p, " ilc:");
  36. *p++ = hex_asc_lo(ilc);
  37. add_str(p, "\n");
  38. sclp_early_printk(buf);
  39. if (kaslr_enabled) {
  40. p = add_str(buf, "Kernel random base: ");
  41. p = add_val_as_hex(p, __kaslr_offset);
  42. add_str(p, "\n");
  43. sclp_early_printk(buf);
  44. }
  45. p = add_str(buf, "PSW : ");
  46. p = add_val_as_hex(p, S390_lowcore.psw_save_area.mask);
  47. p = add_str(p, " ");
  48. p = add_val_as_hex(p, S390_lowcore.psw_save_area.addr);
  49. add_str(p, "\n");
  50. sclp_early_printk(buf);
  51. p = add_str(buf, " R:");
  52. *p++ = hex_asc_lo(psw->per);
  53. p = add_str(p, " T:");
  54. *p++ = hex_asc_lo(psw->dat);
  55. p = add_str(p, " IO:");
  56. *p++ = hex_asc_lo(psw->io);
  57. p = add_str(p, " EX:");
  58. *p++ = hex_asc_lo(psw->ext);
  59. p = add_str(p, " Key:");
  60. *p++ = hex_asc_lo(psw->key);
  61. p = add_str(p, " M:");
  62. *p++ = hex_asc_lo(psw->mcheck);
  63. p = add_str(p, " W:");
  64. *p++ = hex_asc_lo(psw->wait);
  65. p = add_str(p, " P:");
  66. *p++ = hex_asc_lo(psw->pstate);
  67. p = add_str(p, " AS:");
  68. *p++ = hex_asc_lo(psw->as);
  69. p = add_str(p, " CC:");
  70. *p++ = hex_asc_lo(psw->cc);
  71. p = add_str(p, " PM:");
  72. *p++ = hex_asc_lo(psw->pm);
  73. p = add_str(p, " RI:");
  74. *p++ = hex_asc_lo(psw->ri);
  75. p = add_str(p, " EA:");
  76. *p++ = hex_asc_lo(psw->eaba);
  77. add_str(p, "\n");
  78. sclp_early_printk(buf);
  79. for (row = 0; row < 4; row++) {
  80. p = add_str(buf, row == 0 ? "GPRS:" : " ");
  81. for (col = 0; col < 4; col++) {
  82. p = add_str(p, " ");
  83. p = add_val_as_hex(p, S390_lowcore.gpregs_save_area[row * 4 + col]);
  84. }
  85. add_str(p, "\n");
  86. sclp_early_printk(buf);
  87. }
  88. }