162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * ultra.S: Don't expand these all over the place...
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 1997, 2000, 2008 David S. Miller (davem@davemloft.net)
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include <linux/pgtable.h>
962306a36Sopenharmony_ci#include <asm/asi.h>
1062306a36Sopenharmony_ci#include <asm/page.h>
1162306a36Sopenharmony_ci#include <asm/spitfire.h>
1262306a36Sopenharmony_ci#include <asm/mmu_context.h>
1362306a36Sopenharmony_ci#include <asm/mmu.h>
1462306a36Sopenharmony_ci#include <asm/pil.h>
1562306a36Sopenharmony_ci#include <asm/head.h>
1662306a36Sopenharmony_ci#include <asm/thread_info.h>
1762306a36Sopenharmony_ci#include <asm/cacheflush.h>
1862306a36Sopenharmony_ci#include <asm/hypervisor.h>
1962306a36Sopenharmony_ci#include <asm/cpudata.h>
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci	/* Basically, most of the Spitfire vs. Cheetah madness
2262306a36Sopenharmony_ci	 * has to do with the fact that Cheetah does not support
2362306a36Sopenharmony_ci	 * IMMU flushes out of the secondary context.  Someone needs
2462306a36Sopenharmony_ci	 * to throw a south lake birthday party for the folks
2562306a36Sopenharmony_ci	 * in Microelectronics who refused to fix this shit.
2662306a36Sopenharmony_ci	 */
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci	/* This file is meant to be read efficiently by the CPU, not humans.
2962306a36Sopenharmony_ci	 * Staraj sie tego nikomu nie pierdolnac...
3062306a36Sopenharmony_ci	 */
3162306a36Sopenharmony_ci	.text
3262306a36Sopenharmony_ci	.align		32
3362306a36Sopenharmony_ci	.globl		__flush_tlb_mm
3462306a36Sopenharmony_ci__flush_tlb_mm:		/* 19 insns */
3562306a36Sopenharmony_ci	/* %o0=(ctx & TAG_CONTEXT_BITS), %o1=SECONDARY_CONTEXT */
3662306a36Sopenharmony_ci	ldxa		[%o1] ASI_DMMU, %g2
3762306a36Sopenharmony_ci	cmp		%g2, %o0
3862306a36Sopenharmony_ci	bne,pn		%icc, __spitfire_flush_tlb_mm_slow
3962306a36Sopenharmony_ci	 mov		0x50, %g3
4062306a36Sopenharmony_ci	stxa		%g0, [%g3] ASI_DMMU_DEMAP
4162306a36Sopenharmony_ci	stxa		%g0, [%g3] ASI_IMMU_DEMAP
4262306a36Sopenharmony_ci	sethi		%hi(KERNBASE), %g3
4362306a36Sopenharmony_ci	flush		%g3
4462306a36Sopenharmony_ci	retl
4562306a36Sopenharmony_ci	 nop
4662306a36Sopenharmony_ci	nop
4762306a36Sopenharmony_ci	nop
4862306a36Sopenharmony_ci	nop
4962306a36Sopenharmony_ci	nop
5062306a36Sopenharmony_ci	nop
5162306a36Sopenharmony_ci	nop
5262306a36Sopenharmony_ci	nop
5362306a36Sopenharmony_ci	nop
5462306a36Sopenharmony_ci	nop
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci	.align		32
5762306a36Sopenharmony_ci	.globl		__flush_tlb_page
5862306a36Sopenharmony_ci__flush_tlb_page:	/* 22 insns */
5962306a36Sopenharmony_ci	/* %o0 = context, %o1 = vaddr */
6062306a36Sopenharmony_ci	rdpr		%pstate, %g7
6162306a36Sopenharmony_ci	andn		%g7, PSTATE_IE, %g2
6262306a36Sopenharmony_ci	wrpr		%g2, %pstate
6362306a36Sopenharmony_ci	mov		SECONDARY_CONTEXT, %o4
6462306a36Sopenharmony_ci	ldxa		[%o4] ASI_DMMU, %g2
6562306a36Sopenharmony_ci	stxa		%o0, [%o4] ASI_DMMU
6662306a36Sopenharmony_ci	andcc		%o1, 1, %g0
6762306a36Sopenharmony_ci	andn		%o1, 1, %o3
6862306a36Sopenharmony_ci	be,pn		%icc, 1f
6962306a36Sopenharmony_ci	 or		%o3, 0x10, %o3
7062306a36Sopenharmony_ci	stxa		%g0, [%o3] ASI_IMMU_DEMAP
7162306a36Sopenharmony_ci1:	stxa		%g0, [%o3] ASI_DMMU_DEMAP
7262306a36Sopenharmony_ci	membar		#Sync
7362306a36Sopenharmony_ci	stxa		%g2, [%o4] ASI_DMMU
7462306a36Sopenharmony_ci	sethi		%hi(KERNBASE), %o4
7562306a36Sopenharmony_ci	flush		%o4
7662306a36Sopenharmony_ci	retl
7762306a36Sopenharmony_ci	 wrpr		%g7, 0x0, %pstate
7862306a36Sopenharmony_ci	nop
7962306a36Sopenharmony_ci	nop
8062306a36Sopenharmony_ci	nop
8162306a36Sopenharmony_ci	nop
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci	.align		32
8462306a36Sopenharmony_ci	.globl		__flush_tlb_pending
8562306a36Sopenharmony_ci__flush_tlb_pending:	/* 27 insns */
8662306a36Sopenharmony_ci	/* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
8762306a36Sopenharmony_ci	rdpr		%pstate, %g7
8862306a36Sopenharmony_ci	sllx		%o1, 3, %o1
8962306a36Sopenharmony_ci	andn		%g7, PSTATE_IE, %g2
9062306a36Sopenharmony_ci	wrpr		%g2, %pstate
9162306a36Sopenharmony_ci	mov		SECONDARY_CONTEXT, %o4
9262306a36Sopenharmony_ci	ldxa		[%o4] ASI_DMMU, %g2
9362306a36Sopenharmony_ci	stxa		%o0, [%o4] ASI_DMMU
9462306a36Sopenharmony_ci1:	sub		%o1, (1 << 3), %o1
9562306a36Sopenharmony_ci	ldx		[%o2 + %o1], %o3
9662306a36Sopenharmony_ci	andcc		%o3, 1, %g0
9762306a36Sopenharmony_ci	andn		%o3, 1, %o3
9862306a36Sopenharmony_ci	be,pn		%icc, 2f
9962306a36Sopenharmony_ci	 or		%o3, 0x10, %o3
10062306a36Sopenharmony_ci	stxa		%g0, [%o3] ASI_IMMU_DEMAP
10162306a36Sopenharmony_ci2:	stxa		%g0, [%o3] ASI_DMMU_DEMAP
10262306a36Sopenharmony_ci	membar		#Sync
10362306a36Sopenharmony_ci	brnz,pt		%o1, 1b
10462306a36Sopenharmony_ci	 nop
10562306a36Sopenharmony_ci	stxa		%g2, [%o4] ASI_DMMU
10662306a36Sopenharmony_ci	sethi		%hi(KERNBASE), %o4
10762306a36Sopenharmony_ci	flush		%o4
10862306a36Sopenharmony_ci	retl
10962306a36Sopenharmony_ci	 wrpr		%g7, 0x0, %pstate
11062306a36Sopenharmony_ci	nop
11162306a36Sopenharmony_ci	nop
11262306a36Sopenharmony_ci	nop
11362306a36Sopenharmony_ci	nop
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci	.align		32
11662306a36Sopenharmony_ci	.globl		__flush_tlb_kernel_range
11762306a36Sopenharmony_ci__flush_tlb_kernel_range:	/* 31 insns */
11862306a36Sopenharmony_ci	/* %o0=start, %o1=end */
11962306a36Sopenharmony_ci	cmp		%o0, %o1
12062306a36Sopenharmony_ci	be,pn		%xcc, 2f
12162306a36Sopenharmony_ci	 sub		%o1, %o0, %o3
12262306a36Sopenharmony_ci	srlx		%o3, 18, %o4
12362306a36Sopenharmony_ci	brnz,pn		%o4, __spitfire_flush_tlb_kernel_range_slow
12462306a36Sopenharmony_ci	 sethi		%hi(PAGE_SIZE), %o4
12562306a36Sopenharmony_ci	sub		%o3, %o4, %o3
12662306a36Sopenharmony_ci	or		%o0, 0x20, %o0		! Nucleus
12762306a36Sopenharmony_ci1:	stxa		%g0, [%o0 + %o3] ASI_DMMU_DEMAP
12862306a36Sopenharmony_ci	stxa		%g0, [%o0 + %o3] ASI_IMMU_DEMAP
12962306a36Sopenharmony_ci	membar		#Sync
13062306a36Sopenharmony_ci	brnz,pt		%o3, 1b
13162306a36Sopenharmony_ci	 sub		%o3, %o4, %o3
13262306a36Sopenharmony_ci2:	sethi		%hi(KERNBASE), %o3
13362306a36Sopenharmony_ci	flush		%o3
13462306a36Sopenharmony_ci	retl
13562306a36Sopenharmony_ci	 nop
13662306a36Sopenharmony_ci	nop
13762306a36Sopenharmony_ci	nop
13862306a36Sopenharmony_ci	nop
13962306a36Sopenharmony_ci	nop
14062306a36Sopenharmony_ci	nop
14162306a36Sopenharmony_ci	nop
14262306a36Sopenharmony_ci	nop
14362306a36Sopenharmony_ci	nop
14462306a36Sopenharmony_ci	nop
14562306a36Sopenharmony_ci	nop
14662306a36Sopenharmony_ci	nop
14762306a36Sopenharmony_ci	nop
14862306a36Sopenharmony_ci	nop
14962306a36Sopenharmony_ci	nop
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci__spitfire_flush_tlb_kernel_range_slow:
15262306a36Sopenharmony_ci	mov		63 * 8, %o4
15362306a36Sopenharmony_ci1:	ldxa		[%o4] ASI_ITLB_DATA_ACCESS, %o3
15462306a36Sopenharmony_ci	andcc		%o3, 0x40, %g0			/* _PAGE_L_4U */
15562306a36Sopenharmony_ci	bne,pn		%xcc, 2f
15662306a36Sopenharmony_ci	 mov		TLB_TAG_ACCESS, %o3
15762306a36Sopenharmony_ci	stxa		%g0, [%o3] ASI_IMMU
15862306a36Sopenharmony_ci	stxa		%g0, [%o4] ASI_ITLB_DATA_ACCESS
15962306a36Sopenharmony_ci	membar		#Sync
16062306a36Sopenharmony_ci2:	ldxa		[%o4] ASI_DTLB_DATA_ACCESS, %o3
16162306a36Sopenharmony_ci	andcc		%o3, 0x40, %g0
16262306a36Sopenharmony_ci	bne,pn		%xcc, 2f
16362306a36Sopenharmony_ci	 mov		TLB_TAG_ACCESS, %o3
16462306a36Sopenharmony_ci	stxa		%g0, [%o3] ASI_DMMU
16562306a36Sopenharmony_ci	stxa		%g0, [%o4] ASI_DTLB_DATA_ACCESS
16662306a36Sopenharmony_ci	membar		#Sync
16762306a36Sopenharmony_ci2:	sub		%o4, 8, %o4
16862306a36Sopenharmony_ci	brgez,pt	%o4, 1b
16962306a36Sopenharmony_ci	 nop
17062306a36Sopenharmony_ci	retl
17162306a36Sopenharmony_ci	 nop
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci__spitfire_flush_tlb_mm_slow:
17462306a36Sopenharmony_ci	rdpr		%pstate, %g1
17562306a36Sopenharmony_ci	wrpr		%g1, PSTATE_IE, %pstate
17662306a36Sopenharmony_ci	stxa		%o0, [%o1] ASI_DMMU
17762306a36Sopenharmony_ci	stxa		%g0, [%g3] ASI_DMMU_DEMAP
17862306a36Sopenharmony_ci	stxa		%g0, [%g3] ASI_IMMU_DEMAP
17962306a36Sopenharmony_ci	flush		%g6
18062306a36Sopenharmony_ci	stxa		%g2, [%o1] ASI_DMMU
18162306a36Sopenharmony_ci	sethi		%hi(KERNBASE), %o1
18262306a36Sopenharmony_ci	flush		%o1
18362306a36Sopenharmony_ci	retl
18462306a36Sopenharmony_ci	 wrpr		%g1, 0, %pstate
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci/*
18762306a36Sopenharmony_ci * The following code flushes one page_size worth.
18862306a36Sopenharmony_ci */
18962306a36Sopenharmony_ci	.section .kprobes.text, "ax"
19062306a36Sopenharmony_ci	.align		32
19162306a36Sopenharmony_ci	.globl		__flush_icache_page
19262306a36Sopenharmony_ci__flush_icache_page:	/* %o0 = phys_page */
19362306a36Sopenharmony_ci	srlx		%o0, PAGE_SHIFT, %o0
19462306a36Sopenharmony_ci	sethi		%hi(PAGE_OFFSET), %g1
19562306a36Sopenharmony_ci	sllx		%o0, PAGE_SHIFT, %o0
19662306a36Sopenharmony_ci	sethi		%hi(PAGE_SIZE), %g2
19762306a36Sopenharmony_ci	ldx		[%g1 + %lo(PAGE_OFFSET)], %g1
19862306a36Sopenharmony_ci	add		%o0, %g1, %o0
19962306a36Sopenharmony_ci1:	subcc		%g2, 32, %g2
20062306a36Sopenharmony_ci	bne,pt		%icc, 1b
20162306a36Sopenharmony_ci	 flush		%o0 + %g2
20262306a36Sopenharmony_ci	retl
20362306a36Sopenharmony_ci	 nop
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci#ifdef DCACHE_ALIASING_POSSIBLE
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci#if (PAGE_SHIFT != 13)
20862306a36Sopenharmony_ci#error only page shift of 13 is supported by dcache flush
20962306a36Sopenharmony_ci#endif
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ci#define DTAG_MASK 0x3
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci	/* This routine is Spitfire specific so the hardcoded
21462306a36Sopenharmony_ci	 * D-cache size and line-size are OK.
21562306a36Sopenharmony_ci	 */
21662306a36Sopenharmony_ci	.align		64
21762306a36Sopenharmony_ci	.globl		__flush_dcache_page
21862306a36Sopenharmony_ci__flush_dcache_page:	/* %o0=kaddr, %o1=flush_icache */
21962306a36Sopenharmony_ci	sethi		%hi(PAGE_OFFSET), %g1
22062306a36Sopenharmony_ci	ldx		[%g1 + %lo(PAGE_OFFSET)], %g1
22162306a36Sopenharmony_ci	sub		%o0, %g1, %o0			! physical address
22262306a36Sopenharmony_ci	srlx		%o0, 11, %o0			! make D-cache TAG
22362306a36Sopenharmony_ci	sethi		%hi(1 << 14), %o2		! D-cache size
22462306a36Sopenharmony_ci	sub		%o2, (1 << 5), %o2		! D-cache line size
22562306a36Sopenharmony_ci1:	ldxa		[%o2] ASI_DCACHE_TAG, %o3	! load D-cache TAG
22662306a36Sopenharmony_ci	andcc		%o3, DTAG_MASK, %g0		! Valid?
22762306a36Sopenharmony_ci	be,pn		%xcc, 2f			! Nope, branch
22862306a36Sopenharmony_ci	 andn		%o3, DTAG_MASK, %o3		! Clear valid bits
22962306a36Sopenharmony_ci	cmp		%o3, %o0			! TAG match?
23062306a36Sopenharmony_ci	bne,pt		%xcc, 2f			! Nope, branch
23162306a36Sopenharmony_ci	 nop
23262306a36Sopenharmony_ci	stxa		%g0, [%o2] ASI_DCACHE_TAG	! Invalidate TAG
23362306a36Sopenharmony_ci	membar		#Sync
23462306a36Sopenharmony_ci2:	brnz,pt		%o2, 1b
23562306a36Sopenharmony_ci	 sub		%o2, (1 << 5), %o2		! D-cache line size
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ci	/* The I-cache does not snoop local stores so we
23862306a36Sopenharmony_ci	 * better flush that too when necessary.
23962306a36Sopenharmony_ci	 */
24062306a36Sopenharmony_ci	brnz,pt		%o1, __flush_icache_page
24162306a36Sopenharmony_ci	 sllx		%o0, 11, %o0
24262306a36Sopenharmony_ci	retl
24362306a36Sopenharmony_ci	 nop
24462306a36Sopenharmony_ci
24562306a36Sopenharmony_ci#endif /* DCACHE_ALIASING_POSSIBLE */
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci	.previous
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ci	/* Cheetah specific versions, patched at boot time. */
25062306a36Sopenharmony_ci__cheetah_flush_tlb_mm: /* 19 insns */
25162306a36Sopenharmony_ci	rdpr		%pstate, %g7
25262306a36Sopenharmony_ci	andn		%g7, PSTATE_IE, %g2
25362306a36Sopenharmony_ci	wrpr		%g2, 0x0, %pstate
25462306a36Sopenharmony_ci	wrpr		%g0, 1, %tl
25562306a36Sopenharmony_ci	mov		PRIMARY_CONTEXT, %o2
25662306a36Sopenharmony_ci	mov		0x40, %g3
25762306a36Sopenharmony_ci	ldxa		[%o2] ASI_DMMU, %g2
25862306a36Sopenharmony_ci	srlx		%g2, CTX_PGSZ1_NUC_SHIFT, %o1
25962306a36Sopenharmony_ci	sllx		%o1, CTX_PGSZ1_NUC_SHIFT, %o1
26062306a36Sopenharmony_ci	or		%o0, %o1, %o0	/* Preserve nucleus page size fields */
26162306a36Sopenharmony_ci	stxa		%o0, [%o2] ASI_DMMU
26262306a36Sopenharmony_ci	stxa		%g0, [%g3] ASI_DMMU_DEMAP
26362306a36Sopenharmony_ci	stxa		%g0, [%g3] ASI_IMMU_DEMAP
26462306a36Sopenharmony_ci	stxa		%g2, [%o2] ASI_DMMU
26562306a36Sopenharmony_ci	sethi		%hi(KERNBASE), %o2
26662306a36Sopenharmony_ci	flush		%o2
26762306a36Sopenharmony_ci	wrpr		%g0, 0, %tl
26862306a36Sopenharmony_ci	retl
26962306a36Sopenharmony_ci	 wrpr		%g7, 0x0, %pstate
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci__cheetah_flush_tlb_page:	/* 22 insns */
27262306a36Sopenharmony_ci	/* %o0 = context, %o1 = vaddr */
27362306a36Sopenharmony_ci	rdpr		%pstate, %g7
27462306a36Sopenharmony_ci	andn		%g7, PSTATE_IE, %g2
27562306a36Sopenharmony_ci	wrpr		%g2, 0x0, %pstate
27662306a36Sopenharmony_ci	wrpr		%g0, 1, %tl
27762306a36Sopenharmony_ci	mov		PRIMARY_CONTEXT, %o4
27862306a36Sopenharmony_ci	ldxa		[%o4] ASI_DMMU, %g2
27962306a36Sopenharmony_ci	srlx		%g2, CTX_PGSZ1_NUC_SHIFT, %o3
28062306a36Sopenharmony_ci	sllx		%o3, CTX_PGSZ1_NUC_SHIFT, %o3
28162306a36Sopenharmony_ci	or		%o0, %o3, %o0	/* Preserve nucleus page size fields */
28262306a36Sopenharmony_ci	stxa		%o0, [%o4] ASI_DMMU
28362306a36Sopenharmony_ci	andcc		%o1, 1, %g0
28462306a36Sopenharmony_ci	be,pn		%icc, 1f
28562306a36Sopenharmony_ci	 andn		%o1, 1, %o3
28662306a36Sopenharmony_ci	stxa		%g0, [%o3] ASI_IMMU_DEMAP
28762306a36Sopenharmony_ci1:	stxa		%g0, [%o3] ASI_DMMU_DEMAP
28862306a36Sopenharmony_ci	membar		#Sync
28962306a36Sopenharmony_ci	stxa		%g2, [%o4] ASI_DMMU
29062306a36Sopenharmony_ci	sethi		%hi(KERNBASE), %o4
29162306a36Sopenharmony_ci	flush		%o4
29262306a36Sopenharmony_ci	wrpr		%g0, 0, %tl
29362306a36Sopenharmony_ci	retl
29462306a36Sopenharmony_ci	 wrpr		%g7, 0x0, %pstate
29562306a36Sopenharmony_ci
29662306a36Sopenharmony_ci__cheetah_flush_tlb_pending:	/* 27 insns */
29762306a36Sopenharmony_ci	/* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
29862306a36Sopenharmony_ci	rdpr		%pstate, %g7
29962306a36Sopenharmony_ci	sllx		%o1, 3, %o1
30062306a36Sopenharmony_ci	andn		%g7, PSTATE_IE, %g2
30162306a36Sopenharmony_ci	wrpr		%g2, 0x0, %pstate
30262306a36Sopenharmony_ci	wrpr		%g0, 1, %tl
30362306a36Sopenharmony_ci	mov		PRIMARY_CONTEXT, %o4
30462306a36Sopenharmony_ci	ldxa		[%o4] ASI_DMMU, %g2
30562306a36Sopenharmony_ci	srlx		%g2, CTX_PGSZ1_NUC_SHIFT, %o3
30662306a36Sopenharmony_ci	sllx		%o3, CTX_PGSZ1_NUC_SHIFT, %o3
30762306a36Sopenharmony_ci	or		%o0, %o3, %o0	/* Preserve nucleus page size fields */
30862306a36Sopenharmony_ci	stxa		%o0, [%o4] ASI_DMMU
30962306a36Sopenharmony_ci1:	sub		%o1, (1 << 3), %o1
31062306a36Sopenharmony_ci	ldx		[%o2 + %o1], %o3
31162306a36Sopenharmony_ci	andcc		%o3, 1, %g0
31262306a36Sopenharmony_ci	be,pn		%icc, 2f
31362306a36Sopenharmony_ci	 andn		%o3, 1, %o3
31462306a36Sopenharmony_ci	stxa		%g0, [%o3] ASI_IMMU_DEMAP
31562306a36Sopenharmony_ci2:	stxa		%g0, [%o3] ASI_DMMU_DEMAP
31662306a36Sopenharmony_ci	membar		#Sync
31762306a36Sopenharmony_ci	brnz,pt		%o1, 1b
31862306a36Sopenharmony_ci	 nop
31962306a36Sopenharmony_ci	stxa		%g2, [%o4] ASI_DMMU
32062306a36Sopenharmony_ci	sethi		%hi(KERNBASE), %o4
32162306a36Sopenharmony_ci	flush		%o4
32262306a36Sopenharmony_ci	wrpr		%g0, 0, %tl
32362306a36Sopenharmony_ci	retl
32462306a36Sopenharmony_ci	 wrpr		%g7, 0x0, %pstate
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci__cheetah_flush_tlb_kernel_range:	/* 31 insns */
32762306a36Sopenharmony_ci	/* %o0=start, %o1=end */
32862306a36Sopenharmony_ci	cmp		%o0, %o1
32962306a36Sopenharmony_ci	be,pn		%xcc, 2f
33062306a36Sopenharmony_ci	 sub		%o1, %o0, %o3
33162306a36Sopenharmony_ci	srlx		%o3, 18, %o4
33262306a36Sopenharmony_ci	brnz,pn		%o4, 3f
33362306a36Sopenharmony_ci	 sethi		%hi(PAGE_SIZE), %o4
33462306a36Sopenharmony_ci	sub		%o3, %o4, %o3
33562306a36Sopenharmony_ci	or		%o0, 0x20, %o0		! Nucleus
33662306a36Sopenharmony_ci1:	stxa		%g0, [%o0 + %o3] ASI_DMMU_DEMAP
33762306a36Sopenharmony_ci	stxa		%g0, [%o0 + %o3] ASI_IMMU_DEMAP
33862306a36Sopenharmony_ci	membar		#Sync
33962306a36Sopenharmony_ci	brnz,pt		%o3, 1b
34062306a36Sopenharmony_ci	 sub		%o3, %o4, %o3
34162306a36Sopenharmony_ci2:	sethi		%hi(KERNBASE), %o3
34262306a36Sopenharmony_ci	flush		%o3
34362306a36Sopenharmony_ci	retl
34462306a36Sopenharmony_ci	 nop
34562306a36Sopenharmony_ci3:	mov		0x80, %o4
34662306a36Sopenharmony_ci	stxa		%g0, [%o4] ASI_DMMU_DEMAP
34762306a36Sopenharmony_ci	membar		#Sync
34862306a36Sopenharmony_ci	stxa		%g0, [%o4] ASI_IMMU_DEMAP
34962306a36Sopenharmony_ci	membar		#Sync
35062306a36Sopenharmony_ci	retl
35162306a36Sopenharmony_ci	 nop
35262306a36Sopenharmony_ci	nop
35362306a36Sopenharmony_ci	nop
35462306a36Sopenharmony_ci	nop
35562306a36Sopenharmony_ci	nop
35662306a36Sopenharmony_ci	nop
35762306a36Sopenharmony_ci	nop
35862306a36Sopenharmony_ci	nop
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ci#ifdef DCACHE_ALIASING_POSSIBLE
36162306a36Sopenharmony_ci__cheetah_flush_dcache_page: /* 11 insns */
36262306a36Sopenharmony_ci	sethi		%hi(PAGE_OFFSET), %g1
36362306a36Sopenharmony_ci	ldx		[%g1 + %lo(PAGE_OFFSET)], %g1
36462306a36Sopenharmony_ci	sub		%o0, %g1, %o0
36562306a36Sopenharmony_ci	sethi		%hi(PAGE_SIZE), %o4
36662306a36Sopenharmony_ci1:	subcc		%o4, (1 << 5), %o4
36762306a36Sopenharmony_ci	stxa		%g0, [%o0 + %o4] ASI_DCACHE_INVALIDATE
36862306a36Sopenharmony_ci	membar		#Sync
36962306a36Sopenharmony_ci	bne,pt		%icc, 1b
37062306a36Sopenharmony_ci	 nop
37162306a36Sopenharmony_ci	retl		/* I-cache flush never needed on Cheetah, see callers. */
37262306a36Sopenharmony_ci	 nop
37362306a36Sopenharmony_ci#endif /* DCACHE_ALIASING_POSSIBLE */
37462306a36Sopenharmony_ci
37562306a36Sopenharmony_ci	/* Hypervisor specific versions, patched at boot time.  */
37662306a36Sopenharmony_ci__hypervisor_tlb_tl0_error:
37762306a36Sopenharmony_ci	save		%sp, -192, %sp
37862306a36Sopenharmony_ci	mov		%i0, %o0
37962306a36Sopenharmony_ci	call		hypervisor_tlbop_error
38062306a36Sopenharmony_ci	 mov		%i1, %o1
38162306a36Sopenharmony_ci	ret
38262306a36Sopenharmony_ci	 restore
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_ci__hypervisor_flush_tlb_mm: /* 19 insns */
38562306a36Sopenharmony_ci	mov		%o0, %o2	/* ARG2: mmu context */
38662306a36Sopenharmony_ci	mov		0, %o0		/* ARG0: CPU lists unimplemented */
38762306a36Sopenharmony_ci	mov		0, %o1		/* ARG1: CPU lists unimplemented */
38862306a36Sopenharmony_ci	mov		HV_MMU_ALL, %o3	/* ARG3: flags */
38962306a36Sopenharmony_ci	mov		HV_FAST_MMU_DEMAP_CTX, %o5
39062306a36Sopenharmony_ci	ta		HV_FAST_TRAP
39162306a36Sopenharmony_ci	brnz,pn		%o0, 1f
39262306a36Sopenharmony_ci	 mov		HV_FAST_MMU_DEMAP_CTX, %o1
39362306a36Sopenharmony_ci	retl
39462306a36Sopenharmony_ci	 nop
39562306a36Sopenharmony_ci1:	sethi		%hi(__hypervisor_tlb_tl0_error), %o5
39662306a36Sopenharmony_ci	jmpl		%o5 + %lo(__hypervisor_tlb_tl0_error), %g0
39762306a36Sopenharmony_ci	 nop
39862306a36Sopenharmony_ci	nop
39962306a36Sopenharmony_ci	nop
40062306a36Sopenharmony_ci	nop
40162306a36Sopenharmony_ci	nop
40262306a36Sopenharmony_ci	nop
40362306a36Sopenharmony_ci	nop
40462306a36Sopenharmony_ci
40562306a36Sopenharmony_ci__hypervisor_flush_tlb_page: /* 22 insns */
40662306a36Sopenharmony_ci	/* %o0 = context, %o1 = vaddr */
40762306a36Sopenharmony_ci	mov		%o0, %g2
40862306a36Sopenharmony_ci	mov		%o1, %o0              /* ARG0: vaddr + IMMU-bit */
40962306a36Sopenharmony_ci	mov		%g2, %o1	      /* ARG1: mmu context */
41062306a36Sopenharmony_ci	mov		HV_MMU_ALL, %o2	      /* ARG2: flags */
41162306a36Sopenharmony_ci	srlx		%o0, PAGE_SHIFT, %o0
41262306a36Sopenharmony_ci	sllx		%o0, PAGE_SHIFT, %o0
41362306a36Sopenharmony_ci	ta		HV_MMU_UNMAP_ADDR_TRAP
41462306a36Sopenharmony_ci	brnz,pn		%o0, 1f
41562306a36Sopenharmony_ci	 mov		HV_MMU_UNMAP_ADDR_TRAP, %o1
41662306a36Sopenharmony_ci	retl
41762306a36Sopenharmony_ci	 nop
41862306a36Sopenharmony_ci1:	sethi		%hi(__hypervisor_tlb_tl0_error), %o2
41962306a36Sopenharmony_ci	jmpl		%o2 + %lo(__hypervisor_tlb_tl0_error), %g0
42062306a36Sopenharmony_ci	 nop
42162306a36Sopenharmony_ci	nop
42262306a36Sopenharmony_ci	nop
42362306a36Sopenharmony_ci	nop
42462306a36Sopenharmony_ci	nop
42562306a36Sopenharmony_ci	nop
42662306a36Sopenharmony_ci	nop
42762306a36Sopenharmony_ci	nop
42862306a36Sopenharmony_ci	nop
42962306a36Sopenharmony_ci
43062306a36Sopenharmony_ci__hypervisor_flush_tlb_pending: /* 27 insns */
43162306a36Sopenharmony_ci	/* %o0 = context, %o1 = nr, %o2 = vaddrs[] */
43262306a36Sopenharmony_ci	sllx		%o1, 3, %g1
43362306a36Sopenharmony_ci	mov		%o2, %g2
43462306a36Sopenharmony_ci	mov		%o0, %g3
43562306a36Sopenharmony_ci1:	sub		%g1, (1 << 3), %g1
43662306a36Sopenharmony_ci	ldx		[%g2 + %g1], %o0      /* ARG0: vaddr + IMMU-bit */
43762306a36Sopenharmony_ci	mov		%g3, %o1	      /* ARG1: mmu context */
43862306a36Sopenharmony_ci	mov		HV_MMU_ALL, %o2	      /* ARG2: flags */
43962306a36Sopenharmony_ci	srlx		%o0, PAGE_SHIFT, %o0
44062306a36Sopenharmony_ci	sllx		%o0, PAGE_SHIFT, %o0
44162306a36Sopenharmony_ci	ta		HV_MMU_UNMAP_ADDR_TRAP
44262306a36Sopenharmony_ci	brnz,pn		%o0, 1f
44362306a36Sopenharmony_ci	 mov		HV_MMU_UNMAP_ADDR_TRAP, %o1
44462306a36Sopenharmony_ci	brnz,pt		%g1, 1b
44562306a36Sopenharmony_ci	 nop
44662306a36Sopenharmony_ci	retl
44762306a36Sopenharmony_ci	 nop
44862306a36Sopenharmony_ci1:	sethi		%hi(__hypervisor_tlb_tl0_error), %o2
44962306a36Sopenharmony_ci	jmpl		%o2 + %lo(__hypervisor_tlb_tl0_error), %g0
45062306a36Sopenharmony_ci	 nop
45162306a36Sopenharmony_ci	nop
45262306a36Sopenharmony_ci	nop
45362306a36Sopenharmony_ci	nop
45462306a36Sopenharmony_ci	nop
45562306a36Sopenharmony_ci	nop
45662306a36Sopenharmony_ci	nop
45762306a36Sopenharmony_ci	nop
45862306a36Sopenharmony_ci	nop
45962306a36Sopenharmony_ci
46062306a36Sopenharmony_ci__hypervisor_flush_tlb_kernel_range: /* 31 insns */
46162306a36Sopenharmony_ci	/* %o0=start, %o1=end */
46262306a36Sopenharmony_ci	cmp		%o0, %o1
46362306a36Sopenharmony_ci	be,pn		%xcc, 2f
46462306a36Sopenharmony_ci	 sub		%o1, %o0, %g2
46562306a36Sopenharmony_ci	srlx		%g2, 18, %g3
46662306a36Sopenharmony_ci	brnz,pn		%g3, 4f
46762306a36Sopenharmony_ci	 mov		%o0, %g1
46862306a36Sopenharmony_ci	sethi		%hi(PAGE_SIZE), %g3
46962306a36Sopenharmony_ci	sub		%g2, %g3, %g2
47062306a36Sopenharmony_ci1:	add		%g1, %g2, %o0	/* ARG0: virtual address */
47162306a36Sopenharmony_ci	mov		0, %o1		/* ARG1: mmu context */
47262306a36Sopenharmony_ci	mov		HV_MMU_ALL, %o2	/* ARG2: flags */
47362306a36Sopenharmony_ci	ta		HV_MMU_UNMAP_ADDR_TRAP
47462306a36Sopenharmony_ci	brnz,pn		%o0, 3f
47562306a36Sopenharmony_ci	 mov		HV_MMU_UNMAP_ADDR_TRAP, %o1
47662306a36Sopenharmony_ci	brnz,pt		%g2, 1b
47762306a36Sopenharmony_ci	 sub		%g2, %g3, %g2
47862306a36Sopenharmony_ci2:	retl
47962306a36Sopenharmony_ci	 nop
48062306a36Sopenharmony_ci3:	sethi		%hi(__hypervisor_tlb_tl0_error), %o2
48162306a36Sopenharmony_ci	jmpl		%o2 + %lo(__hypervisor_tlb_tl0_error), %g0
48262306a36Sopenharmony_ci	 nop
48362306a36Sopenharmony_ci4:	mov		0, %o0		/* ARG0: CPU lists unimplemented */
48462306a36Sopenharmony_ci	mov		0, %o1		/* ARG1: CPU lists unimplemented */
48562306a36Sopenharmony_ci	mov		0, %o2		/* ARG2: mmu context == nucleus */
48662306a36Sopenharmony_ci	mov		HV_MMU_ALL, %o3	/* ARG3: flags */
48762306a36Sopenharmony_ci	mov		HV_FAST_MMU_DEMAP_CTX, %o5
48862306a36Sopenharmony_ci	ta		HV_FAST_TRAP
48962306a36Sopenharmony_ci	brnz,pn		%o0, 3b
49062306a36Sopenharmony_ci	 mov		HV_FAST_MMU_DEMAP_CTX, %o1
49162306a36Sopenharmony_ci	retl
49262306a36Sopenharmony_ci	 nop
49362306a36Sopenharmony_ci
49462306a36Sopenharmony_ci#ifdef DCACHE_ALIASING_POSSIBLE
49562306a36Sopenharmony_ci	/* XXX Niagara and friends have an 8K cache, so no aliasing is
49662306a36Sopenharmony_ci	 * XXX possible, but nothing explicit in the Hypervisor API
49762306a36Sopenharmony_ci	 * XXX guarantees this.
49862306a36Sopenharmony_ci	 */
49962306a36Sopenharmony_ci__hypervisor_flush_dcache_page:	/* 2 insns */
50062306a36Sopenharmony_ci	retl
50162306a36Sopenharmony_ci	 nop
50262306a36Sopenharmony_ci#endif
50362306a36Sopenharmony_ci
50462306a36Sopenharmony_citlb_patch_one:
50562306a36Sopenharmony_ci1:	lduw		[%o1], %g1
50662306a36Sopenharmony_ci	stw		%g1, [%o0]
50762306a36Sopenharmony_ci	flush		%o0
50862306a36Sopenharmony_ci	subcc		%o2, 1, %o2
50962306a36Sopenharmony_ci	add		%o1, 4, %o1
51062306a36Sopenharmony_ci	bne,pt		%icc, 1b
51162306a36Sopenharmony_ci	 add		%o0, 4, %o0
51262306a36Sopenharmony_ci	retl
51362306a36Sopenharmony_ci	 nop
51462306a36Sopenharmony_ci
51562306a36Sopenharmony_ci#ifdef CONFIG_SMP
51662306a36Sopenharmony_ci	/* These are all called by the slaves of a cross call, at
51762306a36Sopenharmony_ci	 * trap level 1, with interrupts fully disabled.
51862306a36Sopenharmony_ci	 *
51962306a36Sopenharmony_ci	 * Register usage:
52062306a36Sopenharmony_ci	 *   %g5	mm->context	(all tlb flushes)
52162306a36Sopenharmony_ci	 *   %g1	address arg 1	(tlb page and range flushes)
52262306a36Sopenharmony_ci	 *   %g7	address arg 2	(tlb range flush only)
52362306a36Sopenharmony_ci	 *
52462306a36Sopenharmony_ci	 *   %g6	scratch 1
52562306a36Sopenharmony_ci	 *   %g2	scratch 2
52662306a36Sopenharmony_ci	 *   %g3	scratch 3
52762306a36Sopenharmony_ci	 *   %g4	scratch 4
52862306a36Sopenharmony_ci	 */
52962306a36Sopenharmony_ci	.align		32
53062306a36Sopenharmony_ci	.globl		xcall_flush_tlb_mm
53162306a36Sopenharmony_cixcall_flush_tlb_mm:	/* 24 insns */
53262306a36Sopenharmony_ci	mov		PRIMARY_CONTEXT, %g2
53362306a36Sopenharmony_ci	ldxa		[%g2] ASI_DMMU, %g3
53462306a36Sopenharmony_ci	srlx		%g3, CTX_PGSZ1_NUC_SHIFT, %g4
53562306a36Sopenharmony_ci	sllx		%g4, CTX_PGSZ1_NUC_SHIFT, %g4
53662306a36Sopenharmony_ci	or		%g5, %g4, %g5	/* Preserve nucleus page size fields */
53762306a36Sopenharmony_ci	stxa		%g5, [%g2] ASI_DMMU
53862306a36Sopenharmony_ci	mov		0x40, %g4
53962306a36Sopenharmony_ci	stxa		%g0, [%g4] ASI_DMMU_DEMAP
54062306a36Sopenharmony_ci	stxa		%g0, [%g4] ASI_IMMU_DEMAP
54162306a36Sopenharmony_ci	stxa		%g3, [%g2] ASI_DMMU
54262306a36Sopenharmony_ci	retry
54362306a36Sopenharmony_ci	nop
54462306a36Sopenharmony_ci	nop
54562306a36Sopenharmony_ci	nop
54662306a36Sopenharmony_ci	nop
54762306a36Sopenharmony_ci	nop
54862306a36Sopenharmony_ci	nop
54962306a36Sopenharmony_ci	nop
55062306a36Sopenharmony_ci	nop
55162306a36Sopenharmony_ci	nop
55262306a36Sopenharmony_ci	nop
55362306a36Sopenharmony_ci	nop
55462306a36Sopenharmony_ci	nop
55562306a36Sopenharmony_ci	nop
55662306a36Sopenharmony_ci
55762306a36Sopenharmony_ci	.globl		xcall_flush_tlb_page
55862306a36Sopenharmony_cixcall_flush_tlb_page:	/* 20 insns */
55962306a36Sopenharmony_ci	/* %g5=context, %g1=vaddr */
56062306a36Sopenharmony_ci	mov		PRIMARY_CONTEXT, %g4
56162306a36Sopenharmony_ci	ldxa		[%g4] ASI_DMMU, %g2
56262306a36Sopenharmony_ci	srlx		%g2, CTX_PGSZ1_NUC_SHIFT, %g4
56362306a36Sopenharmony_ci	sllx		%g4, CTX_PGSZ1_NUC_SHIFT, %g4
56462306a36Sopenharmony_ci	or		%g5, %g4, %g5
56562306a36Sopenharmony_ci	mov		PRIMARY_CONTEXT, %g4
56662306a36Sopenharmony_ci	stxa		%g5, [%g4] ASI_DMMU
56762306a36Sopenharmony_ci	andcc		%g1, 0x1, %g0
56862306a36Sopenharmony_ci	be,pn		%icc, 2f
56962306a36Sopenharmony_ci	 andn		%g1, 0x1, %g5
57062306a36Sopenharmony_ci	stxa		%g0, [%g5] ASI_IMMU_DEMAP
57162306a36Sopenharmony_ci2:	stxa		%g0, [%g5] ASI_DMMU_DEMAP
57262306a36Sopenharmony_ci	membar		#Sync
57362306a36Sopenharmony_ci	stxa		%g2, [%g4] ASI_DMMU
57462306a36Sopenharmony_ci	retry
57562306a36Sopenharmony_ci	nop
57662306a36Sopenharmony_ci	nop
57762306a36Sopenharmony_ci	nop
57862306a36Sopenharmony_ci	nop
57962306a36Sopenharmony_ci	nop
58062306a36Sopenharmony_ci
58162306a36Sopenharmony_ci	.globl		xcall_flush_tlb_kernel_range
58262306a36Sopenharmony_cixcall_flush_tlb_kernel_range:	/* 44 insns */
58362306a36Sopenharmony_ci	sethi		%hi(PAGE_SIZE - 1), %g2
58462306a36Sopenharmony_ci	or		%g2, %lo(PAGE_SIZE - 1), %g2
58562306a36Sopenharmony_ci	andn		%g1, %g2, %g1
58662306a36Sopenharmony_ci	andn		%g7, %g2, %g7
58762306a36Sopenharmony_ci	sub		%g7, %g1, %g3
58862306a36Sopenharmony_ci	srlx		%g3, 18, %g2
58962306a36Sopenharmony_ci	brnz,pn		%g2, 2f
59062306a36Sopenharmony_ci	 sethi		%hi(PAGE_SIZE), %g2
59162306a36Sopenharmony_ci	sub		%g3, %g2, %g3
59262306a36Sopenharmony_ci	or		%g1, 0x20, %g1		! Nucleus
59362306a36Sopenharmony_ci1:	stxa		%g0, [%g1 + %g3] ASI_DMMU_DEMAP
59462306a36Sopenharmony_ci	stxa		%g0, [%g1 + %g3] ASI_IMMU_DEMAP
59562306a36Sopenharmony_ci	membar		#Sync
59662306a36Sopenharmony_ci	brnz,pt		%g3, 1b
59762306a36Sopenharmony_ci	 sub		%g3, %g2, %g3
59862306a36Sopenharmony_ci	retry
59962306a36Sopenharmony_ci2:	mov		63 * 8, %g1
60062306a36Sopenharmony_ci1:	ldxa		[%g1] ASI_ITLB_DATA_ACCESS, %g2
60162306a36Sopenharmony_ci	andcc		%g2, 0x40, %g0			/* _PAGE_L_4U */
60262306a36Sopenharmony_ci	bne,pn		%xcc, 2f
60362306a36Sopenharmony_ci	 mov		TLB_TAG_ACCESS, %g2
60462306a36Sopenharmony_ci	stxa		%g0, [%g2] ASI_IMMU
60562306a36Sopenharmony_ci	stxa		%g0, [%g1] ASI_ITLB_DATA_ACCESS
60662306a36Sopenharmony_ci	membar		#Sync
60762306a36Sopenharmony_ci2:	ldxa		[%g1] ASI_DTLB_DATA_ACCESS, %g2
60862306a36Sopenharmony_ci	andcc		%g2, 0x40, %g0
60962306a36Sopenharmony_ci	bne,pn		%xcc, 2f
61062306a36Sopenharmony_ci	 mov		TLB_TAG_ACCESS, %g2
61162306a36Sopenharmony_ci	stxa		%g0, [%g2] ASI_DMMU
61262306a36Sopenharmony_ci	stxa		%g0, [%g1] ASI_DTLB_DATA_ACCESS
61362306a36Sopenharmony_ci	membar		#Sync
61462306a36Sopenharmony_ci2:	sub		%g1, 8, %g1
61562306a36Sopenharmony_ci	brgez,pt	%g1, 1b
61662306a36Sopenharmony_ci	 nop
61762306a36Sopenharmony_ci	retry
61862306a36Sopenharmony_ci	nop
61962306a36Sopenharmony_ci	nop
62062306a36Sopenharmony_ci	nop
62162306a36Sopenharmony_ci	nop
62262306a36Sopenharmony_ci	nop
62362306a36Sopenharmony_ci	nop
62462306a36Sopenharmony_ci	nop
62562306a36Sopenharmony_ci	nop
62662306a36Sopenharmony_ci	nop
62762306a36Sopenharmony_ci
62862306a36Sopenharmony_ci	/* This runs in a very controlled environment, so we do
62962306a36Sopenharmony_ci	 * not need to worry about BH races etc.
63062306a36Sopenharmony_ci	 */
63162306a36Sopenharmony_ci	.globl		xcall_sync_tick
63262306a36Sopenharmony_cixcall_sync_tick:
63362306a36Sopenharmony_ci
63462306a36Sopenharmony_ci661:	rdpr		%pstate, %g2
63562306a36Sopenharmony_ci	wrpr		%g2, PSTATE_IG | PSTATE_AG, %pstate
63662306a36Sopenharmony_ci	.section	.sun4v_2insn_patch, "ax"
63762306a36Sopenharmony_ci	.word		661b
63862306a36Sopenharmony_ci	nop
63962306a36Sopenharmony_ci	nop
64062306a36Sopenharmony_ci	.previous
64162306a36Sopenharmony_ci
64262306a36Sopenharmony_ci	rdpr		%pil, %g2
64362306a36Sopenharmony_ci	wrpr		%g0, PIL_NORMAL_MAX, %pil
64462306a36Sopenharmony_ci	sethi		%hi(109f), %g7
64562306a36Sopenharmony_ci	b,pt		%xcc, etrap_irq
64662306a36Sopenharmony_ci109:	 or		%g7, %lo(109b), %g7
64762306a36Sopenharmony_ci#ifdef CONFIG_TRACE_IRQFLAGS
64862306a36Sopenharmony_ci	call		trace_hardirqs_off
64962306a36Sopenharmony_ci	 nop
65062306a36Sopenharmony_ci#endif
65162306a36Sopenharmony_ci	call		smp_synchronize_tick_client
65262306a36Sopenharmony_ci	 nop
65362306a36Sopenharmony_ci	b		rtrap_xcall
65462306a36Sopenharmony_ci	 ldx		[%sp + PTREGS_OFF + PT_V9_TSTATE], %l1
65562306a36Sopenharmony_ci
65662306a36Sopenharmony_ci	.globl		xcall_fetch_glob_regs
65762306a36Sopenharmony_cixcall_fetch_glob_regs:
65862306a36Sopenharmony_ci	sethi		%hi(global_cpu_snapshot), %g1
65962306a36Sopenharmony_ci	or		%g1, %lo(global_cpu_snapshot), %g1
66062306a36Sopenharmony_ci	__GET_CPUID(%g2)
66162306a36Sopenharmony_ci	sllx		%g2, 6, %g3
66262306a36Sopenharmony_ci	add		%g1, %g3, %g1
66362306a36Sopenharmony_ci	rdpr		%tstate, %g7
66462306a36Sopenharmony_ci	stx		%g7, [%g1 + GR_SNAP_TSTATE]
66562306a36Sopenharmony_ci	rdpr		%tpc, %g7
66662306a36Sopenharmony_ci	stx		%g7, [%g1 + GR_SNAP_TPC]
66762306a36Sopenharmony_ci	rdpr		%tnpc, %g7
66862306a36Sopenharmony_ci	stx		%g7, [%g1 + GR_SNAP_TNPC]
66962306a36Sopenharmony_ci	stx		%o7, [%g1 + GR_SNAP_O7]
67062306a36Sopenharmony_ci	stx		%i7, [%g1 + GR_SNAP_I7]
67162306a36Sopenharmony_ci	/* Don't try this at home kids... */
67262306a36Sopenharmony_ci	rdpr		%cwp, %g3
67362306a36Sopenharmony_ci	sub		%g3, 1, %g7
67462306a36Sopenharmony_ci	wrpr		%g7, %cwp
67562306a36Sopenharmony_ci	mov		%i7, %g7
67662306a36Sopenharmony_ci	wrpr		%g3, %cwp
67762306a36Sopenharmony_ci	stx		%g7, [%g1 + GR_SNAP_RPC]
67862306a36Sopenharmony_ci	sethi		%hi(trap_block), %g7
67962306a36Sopenharmony_ci	or		%g7, %lo(trap_block), %g7
68062306a36Sopenharmony_ci	sllx		%g2, TRAP_BLOCK_SZ_SHIFT, %g2
68162306a36Sopenharmony_ci	add		%g7, %g2, %g7
68262306a36Sopenharmony_ci	ldx		[%g7 + TRAP_PER_CPU_THREAD], %g3
68362306a36Sopenharmony_ci	stx		%g3, [%g1 + GR_SNAP_THREAD]
68462306a36Sopenharmony_ci	retry
68562306a36Sopenharmony_ci
68662306a36Sopenharmony_ci	.globl		xcall_fetch_glob_pmu
68762306a36Sopenharmony_cixcall_fetch_glob_pmu:
68862306a36Sopenharmony_ci	sethi		%hi(global_cpu_snapshot), %g1
68962306a36Sopenharmony_ci	or		%g1, %lo(global_cpu_snapshot), %g1
69062306a36Sopenharmony_ci	__GET_CPUID(%g2)
69162306a36Sopenharmony_ci	sllx		%g2, 6, %g3
69262306a36Sopenharmony_ci	add		%g1, %g3, %g1
69362306a36Sopenharmony_ci	rd		%pic, %g7
69462306a36Sopenharmony_ci	stx		%g7, [%g1 + (4 * 8)]
69562306a36Sopenharmony_ci	rd		%pcr, %g7
69662306a36Sopenharmony_ci	stx		%g7, [%g1 + (0 * 8)]
69762306a36Sopenharmony_ci	retry
69862306a36Sopenharmony_ci
69962306a36Sopenharmony_ci	.globl		xcall_fetch_glob_pmu_n4
70062306a36Sopenharmony_cixcall_fetch_glob_pmu_n4:
70162306a36Sopenharmony_ci	sethi		%hi(global_cpu_snapshot), %g1
70262306a36Sopenharmony_ci	or		%g1, %lo(global_cpu_snapshot), %g1
70362306a36Sopenharmony_ci	__GET_CPUID(%g2)
70462306a36Sopenharmony_ci	sllx		%g2, 6, %g3
70562306a36Sopenharmony_ci	add		%g1, %g3, %g1
70662306a36Sopenharmony_ci
70762306a36Sopenharmony_ci	ldxa		[%g0] ASI_PIC, %g7
70862306a36Sopenharmony_ci	stx		%g7, [%g1 + (4 * 8)]
70962306a36Sopenharmony_ci	mov		0x08, %g3
71062306a36Sopenharmony_ci	ldxa		[%g3] ASI_PIC, %g7
71162306a36Sopenharmony_ci	stx		%g7, [%g1 + (5 * 8)]
71262306a36Sopenharmony_ci	mov		0x10, %g3
71362306a36Sopenharmony_ci	ldxa		[%g3] ASI_PIC, %g7
71462306a36Sopenharmony_ci	stx		%g7, [%g1 + (6 * 8)]
71562306a36Sopenharmony_ci	mov		0x18, %g3
71662306a36Sopenharmony_ci	ldxa		[%g3] ASI_PIC, %g7
71762306a36Sopenharmony_ci	stx		%g7, [%g1 + (7 * 8)]
71862306a36Sopenharmony_ci
71962306a36Sopenharmony_ci	mov		%o0, %g2
72062306a36Sopenharmony_ci	mov		%o1, %g3
72162306a36Sopenharmony_ci	mov		%o5, %g7
72262306a36Sopenharmony_ci
72362306a36Sopenharmony_ci	mov		HV_FAST_VT_GET_PERFREG, %o5
72462306a36Sopenharmony_ci	mov		3, %o0
72562306a36Sopenharmony_ci	ta		HV_FAST_TRAP
72662306a36Sopenharmony_ci	stx		%o1, [%g1 + (3 * 8)]
72762306a36Sopenharmony_ci	mov		HV_FAST_VT_GET_PERFREG, %o5
72862306a36Sopenharmony_ci	mov		2, %o0
72962306a36Sopenharmony_ci	ta		HV_FAST_TRAP
73062306a36Sopenharmony_ci	stx		%o1, [%g1 + (2 * 8)]
73162306a36Sopenharmony_ci	mov		HV_FAST_VT_GET_PERFREG, %o5
73262306a36Sopenharmony_ci	mov		1, %o0
73362306a36Sopenharmony_ci	ta		HV_FAST_TRAP
73462306a36Sopenharmony_ci	stx		%o1, [%g1 + (1 * 8)]
73562306a36Sopenharmony_ci	mov		HV_FAST_VT_GET_PERFREG, %o5
73662306a36Sopenharmony_ci	mov		0, %o0
73762306a36Sopenharmony_ci	ta		HV_FAST_TRAP
73862306a36Sopenharmony_ci	stx		%o1, [%g1 + (0 * 8)]
73962306a36Sopenharmony_ci
74062306a36Sopenharmony_ci	mov		%g2, %o0
74162306a36Sopenharmony_ci	mov		%g3, %o1
74262306a36Sopenharmony_ci	mov		%g7, %o5
74362306a36Sopenharmony_ci
74462306a36Sopenharmony_ci	retry
74562306a36Sopenharmony_ci
74662306a36Sopenharmony_ci__cheetah_xcall_flush_tlb_kernel_range:	/* 44 insns */
74762306a36Sopenharmony_ci	sethi		%hi(PAGE_SIZE - 1), %g2
74862306a36Sopenharmony_ci	or		%g2, %lo(PAGE_SIZE - 1), %g2
74962306a36Sopenharmony_ci	andn		%g1, %g2, %g1
75062306a36Sopenharmony_ci	andn		%g7, %g2, %g7
75162306a36Sopenharmony_ci	sub		%g7, %g1, %g3
75262306a36Sopenharmony_ci	srlx		%g3, 18, %g2
75362306a36Sopenharmony_ci	brnz,pn		%g2, 2f
75462306a36Sopenharmony_ci	 sethi		%hi(PAGE_SIZE), %g2
75562306a36Sopenharmony_ci	sub		%g3, %g2, %g3
75662306a36Sopenharmony_ci	or		%g1, 0x20, %g1		! Nucleus
75762306a36Sopenharmony_ci1:	stxa		%g0, [%g1 + %g3] ASI_DMMU_DEMAP
75862306a36Sopenharmony_ci	stxa		%g0, [%g1 + %g3] ASI_IMMU_DEMAP
75962306a36Sopenharmony_ci	membar		#Sync
76062306a36Sopenharmony_ci	brnz,pt		%g3, 1b
76162306a36Sopenharmony_ci	 sub		%g3, %g2, %g3
76262306a36Sopenharmony_ci	retry
76362306a36Sopenharmony_ci2:	mov		0x80, %g2
76462306a36Sopenharmony_ci	stxa		%g0, [%g2] ASI_DMMU_DEMAP
76562306a36Sopenharmony_ci	membar		#Sync
76662306a36Sopenharmony_ci	stxa		%g0, [%g2] ASI_IMMU_DEMAP
76762306a36Sopenharmony_ci	membar		#Sync
76862306a36Sopenharmony_ci	retry
76962306a36Sopenharmony_ci	nop
77062306a36Sopenharmony_ci	nop
77162306a36Sopenharmony_ci	nop
77262306a36Sopenharmony_ci	nop
77362306a36Sopenharmony_ci	nop
77462306a36Sopenharmony_ci	nop
77562306a36Sopenharmony_ci	nop
77662306a36Sopenharmony_ci	nop
77762306a36Sopenharmony_ci	nop
77862306a36Sopenharmony_ci	nop
77962306a36Sopenharmony_ci	nop
78062306a36Sopenharmony_ci	nop
78162306a36Sopenharmony_ci	nop
78262306a36Sopenharmony_ci	nop
78362306a36Sopenharmony_ci	nop
78462306a36Sopenharmony_ci	nop
78562306a36Sopenharmony_ci	nop
78662306a36Sopenharmony_ci	nop
78762306a36Sopenharmony_ci	nop
78862306a36Sopenharmony_ci	nop
78962306a36Sopenharmony_ci	nop
79062306a36Sopenharmony_ci	nop
79162306a36Sopenharmony_ci
79262306a36Sopenharmony_ci#ifdef DCACHE_ALIASING_POSSIBLE
79362306a36Sopenharmony_ci	.align		32
79462306a36Sopenharmony_ci	.globl		xcall_flush_dcache_page_cheetah
79562306a36Sopenharmony_cixcall_flush_dcache_page_cheetah: /* %g1 == physical page address */
79662306a36Sopenharmony_ci	sethi		%hi(PAGE_SIZE), %g3
79762306a36Sopenharmony_ci1:	subcc		%g3, (1 << 5), %g3
79862306a36Sopenharmony_ci	stxa		%g0, [%g1 + %g3] ASI_DCACHE_INVALIDATE
79962306a36Sopenharmony_ci	membar		#Sync
80062306a36Sopenharmony_ci	bne,pt		%icc, 1b
80162306a36Sopenharmony_ci	 nop
80262306a36Sopenharmony_ci	retry
80362306a36Sopenharmony_ci	nop
80462306a36Sopenharmony_ci#endif /* DCACHE_ALIASING_POSSIBLE */
80562306a36Sopenharmony_ci
80662306a36Sopenharmony_ci	.globl		xcall_flush_dcache_page_spitfire
80762306a36Sopenharmony_cixcall_flush_dcache_page_spitfire: /* %g1 == physical page address
80862306a36Sopenharmony_ci				     %g7 == kernel page virtual address
80962306a36Sopenharmony_ci				     %g5 == (page->mapping != NULL)  */
81062306a36Sopenharmony_ci#ifdef DCACHE_ALIASING_POSSIBLE
81162306a36Sopenharmony_ci	srlx		%g1, (13 - 2), %g1	! Form tag comparitor
81262306a36Sopenharmony_ci	sethi		%hi(L1DCACHE_SIZE), %g3	! D$ size == 16K
81362306a36Sopenharmony_ci	sub		%g3, (1 << 5), %g3	! D$ linesize == 32
81462306a36Sopenharmony_ci1:	ldxa		[%g3] ASI_DCACHE_TAG, %g2
81562306a36Sopenharmony_ci	andcc		%g2, 0x3, %g0
81662306a36Sopenharmony_ci	be,pn		%xcc, 2f
81762306a36Sopenharmony_ci	 andn		%g2, 0x3, %g2
81862306a36Sopenharmony_ci	cmp		%g2, %g1
81962306a36Sopenharmony_ci
82062306a36Sopenharmony_ci	bne,pt		%xcc, 2f
82162306a36Sopenharmony_ci	 nop
82262306a36Sopenharmony_ci	stxa		%g0, [%g3] ASI_DCACHE_TAG
82362306a36Sopenharmony_ci	membar		#Sync
82462306a36Sopenharmony_ci2:	cmp		%g3, 0
82562306a36Sopenharmony_ci	bne,pt		%xcc, 1b
82662306a36Sopenharmony_ci	 sub		%g3, (1 << 5), %g3
82762306a36Sopenharmony_ci
82862306a36Sopenharmony_ci	brz,pn		%g5, 2f
82962306a36Sopenharmony_ci#endif /* DCACHE_ALIASING_POSSIBLE */
83062306a36Sopenharmony_ci	 sethi		%hi(PAGE_SIZE), %g3
83162306a36Sopenharmony_ci
83262306a36Sopenharmony_ci1:	flush		%g7
83362306a36Sopenharmony_ci	subcc		%g3, (1 << 5), %g3
83462306a36Sopenharmony_ci	bne,pt		%icc, 1b
83562306a36Sopenharmony_ci	 add		%g7, (1 << 5), %g7
83662306a36Sopenharmony_ci
83762306a36Sopenharmony_ci2:	retry
83862306a36Sopenharmony_ci	nop
83962306a36Sopenharmony_ci	nop
84062306a36Sopenharmony_ci
84162306a36Sopenharmony_ci	/* %g5:	error
84262306a36Sopenharmony_ci	 * %g6:	tlb op
84362306a36Sopenharmony_ci	 */
84462306a36Sopenharmony_ci__hypervisor_tlb_xcall_error:
84562306a36Sopenharmony_ci	mov	%g5, %g4
84662306a36Sopenharmony_ci	mov	%g6, %g5
84762306a36Sopenharmony_ci	ba,pt	%xcc, etrap
84862306a36Sopenharmony_ci	 rd	%pc, %g7
84962306a36Sopenharmony_ci	mov	%l4, %o0
85062306a36Sopenharmony_ci	call	hypervisor_tlbop_error_xcall
85162306a36Sopenharmony_ci	 mov	%l5, %o1
85262306a36Sopenharmony_ci	ba,a,pt	%xcc, rtrap
85362306a36Sopenharmony_ci
85462306a36Sopenharmony_ci	.globl		__hypervisor_xcall_flush_tlb_mm
85562306a36Sopenharmony_ci__hypervisor_xcall_flush_tlb_mm: /* 24 insns */
85662306a36Sopenharmony_ci	/* %g5=ctx, g1,g2,g3,g4,g7=scratch, %g6=unusable */
85762306a36Sopenharmony_ci	mov		%o0, %g2
85862306a36Sopenharmony_ci	mov		%o1, %g3
85962306a36Sopenharmony_ci	mov		%o2, %g4
86062306a36Sopenharmony_ci	mov		%o3, %g1
86162306a36Sopenharmony_ci	mov		%o5, %g7
86262306a36Sopenharmony_ci	clr		%o0		/* ARG0: CPU lists unimplemented */
86362306a36Sopenharmony_ci	clr		%o1		/* ARG1: CPU lists unimplemented */
86462306a36Sopenharmony_ci	mov		%g5, %o2	/* ARG2: mmu context */
86562306a36Sopenharmony_ci	mov		HV_MMU_ALL, %o3	/* ARG3: flags */
86662306a36Sopenharmony_ci	mov		HV_FAST_MMU_DEMAP_CTX, %o5
86762306a36Sopenharmony_ci	ta		HV_FAST_TRAP
86862306a36Sopenharmony_ci	mov		HV_FAST_MMU_DEMAP_CTX, %g6
86962306a36Sopenharmony_ci	brnz,pn		%o0, 1f
87062306a36Sopenharmony_ci	 mov		%o0, %g5
87162306a36Sopenharmony_ci	mov		%g2, %o0
87262306a36Sopenharmony_ci	mov		%g3, %o1
87362306a36Sopenharmony_ci	mov		%g4, %o2
87462306a36Sopenharmony_ci	mov		%g1, %o3
87562306a36Sopenharmony_ci	mov		%g7, %o5
87662306a36Sopenharmony_ci	membar		#Sync
87762306a36Sopenharmony_ci	retry
87862306a36Sopenharmony_ci1:	sethi		%hi(__hypervisor_tlb_xcall_error), %g4
87962306a36Sopenharmony_ci	jmpl		%g4 + %lo(__hypervisor_tlb_xcall_error), %g0
88062306a36Sopenharmony_ci	 nop
88162306a36Sopenharmony_ci
88262306a36Sopenharmony_ci	.globl		__hypervisor_xcall_flush_tlb_page
88362306a36Sopenharmony_ci__hypervisor_xcall_flush_tlb_page: /* 20 insns */
88462306a36Sopenharmony_ci	/* %g5=ctx, %g1=vaddr */
88562306a36Sopenharmony_ci	mov		%o0, %g2
88662306a36Sopenharmony_ci	mov		%o1, %g3
88762306a36Sopenharmony_ci	mov		%o2, %g4
88862306a36Sopenharmony_ci	mov		%g1, %o0	        /* ARG0: virtual address */
88962306a36Sopenharmony_ci	mov		%g5, %o1		/* ARG1: mmu context */
89062306a36Sopenharmony_ci	mov		HV_MMU_ALL, %o2		/* ARG2: flags */
89162306a36Sopenharmony_ci	srlx		%o0, PAGE_SHIFT, %o0
89262306a36Sopenharmony_ci	sllx		%o0, PAGE_SHIFT, %o0
89362306a36Sopenharmony_ci	ta		HV_MMU_UNMAP_ADDR_TRAP
89462306a36Sopenharmony_ci	mov		HV_MMU_UNMAP_ADDR_TRAP, %g6
89562306a36Sopenharmony_ci	brnz,a,pn	%o0, 1f
89662306a36Sopenharmony_ci	 mov		%o0, %g5
89762306a36Sopenharmony_ci	mov		%g2, %o0
89862306a36Sopenharmony_ci	mov		%g3, %o1
89962306a36Sopenharmony_ci	mov		%g4, %o2
90062306a36Sopenharmony_ci	membar		#Sync
90162306a36Sopenharmony_ci	retry
90262306a36Sopenharmony_ci1:	sethi		%hi(__hypervisor_tlb_xcall_error), %g4
90362306a36Sopenharmony_ci	jmpl		%g4 + %lo(__hypervisor_tlb_xcall_error), %g0
90462306a36Sopenharmony_ci	 nop
90562306a36Sopenharmony_ci
90662306a36Sopenharmony_ci	.globl		__hypervisor_xcall_flush_tlb_kernel_range
90762306a36Sopenharmony_ci__hypervisor_xcall_flush_tlb_kernel_range: /* 44 insns */
90862306a36Sopenharmony_ci	/* %g1=start, %g7=end, g2,g3,g4,g5,g6=scratch */
90962306a36Sopenharmony_ci	sethi		%hi(PAGE_SIZE - 1), %g2
91062306a36Sopenharmony_ci	or		%g2, %lo(PAGE_SIZE - 1), %g2
91162306a36Sopenharmony_ci	andn		%g1, %g2, %g1
91262306a36Sopenharmony_ci	andn		%g7, %g2, %g7
91362306a36Sopenharmony_ci	sub		%g7, %g1, %g3
91462306a36Sopenharmony_ci	srlx		%g3, 18, %g7
91562306a36Sopenharmony_ci	add		%g2, 1, %g2
91662306a36Sopenharmony_ci	sub		%g3, %g2, %g3
91762306a36Sopenharmony_ci	mov		%o0, %g2
91862306a36Sopenharmony_ci	mov		%o1, %g4
91962306a36Sopenharmony_ci	brnz,pn		%g7, 2f
92062306a36Sopenharmony_ci	 mov		%o2, %g7
92162306a36Sopenharmony_ci1:	add		%g1, %g3, %o0	/* ARG0: virtual address */
92262306a36Sopenharmony_ci	mov		0, %o1		/* ARG1: mmu context */
92362306a36Sopenharmony_ci	mov		HV_MMU_ALL, %o2	/* ARG2: flags */
92462306a36Sopenharmony_ci	ta		HV_MMU_UNMAP_ADDR_TRAP
92562306a36Sopenharmony_ci	mov		HV_MMU_UNMAP_ADDR_TRAP, %g6
92662306a36Sopenharmony_ci	brnz,pn		%o0, 1f
92762306a36Sopenharmony_ci	 mov		%o0, %g5
92862306a36Sopenharmony_ci	sethi		%hi(PAGE_SIZE), %o2
92962306a36Sopenharmony_ci	brnz,pt		%g3, 1b
93062306a36Sopenharmony_ci	 sub		%g3, %o2, %g3
93162306a36Sopenharmony_ci5:	mov		%g2, %o0
93262306a36Sopenharmony_ci	mov		%g4, %o1
93362306a36Sopenharmony_ci	mov		%g7, %o2
93462306a36Sopenharmony_ci	membar		#Sync
93562306a36Sopenharmony_ci	retry
93662306a36Sopenharmony_ci1:	sethi		%hi(__hypervisor_tlb_xcall_error), %g4
93762306a36Sopenharmony_ci	jmpl		%g4 + %lo(__hypervisor_tlb_xcall_error), %g0
93862306a36Sopenharmony_ci	 nop
93962306a36Sopenharmony_ci2:	mov		%o3, %g1
94062306a36Sopenharmony_ci	mov		%o5, %g3
94162306a36Sopenharmony_ci	mov		0, %o0		/* ARG0: CPU lists unimplemented */
94262306a36Sopenharmony_ci	mov		0, %o1		/* ARG1: CPU lists unimplemented */
94362306a36Sopenharmony_ci	mov		0, %o2		/* ARG2: mmu context == nucleus */
94462306a36Sopenharmony_ci	mov		HV_MMU_ALL, %o3	/* ARG3: flags */
94562306a36Sopenharmony_ci	mov		HV_FAST_MMU_DEMAP_CTX, %o5
94662306a36Sopenharmony_ci	ta		HV_FAST_TRAP
94762306a36Sopenharmony_ci	mov		%g1, %o3
94862306a36Sopenharmony_ci	brz,pt		%o0, 5b
94962306a36Sopenharmony_ci	 mov		%g3, %o5
95062306a36Sopenharmony_ci	mov		HV_FAST_MMU_DEMAP_CTX, %g6
95162306a36Sopenharmony_ci	ba,pt		%xcc, 1b
95262306a36Sopenharmony_ci	 clr		%g5
95362306a36Sopenharmony_ci
95462306a36Sopenharmony_ci	/* These just get rescheduled to PIL vectors. */
95562306a36Sopenharmony_ci	.globl		xcall_call_function
95662306a36Sopenharmony_cixcall_call_function:
95762306a36Sopenharmony_ci	wr		%g0, (1 << PIL_SMP_CALL_FUNC), %set_softint
95862306a36Sopenharmony_ci	retry
95962306a36Sopenharmony_ci
96062306a36Sopenharmony_ci	.globl		xcall_call_function_single
96162306a36Sopenharmony_cixcall_call_function_single:
96262306a36Sopenharmony_ci	wr		%g0, (1 << PIL_SMP_CALL_FUNC_SNGL), %set_softint
96362306a36Sopenharmony_ci	retry
96462306a36Sopenharmony_ci
96562306a36Sopenharmony_ci	.globl		xcall_receive_signal
96662306a36Sopenharmony_cixcall_receive_signal:
96762306a36Sopenharmony_ci	wr		%g0, (1 << PIL_SMP_RECEIVE_SIGNAL), %set_softint
96862306a36Sopenharmony_ci	retry
96962306a36Sopenharmony_ci
97062306a36Sopenharmony_ci	.globl		xcall_capture
97162306a36Sopenharmony_cixcall_capture:
97262306a36Sopenharmony_ci	wr		%g0, (1 << PIL_SMP_CAPTURE), %set_softint
97362306a36Sopenharmony_ci	retry
97462306a36Sopenharmony_ci
97562306a36Sopenharmony_ci#ifdef CONFIG_KGDB
97662306a36Sopenharmony_ci	.globl		xcall_kgdb_capture
97762306a36Sopenharmony_cixcall_kgdb_capture:
97862306a36Sopenharmony_ci	wr		%g0, (1 << PIL_KGDB_CAPTURE), %set_softint
97962306a36Sopenharmony_ci	retry
98062306a36Sopenharmony_ci#endif
98162306a36Sopenharmony_ci
98262306a36Sopenharmony_ci#endif /* CONFIG_SMP */
98362306a36Sopenharmony_ci
98462306a36Sopenharmony_ci	.globl		cheetah_patch_cachetlbops
98562306a36Sopenharmony_cicheetah_patch_cachetlbops:
98662306a36Sopenharmony_ci	save		%sp, -128, %sp
98762306a36Sopenharmony_ci
98862306a36Sopenharmony_ci	sethi		%hi(__flush_tlb_mm), %o0
98962306a36Sopenharmony_ci	or		%o0, %lo(__flush_tlb_mm), %o0
99062306a36Sopenharmony_ci	sethi		%hi(__cheetah_flush_tlb_mm), %o1
99162306a36Sopenharmony_ci	or		%o1, %lo(__cheetah_flush_tlb_mm), %o1
99262306a36Sopenharmony_ci	call		tlb_patch_one
99362306a36Sopenharmony_ci	 mov		19, %o2
99462306a36Sopenharmony_ci
99562306a36Sopenharmony_ci	sethi		%hi(__flush_tlb_page), %o0
99662306a36Sopenharmony_ci	or		%o0, %lo(__flush_tlb_page), %o0
99762306a36Sopenharmony_ci	sethi		%hi(__cheetah_flush_tlb_page), %o1
99862306a36Sopenharmony_ci	or		%o1, %lo(__cheetah_flush_tlb_page), %o1
99962306a36Sopenharmony_ci	call		tlb_patch_one
100062306a36Sopenharmony_ci	 mov		22, %o2
100162306a36Sopenharmony_ci
100262306a36Sopenharmony_ci	sethi		%hi(__flush_tlb_pending), %o0
100362306a36Sopenharmony_ci	or		%o0, %lo(__flush_tlb_pending), %o0
100462306a36Sopenharmony_ci	sethi		%hi(__cheetah_flush_tlb_pending), %o1
100562306a36Sopenharmony_ci	or		%o1, %lo(__cheetah_flush_tlb_pending), %o1
100662306a36Sopenharmony_ci	call		tlb_patch_one
100762306a36Sopenharmony_ci	 mov		27, %o2
100862306a36Sopenharmony_ci
100962306a36Sopenharmony_ci	sethi		%hi(__flush_tlb_kernel_range), %o0
101062306a36Sopenharmony_ci	or		%o0, %lo(__flush_tlb_kernel_range), %o0
101162306a36Sopenharmony_ci	sethi		%hi(__cheetah_flush_tlb_kernel_range), %o1
101262306a36Sopenharmony_ci	or		%o1, %lo(__cheetah_flush_tlb_kernel_range), %o1
101362306a36Sopenharmony_ci	call		tlb_patch_one
101462306a36Sopenharmony_ci	 mov		31, %o2
101562306a36Sopenharmony_ci
101662306a36Sopenharmony_ci#ifdef DCACHE_ALIASING_POSSIBLE
101762306a36Sopenharmony_ci	sethi		%hi(__flush_dcache_page), %o0
101862306a36Sopenharmony_ci	or		%o0, %lo(__flush_dcache_page), %o0
101962306a36Sopenharmony_ci	sethi		%hi(__cheetah_flush_dcache_page), %o1
102062306a36Sopenharmony_ci	or		%o1, %lo(__cheetah_flush_dcache_page), %o1
102162306a36Sopenharmony_ci	call		tlb_patch_one
102262306a36Sopenharmony_ci	 mov		11, %o2
102362306a36Sopenharmony_ci#endif /* DCACHE_ALIASING_POSSIBLE */
102462306a36Sopenharmony_ci
102562306a36Sopenharmony_ci#ifdef CONFIG_SMP
102662306a36Sopenharmony_ci	sethi		%hi(xcall_flush_tlb_kernel_range), %o0
102762306a36Sopenharmony_ci	or		%o0, %lo(xcall_flush_tlb_kernel_range), %o0
102862306a36Sopenharmony_ci	sethi		%hi(__cheetah_xcall_flush_tlb_kernel_range), %o1
102962306a36Sopenharmony_ci	or		%o1, %lo(__cheetah_xcall_flush_tlb_kernel_range), %o1
103062306a36Sopenharmony_ci	call		tlb_patch_one
103162306a36Sopenharmony_ci	 mov		44, %o2
103262306a36Sopenharmony_ci#endif /* CONFIG_SMP */
103362306a36Sopenharmony_ci
103462306a36Sopenharmony_ci	ret
103562306a36Sopenharmony_ci	 restore
103662306a36Sopenharmony_ci
103762306a36Sopenharmony_ci	.globl		hypervisor_patch_cachetlbops
103862306a36Sopenharmony_cihypervisor_patch_cachetlbops:
103962306a36Sopenharmony_ci	save		%sp, -128, %sp
104062306a36Sopenharmony_ci
104162306a36Sopenharmony_ci	sethi		%hi(__flush_tlb_mm), %o0
104262306a36Sopenharmony_ci	or		%o0, %lo(__flush_tlb_mm), %o0
104362306a36Sopenharmony_ci	sethi		%hi(__hypervisor_flush_tlb_mm), %o1
104462306a36Sopenharmony_ci	or		%o1, %lo(__hypervisor_flush_tlb_mm), %o1
104562306a36Sopenharmony_ci	call		tlb_patch_one
104662306a36Sopenharmony_ci	 mov		19, %o2
104762306a36Sopenharmony_ci
104862306a36Sopenharmony_ci	sethi		%hi(__flush_tlb_page), %o0
104962306a36Sopenharmony_ci	or		%o0, %lo(__flush_tlb_page), %o0
105062306a36Sopenharmony_ci	sethi		%hi(__hypervisor_flush_tlb_page), %o1
105162306a36Sopenharmony_ci	or		%o1, %lo(__hypervisor_flush_tlb_page), %o1
105262306a36Sopenharmony_ci	call		tlb_patch_one
105362306a36Sopenharmony_ci	 mov		22, %o2
105462306a36Sopenharmony_ci
105562306a36Sopenharmony_ci	sethi		%hi(__flush_tlb_pending), %o0
105662306a36Sopenharmony_ci	or		%o0, %lo(__flush_tlb_pending), %o0
105762306a36Sopenharmony_ci	sethi		%hi(__hypervisor_flush_tlb_pending), %o1
105862306a36Sopenharmony_ci	or		%o1, %lo(__hypervisor_flush_tlb_pending), %o1
105962306a36Sopenharmony_ci	call		tlb_patch_one
106062306a36Sopenharmony_ci	 mov		27, %o2
106162306a36Sopenharmony_ci
106262306a36Sopenharmony_ci	sethi		%hi(__flush_tlb_kernel_range), %o0
106362306a36Sopenharmony_ci	or		%o0, %lo(__flush_tlb_kernel_range), %o0
106462306a36Sopenharmony_ci	sethi		%hi(__hypervisor_flush_tlb_kernel_range), %o1
106562306a36Sopenharmony_ci	or		%o1, %lo(__hypervisor_flush_tlb_kernel_range), %o1
106662306a36Sopenharmony_ci	call		tlb_patch_one
106762306a36Sopenharmony_ci	 mov		31, %o2
106862306a36Sopenharmony_ci
106962306a36Sopenharmony_ci#ifdef DCACHE_ALIASING_POSSIBLE
107062306a36Sopenharmony_ci	sethi		%hi(__flush_dcache_page), %o0
107162306a36Sopenharmony_ci	or		%o0, %lo(__flush_dcache_page), %o0
107262306a36Sopenharmony_ci	sethi		%hi(__hypervisor_flush_dcache_page), %o1
107362306a36Sopenharmony_ci	or		%o1, %lo(__hypervisor_flush_dcache_page), %o1
107462306a36Sopenharmony_ci	call		tlb_patch_one
107562306a36Sopenharmony_ci	 mov		2, %o2
107662306a36Sopenharmony_ci#endif /* DCACHE_ALIASING_POSSIBLE */
107762306a36Sopenharmony_ci
107862306a36Sopenharmony_ci#ifdef CONFIG_SMP
107962306a36Sopenharmony_ci	sethi		%hi(xcall_flush_tlb_mm), %o0
108062306a36Sopenharmony_ci	or		%o0, %lo(xcall_flush_tlb_mm), %o0
108162306a36Sopenharmony_ci	sethi		%hi(__hypervisor_xcall_flush_tlb_mm), %o1
108262306a36Sopenharmony_ci	or		%o1, %lo(__hypervisor_xcall_flush_tlb_mm), %o1
108362306a36Sopenharmony_ci	call		tlb_patch_one
108462306a36Sopenharmony_ci	 mov		24, %o2
108562306a36Sopenharmony_ci
108662306a36Sopenharmony_ci	sethi		%hi(xcall_flush_tlb_page), %o0
108762306a36Sopenharmony_ci	or		%o0, %lo(xcall_flush_tlb_page), %o0
108862306a36Sopenharmony_ci	sethi		%hi(__hypervisor_xcall_flush_tlb_page), %o1
108962306a36Sopenharmony_ci	or		%o1, %lo(__hypervisor_xcall_flush_tlb_page), %o1
109062306a36Sopenharmony_ci	call		tlb_patch_one
109162306a36Sopenharmony_ci	 mov		20, %o2
109262306a36Sopenharmony_ci
109362306a36Sopenharmony_ci	sethi		%hi(xcall_flush_tlb_kernel_range), %o0
109462306a36Sopenharmony_ci	or		%o0, %lo(xcall_flush_tlb_kernel_range), %o0
109562306a36Sopenharmony_ci	sethi		%hi(__hypervisor_xcall_flush_tlb_kernel_range), %o1
109662306a36Sopenharmony_ci	or		%o1, %lo(__hypervisor_xcall_flush_tlb_kernel_range), %o1
109762306a36Sopenharmony_ci	call		tlb_patch_one
109862306a36Sopenharmony_ci	 mov		44, %o2
109962306a36Sopenharmony_ci#endif /* CONFIG_SMP */
110062306a36Sopenharmony_ci
110162306a36Sopenharmony_ci	ret
110262306a36Sopenharmony_ci	 restore
1103