book3s_hv_hmi.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Hypervisor Maintenance Interrupt (HMI) handling.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program.
  16. *
  17. * Copyright 2015 IBM Corporation
  18. * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
  19. */
  20. #undef DEBUG
  21. #include <linux/types.h>
  22. #include <linux/compiler.h>
  23. #include <asm/paca.h>
  24. #include <asm/hmi.h>
  25. void wait_for_subcore_guest_exit(void)
  26. {
  27. int i;
  28. /*
  29. * NULL bitmap pointer indicates that KVM module hasn't
  30. * been loaded yet and hence no guests are running.
  31. * If no KVM is in use, no need to co-ordinate among threads
  32. * as all of them will always be in host and no one is going
  33. * to modify TB other than the opal hmi handler.
  34. * Hence, just return from here.
  35. */
  36. if (!local_paca->sibling_subcore_state)
  37. return;
  38. for (i = 0; i < MAX_SUBCORE_PER_CORE; i++)
  39. while (local_paca->sibling_subcore_state->in_guest[i])
  40. cpu_relax();
  41. }
  42. void wait_for_tb_resync(void)
  43. {
  44. if (!local_paca->sibling_subcore_state)
  45. return;
  46. while (test_bit(CORE_TB_RESYNC_REQ_BIT,
  47. &local_paca->sibling_subcore_state->flags))
  48. cpu_relax();
  49. }