book3s_hv_hmi.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Hypervisor Maintenance Interrupt (HMI) handling.
  4. *
  5. * Copyright 2015 IBM Corporation
  6. * Author: Mahesh Salgaonkar <[email protected]>
  7. */
  8. #undef DEBUG
  9. #include <linux/types.h>
  10. #include <linux/compiler.h>
  11. #include <asm/paca.h>
  12. #include <asm/hmi.h>
  13. #include <asm/processor.h>
  14. void wait_for_subcore_guest_exit(void)
  15. {
  16. int i;
  17. /*
  18. * NULL bitmap pointer indicates that KVM module hasn't
  19. * been loaded yet and hence no guests are running, or running
  20. * on POWER9 or newer CPU.
  21. *
  22. * If no KVM is in use, no need to co-ordinate among threads
  23. * as all of them will always be in host and no one is going
  24. * to modify TB other than the opal hmi handler.
  25. *
  26. * POWER9 and newer don't need this synchronisation.
  27. *
  28. * Hence, just return from here.
  29. */
  30. if (!local_paca->sibling_subcore_state)
  31. return;
  32. for (i = 0; i < MAX_SUBCORE_PER_CORE; i++)
  33. while (local_paca->sibling_subcore_state->in_guest[i])
  34. cpu_relax();
  35. }
  36. void wait_for_tb_resync(void)
  37. {
  38. if (!local_paca->sibling_subcore_state)
  39. return;
  40. while (test_bit(CORE_TB_RESYNC_REQ_BIT,
  41. &local_paca->sibling_subcore_state->flags))
  42. cpu_relax();
  43. }