18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright 2012 Paul Mackerras, IBM Corp. <paulus@au1.ibm.com>
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#include <linux/types.h>
88c2ecf20Sopenharmony_ci#include <linux/string.h>
98c2ecf20Sopenharmony_ci#include <linux/kvm.h>
108c2ecf20Sopenharmony_ci#include <linux/kvm_host.h>
118c2ecf20Sopenharmony_ci#include <linux/kernel.h>
128c2ecf20Sopenharmony_ci#include <asm/lppaca.h>
138c2ecf20Sopenharmony_ci#include <asm/opal.h>
148c2ecf20Sopenharmony_ci#include <asm/mce.h>
158c2ecf20Sopenharmony_ci#include <asm/machdep.h>
168c2ecf20Sopenharmony_ci#include <asm/cputhreads.h>
178c2ecf20Sopenharmony_ci#include <asm/hmi.h>
188c2ecf20Sopenharmony_ci#include <asm/kvm_ppc.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci/* SRR1 bits for machine check on POWER7 */
218c2ecf20Sopenharmony_ci#define SRR1_MC_LDSTERR		(1ul << (63-42))
228c2ecf20Sopenharmony_ci#define SRR1_MC_IFETCH_SH	(63-45)
238c2ecf20Sopenharmony_ci#define SRR1_MC_IFETCH_MASK	0x7
248c2ecf20Sopenharmony_ci#define SRR1_MC_IFETCH_SLBPAR		2	/* SLB parity error */
258c2ecf20Sopenharmony_ci#define SRR1_MC_IFETCH_SLBMULTI		3	/* SLB multi-hit */
268c2ecf20Sopenharmony_ci#define SRR1_MC_IFETCH_SLBPARMULTI	4	/* SLB parity + multi-hit */
278c2ecf20Sopenharmony_ci#define SRR1_MC_IFETCH_TLBMULTI		5	/* I-TLB multi-hit */
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci/* DSISR bits for machine check on POWER7 */
308c2ecf20Sopenharmony_ci#define DSISR_MC_DERAT_MULTI	0x800		/* D-ERAT multi-hit */
318c2ecf20Sopenharmony_ci#define DSISR_MC_TLB_MULTI	0x400		/* D-TLB multi-hit */
328c2ecf20Sopenharmony_ci#define DSISR_MC_SLB_PARITY	0x100		/* SLB parity error */
338c2ecf20Sopenharmony_ci#define DSISR_MC_SLB_MULTI	0x080		/* SLB multi-hit */
348c2ecf20Sopenharmony_ci#define DSISR_MC_SLB_PARMULTI	0x040		/* SLB parity + multi-hit */
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/* POWER7 SLB flush and reload */
378c2ecf20Sopenharmony_cistatic void reload_slb(struct kvm_vcpu *vcpu)
388c2ecf20Sopenharmony_ci{
398c2ecf20Sopenharmony_ci	struct slb_shadow *slb;
408c2ecf20Sopenharmony_ci	unsigned long i, n;
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	/* First clear out SLB */
438c2ecf20Sopenharmony_ci	asm volatile("slbmte %0,%0; slbia" : : "r" (0));
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci	/* Do they have an SLB shadow buffer registered? */
468c2ecf20Sopenharmony_ci	slb = vcpu->arch.slb_shadow.pinned_addr;
478c2ecf20Sopenharmony_ci	if (!slb)
488c2ecf20Sopenharmony_ci		return;
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci	/* Sanity check */
518c2ecf20Sopenharmony_ci	n = min_t(u32, be32_to_cpu(slb->persistent), SLB_MIN_SIZE);
528c2ecf20Sopenharmony_ci	if ((void *) &slb->save_area[n] > vcpu->arch.slb_shadow.pinned_end)
538c2ecf20Sopenharmony_ci		return;
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	/* Load up the SLB from that */
568c2ecf20Sopenharmony_ci	for (i = 0; i < n; ++i) {
578c2ecf20Sopenharmony_ci		unsigned long rb = be64_to_cpu(slb->save_area[i].esid);
588c2ecf20Sopenharmony_ci		unsigned long rs = be64_to_cpu(slb->save_area[i].vsid);
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci		rb = (rb & ~0xFFFul) | i;	/* insert entry number */
618c2ecf20Sopenharmony_ci		asm volatile("slbmte %0,%1" : : "r" (rs), "r" (rb));
628c2ecf20Sopenharmony_ci	}
638c2ecf20Sopenharmony_ci}
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/*
668c2ecf20Sopenharmony_ci * On POWER7, see if we can handle a machine check that occurred inside
678c2ecf20Sopenharmony_ci * the guest in real mode, without switching to the host partition.
688c2ecf20Sopenharmony_ci */
698c2ecf20Sopenharmony_cistatic void kvmppc_realmode_mc_power7(struct kvm_vcpu *vcpu)
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	unsigned long srr1 = vcpu->arch.shregs.msr;
728c2ecf20Sopenharmony_ci	struct machine_check_event mce_evt;
738c2ecf20Sopenharmony_ci	long handled = 1;
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci	if (srr1 & SRR1_MC_LDSTERR) {
768c2ecf20Sopenharmony_ci		/* error on load/store */
778c2ecf20Sopenharmony_ci		unsigned long dsisr = vcpu->arch.shregs.dsisr;
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci		if (dsisr & (DSISR_MC_SLB_PARMULTI | DSISR_MC_SLB_MULTI |
808c2ecf20Sopenharmony_ci			     DSISR_MC_SLB_PARITY | DSISR_MC_DERAT_MULTI)) {
818c2ecf20Sopenharmony_ci			/* flush and reload SLB; flushes D-ERAT too */
828c2ecf20Sopenharmony_ci			reload_slb(vcpu);
838c2ecf20Sopenharmony_ci			dsisr &= ~(DSISR_MC_SLB_PARMULTI | DSISR_MC_SLB_MULTI |
848c2ecf20Sopenharmony_ci				   DSISR_MC_SLB_PARITY | DSISR_MC_DERAT_MULTI);
858c2ecf20Sopenharmony_ci		}
868c2ecf20Sopenharmony_ci		if (dsisr & DSISR_MC_TLB_MULTI) {
878c2ecf20Sopenharmony_ci			tlbiel_all_lpid(vcpu->kvm->arch.radix);
888c2ecf20Sopenharmony_ci			dsisr &= ~DSISR_MC_TLB_MULTI;
898c2ecf20Sopenharmony_ci		}
908c2ecf20Sopenharmony_ci		/* Any other errors we don't understand? */
918c2ecf20Sopenharmony_ci		if (dsisr & 0xffffffffUL)
928c2ecf20Sopenharmony_ci			handled = 0;
938c2ecf20Sopenharmony_ci	}
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci	switch ((srr1 >> SRR1_MC_IFETCH_SH) & SRR1_MC_IFETCH_MASK) {
968c2ecf20Sopenharmony_ci	case 0:
978c2ecf20Sopenharmony_ci		break;
988c2ecf20Sopenharmony_ci	case SRR1_MC_IFETCH_SLBPAR:
998c2ecf20Sopenharmony_ci	case SRR1_MC_IFETCH_SLBMULTI:
1008c2ecf20Sopenharmony_ci	case SRR1_MC_IFETCH_SLBPARMULTI:
1018c2ecf20Sopenharmony_ci		reload_slb(vcpu);
1028c2ecf20Sopenharmony_ci		break;
1038c2ecf20Sopenharmony_ci	case SRR1_MC_IFETCH_TLBMULTI:
1048c2ecf20Sopenharmony_ci		tlbiel_all_lpid(vcpu->kvm->arch.radix);
1058c2ecf20Sopenharmony_ci		break;
1068c2ecf20Sopenharmony_ci	default:
1078c2ecf20Sopenharmony_ci		handled = 0;
1088c2ecf20Sopenharmony_ci	}
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_ci	/*
1118c2ecf20Sopenharmony_ci	 * Now get the event and stash it in the vcpu struct so it can
1128c2ecf20Sopenharmony_ci	 * be handled by the primary thread in virtual mode.  We can't
1138c2ecf20Sopenharmony_ci	 * call machine_check_queue_event() here if we are running on
1148c2ecf20Sopenharmony_ci	 * an offline secondary thread.
1158c2ecf20Sopenharmony_ci	 */
1168c2ecf20Sopenharmony_ci	if (get_mce_event(&mce_evt, MCE_EVENT_RELEASE)) {
1178c2ecf20Sopenharmony_ci		if (handled && mce_evt.version == MCE_V1)
1188c2ecf20Sopenharmony_ci			mce_evt.disposition = MCE_DISPOSITION_RECOVERED;
1198c2ecf20Sopenharmony_ci	} else {
1208c2ecf20Sopenharmony_ci		memset(&mce_evt, 0, sizeof(mce_evt));
1218c2ecf20Sopenharmony_ci	}
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci	vcpu->arch.mce_evt = mce_evt;
1248c2ecf20Sopenharmony_ci}
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_civoid kvmppc_realmode_machine_check(struct kvm_vcpu *vcpu)
1278c2ecf20Sopenharmony_ci{
1288c2ecf20Sopenharmony_ci	kvmppc_realmode_mc_power7(vcpu);
1298c2ecf20Sopenharmony_ci}
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ci/* Check if dynamic split is in force and return subcore size accordingly. */
1328c2ecf20Sopenharmony_cistatic inline int kvmppc_cur_subcore_size(void)
1338c2ecf20Sopenharmony_ci{
1348c2ecf20Sopenharmony_ci	if (local_paca->kvm_hstate.kvm_split_mode)
1358c2ecf20Sopenharmony_ci		return local_paca->kvm_hstate.kvm_split_mode->subcore_size;
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci	return threads_per_subcore;
1388c2ecf20Sopenharmony_ci}
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_civoid kvmppc_subcore_enter_guest(void)
1418c2ecf20Sopenharmony_ci{
1428c2ecf20Sopenharmony_ci	int thread_id, subcore_id;
1438c2ecf20Sopenharmony_ci
1448c2ecf20Sopenharmony_ci	thread_id = cpu_thread_in_core(local_paca->paca_index);
1458c2ecf20Sopenharmony_ci	subcore_id = thread_id / kvmppc_cur_subcore_size();
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci	local_paca->sibling_subcore_state->in_guest[subcore_id] = 1;
1488c2ecf20Sopenharmony_ci}
1498c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(kvmppc_subcore_enter_guest);
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_civoid kvmppc_subcore_exit_guest(void)
1528c2ecf20Sopenharmony_ci{
1538c2ecf20Sopenharmony_ci	int thread_id, subcore_id;
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci	thread_id = cpu_thread_in_core(local_paca->paca_index);
1568c2ecf20Sopenharmony_ci	subcore_id = thread_id / kvmppc_cur_subcore_size();
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ci	local_paca->sibling_subcore_state->in_guest[subcore_id] = 0;
1598c2ecf20Sopenharmony_ci}
1608c2ecf20Sopenharmony_ciEXPORT_SYMBOL_GPL(kvmppc_subcore_exit_guest);
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_cistatic bool kvmppc_tb_resync_required(void)
1638c2ecf20Sopenharmony_ci{
1648c2ecf20Sopenharmony_ci	if (test_and_set_bit(CORE_TB_RESYNC_REQ_BIT,
1658c2ecf20Sopenharmony_ci				&local_paca->sibling_subcore_state->flags))
1668c2ecf20Sopenharmony_ci		return false;
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci	return true;
1698c2ecf20Sopenharmony_ci}
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_cistatic void kvmppc_tb_resync_done(void)
1728c2ecf20Sopenharmony_ci{
1738c2ecf20Sopenharmony_ci	clear_bit(CORE_TB_RESYNC_REQ_BIT,
1748c2ecf20Sopenharmony_ci			&local_paca->sibling_subcore_state->flags);
1758c2ecf20Sopenharmony_ci}
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ci/*
1788c2ecf20Sopenharmony_ci * kvmppc_realmode_hmi_handler() is called only by primary thread during
1798c2ecf20Sopenharmony_ci * guest exit path.
1808c2ecf20Sopenharmony_ci *
1818c2ecf20Sopenharmony_ci * There are multiple reasons why HMI could occur, one of them is
1828c2ecf20Sopenharmony_ci * Timebase (TB) error. If this HMI is due to TB error, then TB would
1838c2ecf20Sopenharmony_ci * have been in stopped state. The opal hmi handler Will fix it and
1848c2ecf20Sopenharmony_ci * restore the TB value with host timebase value. For HMI caused due
1858c2ecf20Sopenharmony_ci * to non-TB errors, opal hmi handler will not touch/restore TB register
1868c2ecf20Sopenharmony_ci * and hence there won't be any change in TB value.
1878c2ecf20Sopenharmony_ci *
1888c2ecf20Sopenharmony_ci * Since we are not sure about the cause of this HMI, we can't be sure
1898c2ecf20Sopenharmony_ci * about the content of TB register whether it holds guest or host timebase
1908c2ecf20Sopenharmony_ci * value. Hence the idea is to resync the TB on every HMI, so that we
1918c2ecf20Sopenharmony_ci * know about the exact state of the TB value. Resync TB call will
1928c2ecf20Sopenharmony_ci * restore TB to host timebase.
1938c2ecf20Sopenharmony_ci *
1948c2ecf20Sopenharmony_ci * Things to consider:
1958c2ecf20Sopenharmony_ci * - On TB error, HMI interrupt is reported on all the threads of the core
1968c2ecf20Sopenharmony_ci *   that has encountered TB error irrespective of split-core mode.
1978c2ecf20Sopenharmony_ci * - The very first thread on the core that get chance to fix TB error
1988c2ecf20Sopenharmony_ci *   would rsync the TB with local chipTOD value.
1998c2ecf20Sopenharmony_ci * - The resync TB is a core level action i.e. it will sync all the TBs
2008c2ecf20Sopenharmony_ci *   in that core independent of split-core mode. This means if we trigger
2018c2ecf20Sopenharmony_ci *   TB sync from a thread from one subcore, it would affect TB values of
2028c2ecf20Sopenharmony_ci *   sibling subcores of the same core.
2038c2ecf20Sopenharmony_ci *
2048c2ecf20Sopenharmony_ci * All threads need to co-ordinate before making opal hmi handler.
2058c2ecf20Sopenharmony_ci * All threads will use sibling_subcore_state->in_guest[] (shared by all
2068c2ecf20Sopenharmony_ci * threads in the core) in paca which holds information about whether
2078c2ecf20Sopenharmony_ci * sibling subcores are in Guest mode or host mode. The in_guest[] array
2088c2ecf20Sopenharmony_ci * is of size MAX_SUBCORE_PER_CORE=4, indexed using subcore id to set/unset
2098c2ecf20Sopenharmony_ci * subcore status. Only primary threads from each subcore is responsible
2108c2ecf20Sopenharmony_ci * to set/unset its designated array element while entering/exiting the
2118c2ecf20Sopenharmony_ci * guset.
2128c2ecf20Sopenharmony_ci *
2138c2ecf20Sopenharmony_ci * After invoking opal hmi handler call, one of the thread (of entire core)
2148c2ecf20Sopenharmony_ci * will need to resync the TB. Bit 63 from subcore state bitmap flags
2158c2ecf20Sopenharmony_ci * (sibling_subcore_state->flags) will be used to co-ordinate between
2168c2ecf20Sopenharmony_ci * primary threads to decide who takes up the responsibility.
2178c2ecf20Sopenharmony_ci *
2188c2ecf20Sopenharmony_ci * This is what we do:
2198c2ecf20Sopenharmony_ci * - Primary thread from each subcore tries to set resync required bit[63]
2208c2ecf20Sopenharmony_ci *   of paca->sibling_subcore_state->flags.
2218c2ecf20Sopenharmony_ci * - The first primary thread that is able to set the flag takes the
2228c2ecf20Sopenharmony_ci *   responsibility of TB resync. (Let us call it as thread leader)
2238c2ecf20Sopenharmony_ci * - All other threads which are in host will call
2248c2ecf20Sopenharmony_ci *   wait_for_subcore_guest_exit() and wait for in_guest[0-3] from
2258c2ecf20Sopenharmony_ci *   paca->sibling_subcore_state to get cleared.
2268c2ecf20Sopenharmony_ci * - All the primary thread will clear its subcore status from subcore
2278c2ecf20Sopenharmony_ci *   state in_guest[] array respectively.
2288c2ecf20Sopenharmony_ci * - Once all primary threads clear in_guest[0-3], all of them will invoke
2298c2ecf20Sopenharmony_ci *   opal hmi handler.
2308c2ecf20Sopenharmony_ci * - Now all threads will wait for TB resync to complete by invoking
2318c2ecf20Sopenharmony_ci *   wait_for_tb_resync() except the thread leader.
2328c2ecf20Sopenharmony_ci * - Thread leader will do a TB resync by invoking opal_resync_timebase()
2338c2ecf20Sopenharmony_ci *   call and the it will clear the resync required bit.
2348c2ecf20Sopenharmony_ci * - All other threads will now come out of resync wait loop and proceed
2358c2ecf20Sopenharmony_ci *   with individual execution.
2368c2ecf20Sopenharmony_ci * - On return of this function, primary thread will signal all
2378c2ecf20Sopenharmony_ci *   secondary threads to proceed.
2388c2ecf20Sopenharmony_ci * - All secondary threads will eventually call opal hmi handler on
2398c2ecf20Sopenharmony_ci *   their exit path.
2408c2ecf20Sopenharmony_ci *
2418c2ecf20Sopenharmony_ci * Returns 1 if the timebase offset should be applied, 0 if not.
2428c2ecf20Sopenharmony_ci */
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_cilong kvmppc_realmode_hmi_handler(void)
2458c2ecf20Sopenharmony_ci{
2468c2ecf20Sopenharmony_ci	bool resync_req;
2478c2ecf20Sopenharmony_ci
2488c2ecf20Sopenharmony_ci	local_paca->hmi_irqs++;
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ci	if (hmi_handle_debugtrig(NULL) >= 0)
2518c2ecf20Sopenharmony_ci		return 1;
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci	/*
2548c2ecf20Sopenharmony_ci	 * By now primary thread has already completed guest->host
2558c2ecf20Sopenharmony_ci	 * partition switch but haven't signaled secondaries yet.
2568c2ecf20Sopenharmony_ci	 * All the secondary threads on this subcore is waiting
2578c2ecf20Sopenharmony_ci	 * for primary thread to signal them to go ahead.
2588c2ecf20Sopenharmony_ci	 *
2598c2ecf20Sopenharmony_ci	 * For threads from subcore which isn't in guest, they all will
2608c2ecf20Sopenharmony_ci	 * wait until all other subcores on this core exit the guest.
2618c2ecf20Sopenharmony_ci	 *
2628c2ecf20Sopenharmony_ci	 * Now set the resync required bit. If you are the first to
2638c2ecf20Sopenharmony_ci	 * set this bit then kvmppc_tb_resync_required() function will
2648c2ecf20Sopenharmony_ci	 * return true. For rest all other subcores
2658c2ecf20Sopenharmony_ci	 * kvmppc_tb_resync_required() will return false.
2668c2ecf20Sopenharmony_ci	 *
2678c2ecf20Sopenharmony_ci	 * If resync_req == true, then this thread is responsible to
2688c2ecf20Sopenharmony_ci	 * initiate TB resync after hmi handler has completed.
2698c2ecf20Sopenharmony_ci	 * All other threads on this core will wait until this thread
2708c2ecf20Sopenharmony_ci	 * clears the resync required bit flag.
2718c2ecf20Sopenharmony_ci	 */
2728c2ecf20Sopenharmony_ci	resync_req = kvmppc_tb_resync_required();
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_ci	/* Reset the subcore status to indicate it has exited guest */
2758c2ecf20Sopenharmony_ci	kvmppc_subcore_exit_guest();
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_ci	/*
2788c2ecf20Sopenharmony_ci	 * Wait for other subcores on this core to exit the guest.
2798c2ecf20Sopenharmony_ci	 * All the primary threads and threads from subcore that are
2808c2ecf20Sopenharmony_ci	 * not in guest will wait here until all subcores are out
2818c2ecf20Sopenharmony_ci	 * of guest context.
2828c2ecf20Sopenharmony_ci	 */
2838c2ecf20Sopenharmony_ci	wait_for_subcore_guest_exit();
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci	/*
2868c2ecf20Sopenharmony_ci	 * At this point we are sure that primary threads from each
2878c2ecf20Sopenharmony_ci	 * subcore on this core have completed guest->host partition
2888c2ecf20Sopenharmony_ci	 * switch. Now it is safe to call HMI handler.
2898c2ecf20Sopenharmony_ci	 */
2908c2ecf20Sopenharmony_ci	if (ppc_md.hmi_exception_early)
2918c2ecf20Sopenharmony_ci		ppc_md.hmi_exception_early(NULL);
2928c2ecf20Sopenharmony_ci
2938c2ecf20Sopenharmony_ci	/*
2948c2ecf20Sopenharmony_ci	 * Check if this thread is responsible to resync TB.
2958c2ecf20Sopenharmony_ci	 * All other threads will wait until this thread completes the
2968c2ecf20Sopenharmony_ci	 * TB resync.
2978c2ecf20Sopenharmony_ci	 */
2988c2ecf20Sopenharmony_ci	if (resync_req) {
2998c2ecf20Sopenharmony_ci		opal_resync_timebase();
3008c2ecf20Sopenharmony_ci		/* Reset TB resync req bit */
3018c2ecf20Sopenharmony_ci		kvmppc_tb_resync_done();
3028c2ecf20Sopenharmony_ci	} else {
3038c2ecf20Sopenharmony_ci		wait_for_tb_resync();
3048c2ecf20Sopenharmony_ci	}
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci	/*
3078c2ecf20Sopenharmony_ci	 * Reset tb_offset_applied so the guest exit code won't try
3088c2ecf20Sopenharmony_ci	 * to subtract the previous timebase offset from the timebase.
3098c2ecf20Sopenharmony_ci	 */
3108c2ecf20Sopenharmony_ci	if (local_paca->kvm_hstate.kvm_vcore)
3118c2ecf20Sopenharmony_ci		local_paca->kvm_hstate.kvm_vcore->tb_offset_applied = 0;
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci	return 0;
3148c2ecf20Sopenharmony_ci}
315