kexec_image.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Image loader for kexec_file_load system call.
  4. *
  5. * Copyright IBM Corp. 2018
  6. *
  7. * Author(s): Philipp Rudo <prudo@linux.vnet.ibm.com>
  8. */
  9. #include <linux/errno.h>
  10. #include <linux/kernel.h>
  11. #include <linux/kexec.h>
  12. #include <asm/ipl.h>
  13. #include <asm/setup.h>
  14. static int kexec_file_add_kernel_image(struct kimage *image,
  15. struct s390_load_data *data)
  16. {
  17. struct kexec_buf buf;
  18. buf.image = image;
  19. buf.buffer = image->kernel_buf;
  20. buf.bufsz = image->kernel_buf_len;
  21. buf.mem = 0;
  22. #ifdef CONFIG_CRASH_DUMP
  23. if (image->type == KEXEC_TYPE_CRASH)
  24. buf.mem += crashk_res.start;
  25. #endif
  26. buf.memsz = buf.bufsz;
  27. data->kernel_buf = image->kernel_buf;
  28. data->kernel_mem = buf.mem;
  29. data->parm = image->kernel_buf + PARMAREA;
  30. data->memsz += buf.memsz;
  31. ipl_report_add_component(data->report, &buf,
  32. IPL_RB_COMPONENT_FLAG_SIGNED |
  33. IPL_RB_COMPONENT_FLAG_VERIFIED,
  34. IPL_RB_CERT_UNKNOWN);
  35. return kexec_add_buffer(&buf);
  36. }
  37. static void *s390_image_load(struct kimage *image,
  38. char *kernel, unsigned long kernel_len,
  39. char *initrd, unsigned long initrd_len,
  40. char *cmdline, unsigned long cmdline_len)
  41. {
  42. return kexec_file_add_components(image, kexec_file_add_kernel_image);
  43. }
  44. static int s390_image_probe(const char *buf, unsigned long len)
  45. {
  46. /* Can't reliably tell if an image is valid. Therefore give the
  47. * user whatever he wants.
  48. */
  49. return 0;
  50. }
  51. const struct kexec_file_ops s390_kexec_image_ops = {
  52. .probe = s390_image_probe,
  53. .load = s390_image_load,
  54. #ifdef CONFIG_KEXEC_SIG
  55. .verify_sig = s390_verify_sig,
  56. #endif /* CONFIG_KEXEC_SIG */
  57. };