1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* clear_page.S: UltraSparc optimized clear page.
4 * Copyright (C) 1996, 1998, 1999, 2000, 2004 David S. Miller (davem@redhat.com)
5 * Copyright (C) 1997 Jakub Jelinek (jakub@redhat.com)
8 #include <asm/visasm.h>
9 #include <asm/thread_info.h>
11 #include <asm/pgtable.h>
12 #include <asm/spitfire.h>
14 #include <asm/export.h>
16 /* What we used to do was lock a TLB entry into a specific
17 * TLB slot, clear the page with interrupts disabled, then
18 * restore the original TLB entry. This was great for
19 * disturbing the TLB as little as possible, but it meant
20 * we had to keep interrupts disabled for a long time.
22 * Now, we simply use the normal TLB loading mechanism,
23 * and this makes the cpu choose a slot all by itself.
24 * Then we do a normal TLB flush on exit. We need only
25 * disable preemption during the clear.
31 EXPORT_SYMBOL(_clear_page)
32 _clear_page: /* %o0=dest */
33 ba,pt %xcc, clear_page_common
36 /* This thing is pretty important, it shows up
37 * on the profiles via do_anonymous_page().
40 .globl clear_user_page
41 EXPORT_SYMBOL(clear_user_page)
42 clear_user_page: /* %o0=dest, %o1=vaddr */
43 lduw [%g6 + TI_PRE_COUNT], %o2
44 sethi %hi(PAGE_OFFSET), %g2
45 sethi %hi(PAGE_SIZE), %o4
47 ldx [%g2 + %lo(PAGE_OFFSET)], %g2
48 sethi %hi(PAGE_KERNEL_LOCKED), %g3
50 ldx [%g3 + %lo(PAGE_KERNEL_LOCKED)], %g3
51 sub %o0, %g2, %g1 ! paddr
53 and %o1, %o4, %o0 ! vaddr D-cache alias bit
55 or %g1, %g3, %g1 ! TTE data
56 sethi %hi(TLBTEMP_BASE), %o3
59 add %o0, %o3, %o0 ! TTE vaddr
61 /* Disable preemption. */
62 mov TLB_TAG_ACCESS, %g3
63 stw %o4, [%g6 + TI_PRE_COUNT]
67 wrpr %o4, PSTATE_IE, %pstate
68 stxa %o0, [%g3] ASI_DMMU
69 stxa %g1, [%g0] ASI_DTLB_DATA_IN
70 sethi %hi(KERNBASE), %g1
72 wrpr %o4, 0x0, %pstate
78 membar #StoreLoad | #StoreStore | #LoadStore
80 sethi %hi(PAGE_SIZE/64), %o1
81 mov %o0, %g1 ! remember vaddr for tlbflush
83 or %o1, %lo(PAGE_SIZE/64), %o1
91 1: stda %f0, [%o0 + %g0] ASI_BLK_P
101 stxa %g0, [%g1] ASI_DMMU_DEMAP
103 stw %o2, [%g6 + TI_PRE_COUNT]