kexec.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright 2006 Michael Ellerman, IBM Corporation
  4. */
  5. #include <linux/kernel.h>
  6. #include <linux/interrupt.h>
  7. #include <asm/setup.h>
  8. #include <asm/page.h>
  9. #include <asm/firmware.h>
  10. #include <asm/kexec.h>
  11. #include <asm/xics.h>
  12. #include <asm/xive.h>
  13. #include <asm/smp.h>
  14. #include <asm/plpar_wrappers.h>
  15. #include "pseries.h"
  16. void pseries_kexec_cpu_down(int crash_shutdown, int secondary)
  17. {
  18. /*
  19. * Don't risk a hypervisor call if we're crashing
  20. * XXX: Why? The hypervisor is not crashing. It might be better
  21. * to at least attempt unregister to avoid the hypervisor stepping
  22. * on our memory.
  23. */
  24. if (firmware_has_feature(FW_FEATURE_SPLPAR) && !crash_shutdown) {
  25. int ret;
  26. int cpu = smp_processor_id();
  27. int hwcpu = hard_smp_processor_id();
  28. if (get_lppaca()->dtl_enable_mask) {
  29. ret = unregister_dtl(hwcpu);
  30. if (ret) {
  31. pr_err("WARNING: DTL deregistration for cpu "
  32. "%d (hw %d) failed with %d\n",
  33. cpu, hwcpu, ret);
  34. }
  35. }
  36. ret = unregister_slb_shadow(hwcpu);
  37. if (ret) {
  38. pr_err("WARNING: SLB shadow buffer deregistration "
  39. "for cpu %d (hw %d) failed with %d\n",
  40. cpu, hwcpu, ret);
  41. }
  42. ret = unregister_vpa(hwcpu);
  43. if (ret) {
  44. pr_err("WARNING: VPA deregistration for cpu %d "
  45. "(hw %d) failed with %d\n", cpu, hwcpu, ret);
  46. }
  47. }
  48. if (xive_enabled()) {
  49. xive_teardown_cpu();
  50. if (!secondary)
  51. xive_shutdown();
  52. } else
  53. xics_kexec_teardown_cpu(secondary);
  54. }
  55. void pseries_machine_kexec(struct kimage *image)
  56. {
  57. if (firmware_has_feature(FW_FEATURE_SET_MODE))
  58. pseries_disable_reloc_on_exc();
  59. default_machine_kexec(image);
  60. }