162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Hypervisor Maintenance Interrupt header file.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright 2015 IBM Corporation
662306a36Sopenharmony_ci * Author: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#ifndef __ASM_PPC64_HMI_H__
1062306a36Sopenharmony_ci#define __ASM_PPC64_HMI_H__
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#define	CORE_TB_RESYNC_REQ_BIT		63
1562306a36Sopenharmony_ci#define MAX_SUBCORE_PER_CORE		4
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci/*
1862306a36Sopenharmony_ci * sibling_subcore_state structure is used to co-ordinate all threads
1962306a36Sopenharmony_ci * during HMI to avoid TB corruption. This structure is allocated once
2062306a36Sopenharmony_ci * per each core and shared by all threads on that core.
2162306a36Sopenharmony_ci */
2262306a36Sopenharmony_cistruct sibling_subcore_state {
2362306a36Sopenharmony_ci	unsigned long	flags;
2462306a36Sopenharmony_ci	u8		in_guest[MAX_SUBCORE_PER_CORE];
2562306a36Sopenharmony_ci};
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ciextern void wait_for_subcore_guest_exit(void);
2862306a36Sopenharmony_ciextern void wait_for_tb_resync(void);
2962306a36Sopenharmony_ci#else
3062306a36Sopenharmony_cistatic inline void wait_for_subcore_guest_exit(void) { }
3162306a36Sopenharmony_cistatic inline void wait_for_tb_resync(void) { }
3262306a36Sopenharmony_ci#endif
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_cistruct pt_regs;
3562306a36Sopenharmony_ciextern long hmi_handle_debugtrig(struct pt_regs *regs);
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci#endif /* __ASM_PPC64_HMI_H__ */
38