kexec_image.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 <[email protected]>
  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. if (image->type == KEXEC_TYPE_CRASH)
  23. buf.mem += crashk_res.start;
  24. buf.memsz = buf.bufsz;
  25. data->kernel_buf = image->kernel_buf;
  26. data->kernel_mem = buf.mem;
  27. data->parm = image->kernel_buf + PARMAREA;
  28. data->memsz += buf.memsz;
  29. ipl_report_add_component(data->report, &buf,
  30. IPL_RB_COMPONENT_FLAG_SIGNED |
  31. IPL_RB_COMPONENT_FLAG_VERIFIED,
  32. IPL_RB_CERT_UNKNOWN);
  33. return kexec_add_buffer(&buf);
  34. }
  35. static void *s390_image_load(struct kimage *image,
  36. char *kernel, unsigned long kernel_len,
  37. char *initrd, unsigned long initrd_len,
  38. char *cmdline, unsigned long cmdline_len)
  39. {
  40. return kexec_file_add_components(image, kexec_file_add_kernel_image);
  41. }
  42. static int s390_image_probe(const char *buf, unsigned long len)
  43. {
  44. /* Can't reliably tell if an image is valid. Therefore give the
  45. * user whatever he wants.
  46. */
  47. return 0;
  48. }
  49. const struct kexec_file_ops s390_kexec_image_ops = {
  50. .probe = s390_image_probe,
  51. .load = s390_image_load,
  52. #ifdef CONFIG_KEXEC_SIG
  53. .verify_sig = s390_verify_sig,
  54. #endif /* CONFIG_KEXEC_SIG */
  55. };