Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Hypervisor Maintenance Interrupt (HMI) handling.
0004  *
0005  * Copyright 2015 IBM Corporation
0006  * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
0007  */
0008 
0009 #undef DEBUG
0010 
0011 #include <linux/types.h>
0012 #include <linux/compiler.h>
0013 #include <asm/paca.h>
0014 #include <asm/hmi.h>
0015 #include <asm/processor.h>
0016 
0017 void wait_for_subcore_guest_exit(void)
0018 {
0019     int i;
0020 
0021     /*
0022      * NULL bitmap pointer indicates that KVM module hasn't
0023      * been loaded yet and hence no guests are running, or running
0024      * on POWER9 or newer CPU.
0025      *
0026      * If no KVM is in use, no need to co-ordinate among threads
0027      * as all of them will always be in host and no one is going
0028      * to modify TB other than the opal hmi handler.
0029      *
0030      * POWER9 and newer don't need this synchronisation.
0031      *
0032      * Hence, just return from here.
0033      */
0034     if (!local_paca->sibling_subcore_state)
0035         return;
0036 
0037     for (i = 0; i < MAX_SUBCORE_PER_CORE; i++)
0038         while (local_paca->sibling_subcore_state->in_guest[i])
0039             cpu_relax();
0040 }
0041 
0042 void wait_for_tb_resync(void)
0043 {
0044     if (!local_paca->sibling_subcore_state)
0045         return;
0046 
0047     while (test_bit(CORE_TB_RESYNC_REQ_BIT,
0048                 &local_paca->sibling_subcore_state->flags))
0049         cpu_relax();
0050 }