blob: d4d245c0d78799a6f48e65aae52560b75daac6e7 [file] [log] [blame]
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +09001/*
2 * "Cell Reference Set" HTAB support.
3 *
4 * (C) Copyright 2006-2007 TOSHIBA CORPORATION
5 *
6 * This code is based on arch/powerpc/platforms/pseries/lpar.c:
7 * Copyright (C) 2001 Todd Inglett, IBM Corporation
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24#undef DEBUG_LOW
25
26#include <linux/kernel.h>
27#include <linux/spinlock.h>
28
29#include <asm/mmu.h>
30#include <asm/page.h>
31#include <asm/pgtable.h>
32#include <asm/machdep.h>
33#include <asm/udbg.h>
34
Ishizaki Kou8ae6e302008-04-24 19:28:48 +100035#include "beat_wrapper.h"
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +090036
37#ifdef DEBUG_LOW
Ishizaki Kou2fe37a62008-03-14 23:19:34 +110038#define DBG_LOW(fmt...) do { udbg_printf(fmt); } while (0)
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +090039#else
Ishizaki Kou2fe37a62008-03-14 23:19:34 +110040#define DBG_LOW(fmt...) do { } while (0)
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +090041#endif
42
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +000043static DEFINE_RAW_SPINLOCK(beat_htab_lock);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +090044
45static inline unsigned int beat_read_mask(unsigned hpte_group)
46{
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +090047 unsigned long rmask = 0;
Ingo Molnar19b0bd02009-01-06 14:01:23 +000048 u64 hpte_v[5];
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +090049
50 beat_read_htab_entries(0, hpte_group + 0, hpte_v);
51 if (!(hpte_v[0] & HPTE_V_BOLTED))
52 rmask |= 0x8000;
53 if (!(hpte_v[1] & HPTE_V_BOLTED))
54 rmask |= 0x4000;
55 if (!(hpte_v[2] & HPTE_V_BOLTED))
56 rmask |= 0x2000;
57 if (!(hpte_v[3] & HPTE_V_BOLTED))
58 rmask |= 0x1000;
59 beat_read_htab_entries(0, hpte_group + 4, hpte_v);
60 if (!(hpte_v[0] & HPTE_V_BOLTED))
61 rmask |= 0x0800;
62 if (!(hpte_v[1] & HPTE_V_BOLTED))
63 rmask |= 0x0400;
64 if (!(hpte_v[2] & HPTE_V_BOLTED))
65 rmask |= 0x0200;
66 if (!(hpte_v[3] & HPTE_V_BOLTED))
67 rmask |= 0x0100;
68 hpte_group = ~hpte_group & (htab_hash_mask * HPTES_PER_GROUP);
69 beat_read_htab_entries(0, hpte_group + 0, hpte_v);
70 if (!(hpte_v[0] & HPTE_V_BOLTED))
71 rmask |= 0x80;
72 if (!(hpte_v[1] & HPTE_V_BOLTED))
73 rmask |= 0x40;
74 if (!(hpte_v[2] & HPTE_V_BOLTED))
75 rmask |= 0x20;
76 if (!(hpte_v[3] & HPTE_V_BOLTED))
77 rmask |= 0x10;
78 beat_read_htab_entries(0, hpte_group + 4, hpte_v);
79 if (!(hpte_v[0] & HPTE_V_BOLTED))
80 rmask |= 0x08;
81 if (!(hpte_v[1] & HPTE_V_BOLTED))
82 rmask |= 0x04;
83 if (!(hpte_v[2] & HPTE_V_BOLTED))
84 rmask |= 0x02;
85 if (!(hpte_v[3] & HPTE_V_BOLTED))
86 rmask |= 0x01;
87 return rmask;
88}
89
90static long beat_lpar_hpte_insert(unsigned long hpte_group,
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +000091 unsigned long vpn, unsigned long pa,
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +090092 unsigned long rflags, unsigned long vflags,
Aneesh Kumar K.Vb1022fb2013-04-28 09:37:35 +000093 int psize, int apsize, int ssize)
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +090094{
95 unsigned long lpar_rc;
Ingo Molnar19b0bd02009-01-06 14:01:23 +000096 u64 hpte_v, hpte_r, slot;
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +090097
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +090098 if (vflags & HPTE_V_SECONDARY)
99 return -1;
100
101 if (!(vflags & HPTE_V_BOLTED))
102 DBG_LOW("hpte_insert(group=%lx, va=%016lx, pa=%016lx, "
103 "rflags=%lx, vflags=%lx, psize=%d)\n",
104 hpte_group, va, pa, rflags, vflags, psize);
105
Aneesh Kumar K.Vb1022fb2013-04-28 09:37:35 +0000106 hpte_v = hpte_encode_v(vpn, psize, apsize, MMU_SEGSIZE_256M) |
Paul Mackerras1189be62007-10-11 20:37:10 +1000107 vflags | HPTE_V_VALID;
Aneesh Kumar K.Vb1022fb2013-04-28 09:37:35 +0000108 hpte_r = hpte_encode_r(pa, psize, apsize) | rflags;
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900109
110 if (!(vflags & HPTE_V_BOLTED))
111 DBG_LOW(" hpte_v=%016lx, hpte_r=%016lx\n", hpte_v, hpte_r);
112
Dave Kleikamp443dcac2008-07-10 01:28:07 +1000113 if (rflags & _PAGE_NO_CACHE)
Aneesh Kumar K.V92c08a02013-11-18 14:58:09 +0530114 hpte_r &= ~HPTE_R_M;
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900115
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000116 raw_spin_lock(&beat_htab_lock);
Ishizaki Kou2fe37a62008-03-14 23:19:34 +1100117 lpar_rc = beat_read_mask(hpte_group);
118 if (lpar_rc == 0) {
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900119 if (!(vflags & HPTE_V_BOLTED))
120 DBG_LOW(" full\n");
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000121 raw_spin_unlock(&beat_htab_lock);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900122 return -1;
123 }
124
125 lpar_rc = beat_insert_htab_entry(0, hpte_group, lpar_rc << 48,
126 hpte_v, hpte_r, &slot);
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000127 raw_spin_unlock(&beat_htab_lock);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900128
129 /*
130 * Since we try and ioremap PHBs we don't own, the pte insert
131 * will fail. However we must catch the failure in hash_page
132 * or we will loop forever, so return -2 in this case.
133 */
134 if (unlikely(lpar_rc != 0)) {
135 if (!(vflags & HPTE_V_BOLTED))
136 DBG_LOW(" lpar err %lx\n", lpar_rc);
137 return -2;
138 }
139 if (!(vflags & HPTE_V_BOLTED))
140 DBG_LOW(" -> slot: %lx\n", slot);
141
142 /* We have to pass down the secondary bucket bit here as well */
143 return (slot ^ hpte_group) & 15;
144}
145
146static long beat_lpar_hpte_remove(unsigned long hpte_group)
147{
148 DBG_LOW("hpte_remove(group=%lx)\n", hpte_group);
149 return -1;
150}
151
152static unsigned long beat_lpar_hpte_getword0(unsigned long slot)
153{
Ingo Molnar19b0bd02009-01-06 14:01:23 +0000154 unsigned long dword0;
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900155 unsigned long lpar_rc;
Ingo Molnar19b0bd02009-01-06 14:01:23 +0000156 u64 dword[5];
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900157
158 lpar_rc = beat_read_htab_entries(0, slot & ~3UL, dword);
159
160 dword0 = dword[slot&3];
161
162 BUG_ON(lpar_rc != 0);
163
164 return dword0;
165}
166
167static void beat_lpar_hptab_clear(void)
168{
169 unsigned long size_bytes = 1UL << ppc64_pft_size;
170 unsigned long hpte_count = size_bytes >> 4;
171 int i;
Ingo Molnar19b0bd02009-01-06 14:01:23 +0000172 u64 dummy0, dummy1;
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900173
174 /* TODO: Use bulk call */
175 for (i = 0; i < hpte_count; i++)
176 beat_write_htab_entry(0, i, 0, 0, -1UL, -1UL, &dummy0, &dummy1);
177}
178
179/*
180 * NOTE: for updatepp ops we are fortunate that the linux "newpp" bits and
181 * the low 3 bits of flags happen to line up. So no transform is needed.
182 * We can probably optimize here and assume the high bits of newpp are
183 * already zero. For now I am paranoid.
184 */
185static long beat_lpar_hpte_updatepp(unsigned long slot,
186 unsigned long newpp,
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000187 unsigned long vpn,
Aneesh Kumar K.Vdb3d8532013-06-20 14:30:13 +0530188 int psize, int apsize,
189 int ssize, int local)
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900190{
191 unsigned long lpar_rc;
Ingo Molnar19b0bd02009-01-06 14:01:23 +0000192 u64 dummy0, dummy1;
193 unsigned long want_v;
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900194
Aneesh Kumar K.V74f227b2013-04-28 09:37:34 +0000195 want_v = hpte_encode_avpn(vpn, psize, MMU_SEGSIZE_256M);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900196
197 DBG_LOW(" update: "
198 "avpnv=%016lx, slot=%016lx, psize: %d, newpp %016lx ... ",
199 want_v & HPTE_V_AVPN, slot, psize, newpp);
200
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000201 raw_spin_lock(&beat_htab_lock);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900202 dummy0 = beat_lpar_hpte_getword0(slot);
203 if ((dummy0 & ~0x7FUL) != (want_v & ~0x7FUL)) {
204 DBG_LOW("not found !\n");
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000205 raw_spin_unlock(&beat_htab_lock);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900206 return -1;
207 }
208
209 lpar_rc = beat_write_htab_entry(0, slot, 0, newpp, 0, 7, &dummy0,
210 &dummy1);
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000211 raw_spin_unlock(&beat_htab_lock);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900212 if (lpar_rc != 0 || dummy0 == 0) {
213 DBG_LOW("not found !\n");
214 return -1;
215 }
216
217 DBG_LOW("ok %lx %lx\n", dummy0, dummy1);
218
219 BUG_ON(lpar_rc != 0);
220
221 return 0;
222}
223
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000224static long beat_lpar_hpte_find(unsigned long vpn, int psize)
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900225{
226 unsigned long hash;
227 unsigned long i, j;
228 long slot;
229 unsigned long want_v, hpte_v;
230
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000231 hash = hpt_hash(vpn, mmu_psize_defs[psize].shift, MMU_SEGSIZE_256M);
Aneesh Kumar K.V74f227b2013-04-28 09:37:34 +0000232 want_v = hpte_encode_avpn(vpn, psize, MMU_SEGSIZE_256M);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900233
234 for (j = 0; j < 2; j++) {
235 slot = (hash & htab_hash_mask) * HPTES_PER_GROUP;
236 for (i = 0; i < HPTES_PER_GROUP; i++) {
237 hpte_v = beat_lpar_hpte_getword0(slot);
238
239 if (HPTE_V_COMPARE(hpte_v, want_v)
240 && (hpte_v & HPTE_V_VALID)
241 && (!!(hpte_v & HPTE_V_SECONDARY) == j)) {
242 /* HPTE matches */
243 if (j)
244 slot = -slot;
245 return slot;
246 }
247 ++slot;
248 }
249 hash = ~hash;
250 }
251
252 return -1;
253}
254
255static void beat_lpar_hpte_updateboltedpp(unsigned long newpp,
256 unsigned long ea,
Paul Mackerras1189be62007-10-11 20:37:10 +1000257 int psize, int ssize)
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900258{
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000259 unsigned long vpn;
260 unsigned long lpar_rc, slot, vsid;
Ingo Molnar19b0bd02009-01-06 14:01:23 +0000261 u64 dummy0, dummy1;
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900262
Paul Mackerras1189be62007-10-11 20:37:10 +1000263 vsid = get_kernel_vsid(ea, MMU_SEGSIZE_256M);
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000264 vpn = hpt_vpn(ea, vsid, MMU_SEGSIZE_256M);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900265
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000266 raw_spin_lock(&beat_htab_lock);
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000267 slot = beat_lpar_hpte_find(vpn, psize);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900268 BUG_ON(slot == -1);
269
270 lpar_rc = beat_write_htab_entry(0, slot, 0, newpp, 0, 7,
271 &dummy0, &dummy1);
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000272 raw_spin_unlock(&beat_htab_lock);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900273
274 BUG_ON(lpar_rc != 0);
275}
276
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000277static void beat_lpar_hpte_invalidate(unsigned long slot, unsigned long vpn,
Aneesh Kumar K.Vdb3d8532013-06-20 14:30:13 +0530278 int psize, int apsize,
279 int ssize, int local)
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900280{
281 unsigned long want_v;
282 unsigned long lpar_rc;
Ingo Molnar19b0bd02009-01-06 14:01:23 +0000283 u64 dummy1, dummy2;
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900284 unsigned long flags;
285
286 DBG_LOW(" inval : slot=%lx, va=%016lx, psize: %d, local: %d\n",
287 slot, va, psize, local);
Aneesh Kumar K.V74f227b2013-04-28 09:37:34 +0000288 want_v = hpte_encode_avpn(vpn, psize, MMU_SEGSIZE_256M);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900289
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000290 raw_spin_lock_irqsave(&beat_htab_lock, flags);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900291 dummy1 = beat_lpar_hpte_getword0(slot);
292
293 if ((dummy1 & ~0x7FUL) != (want_v & ~0x7FUL)) {
294 DBG_LOW("not found !\n");
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000295 raw_spin_unlock_irqrestore(&beat_htab_lock, flags);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900296 return;
297 }
298
299 lpar_rc = beat_write_htab_entry(0, slot, 0, 0, HPTE_V_VALID, 0,
300 &dummy1, &dummy2);
Thomas Gleixner7cc8a5e2010-02-18 02:22:47 +0000301 raw_spin_unlock_irqrestore(&beat_htab_lock, flags);
Ishizaki Koufe4a0cf2007-02-02 16:42:28 +0900302
303 BUG_ON(lpar_rc != 0);
304}
305
306void __init hpte_init_beat(void)
307{
308 ppc_md.hpte_invalidate = beat_lpar_hpte_invalidate;
309 ppc_md.hpte_updatepp = beat_lpar_hpte_updatepp;
310 ppc_md.hpte_updateboltedpp = beat_lpar_hpte_updateboltedpp;
311 ppc_md.hpte_insert = beat_lpar_hpte_insert;
312 ppc_md.hpte_remove = beat_lpar_hpte_remove;
313 ppc_md.hpte_clear_all = beat_lpar_hptab_clear;
314}
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000315
316static long beat_lpar_hpte_insert_v3(unsigned long hpte_group,
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000317 unsigned long vpn, unsigned long pa,
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000318 unsigned long rflags, unsigned long vflags,
Aneesh Kumar K.Vb1022fb2013-04-28 09:37:35 +0000319 int psize, int apsize, int ssize)
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000320{
321 unsigned long lpar_rc;
Ingo Molnar19b0bd02009-01-06 14:01:23 +0000322 u64 hpte_v, hpte_r, slot;
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000323
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000324 if (vflags & HPTE_V_SECONDARY)
325 return -1;
326
327 if (!(vflags & HPTE_V_BOLTED))
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000328 DBG_LOW("hpte_insert(group=%lx, vpn=%016lx, pa=%016lx, "
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000329 "rflags=%lx, vflags=%lx, psize=%d)\n",
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000330 hpte_group, vpn, pa, rflags, vflags, psize);
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000331
Aneesh Kumar K.Vb1022fb2013-04-28 09:37:35 +0000332 hpte_v = hpte_encode_v(vpn, psize, apsize, MMU_SEGSIZE_256M) |
Paul Mackerras1189be62007-10-11 20:37:10 +1000333 vflags | HPTE_V_VALID;
Aneesh Kumar K.Vb1022fb2013-04-28 09:37:35 +0000334 hpte_r = hpte_encode_r(pa, psize, apsize) | rflags;
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000335
336 if (!(vflags & HPTE_V_BOLTED))
337 DBG_LOW(" hpte_v=%016lx, hpte_r=%016lx\n", hpte_v, hpte_r);
338
Dave Kleikamp443dcac2008-07-10 01:28:07 +1000339 if (rflags & _PAGE_NO_CACHE)
Aneesh Kumar K.V92c08a02013-11-18 14:58:09 +0530340 hpte_r &= ~HPTE_R_M;
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000341
342 /* insert into not-volted entry */
343 lpar_rc = beat_insert_htab_entry3(0, hpte_group, hpte_v, hpte_r,
344 HPTE_V_BOLTED, 0, &slot);
345 /*
346 * Since we try and ioremap PHBs we don't own, the pte insert
347 * will fail. However we must catch the failure in hash_page
348 * or we will loop forever, so return -2 in this case.
349 */
350 if (unlikely(lpar_rc != 0)) {
351 if (!(vflags & HPTE_V_BOLTED))
352 DBG_LOW(" lpar err %lx\n", lpar_rc);
353 return -2;
354 }
355 if (!(vflags & HPTE_V_BOLTED))
356 DBG_LOW(" -> slot: %lx\n", slot);
357
358 /* We have to pass down the secondary bucket bit here as well */
359 return (slot ^ hpte_group) & 15;
360}
361
362/*
363 * NOTE: for updatepp ops we are fortunate that the linux "newpp" bits and
364 * the low 3 bits of flags happen to line up. So no transform is needed.
365 * We can probably optimize here and assume the high bits of newpp are
366 * already zero. For now I am paranoid.
367 */
368static long beat_lpar_hpte_updatepp_v3(unsigned long slot,
Aneesh Kumar K.Vdb3d8532013-06-20 14:30:13 +0530369 unsigned long newpp,
370 unsigned long vpn,
371 int psize, int apsize,
372 int ssize, int local)
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000373{
374 unsigned long lpar_rc;
375 unsigned long want_v;
376 unsigned long pss;
377
Aneesh Kumar K.V74f227b2013-04-28 09:37:34 +0000378 want_v = hpte_encode_avpn(vpn, psize, MMU_SEGSIZE_256M);
Aneesh Kumar K.Vb1022fb2013-04-28 09:37:35 +0000379 pss = (psize == MMU_PAGE_4K) ? -1UL : mmu_psize_defs[psize].penc[psize];
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000380
381 DBG_LOW(" update: "
382 "avpnv=%016lx, slot=%016lx, psize: %d, newpp %016lx ... ",
383 want_v & HPTE_V_AVPN, slot, psize, newpp);
384
385 lpar_rc = beat_update_htab_permission3(0, slot, want_v, pss, 7, newpp);
386
387 if (lpar_rc == 0xfffffff7) {
388 DBG_LOW("not found !\n");
389 return -1;
390 }
391
392 DBG_LOW("ok\n");
393
394 BUG_ON(lpar_rc != 0);
395
396 return 0;
397}
398
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000399static void beat_lpar_hpte_invalidate_v3(unsigned long slot, unsigned long vpn,
Aneesh Kumar K.Vdb3d8532013-06-20 14:30:13 +0530400 int psize, int apsize,
401 int ssize, int local)
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000402{
403 unsigned long want_v;
404 unsigned long lpar_rc;
405 unsigned long pss;
406
Aneesh Kumar K.V5524a272012-09-10 02:52:50 +0000407 DBG_LOW(" inval : slot=%lx, vpn=%016lx, psize: %d, local: %d\n",
408 slot, vpn, psize, local);
Aneesh Kumar K.V74f227b2013-04-28 09:37:34 +0000409 want_v = hpte_encode_avpn(vpn, psize, MMU_SEGSIZE_256M);
Aneesh Kumar K.Vb1022fb2013-04-28 09:37:35 +0000410 pss = (psize == MMU_PAGE_4K) ? -1UL : mmu_psize_defs[psize].penc[psize];
Ishizaki Kou7f2c8572007-10-02 18:23:46 +1000411
412 lpar_rc = beat_invalidate_htab_entry3(0, slot, want_v, pss);
413
414 /* E_busy can be valid output: page may be already replaced */
415 BUG_ON(lpar_rc != 0 && lpar_rc != 0xfffffff7);
416}
417
418static int64_t _beat_lpar_hptab_clear_v3(void)
419{
420 return beat_clear_htab3(0);
421}
422
423static void beat_lpar_hptab_clear_v3(void)
424{
425 _beat_lpar_hptab_clear_v3();
426}
427
428void __init hpte_init_beat_v3(void)
429{
430 if (_beat_lpar_hptab_clear_v3() == 0) {
431 ppc_md.hpte_invalidate = beat_lpar_hpte_invalidate_v3;
432 ppc_md.hpte_updatepp = beat_lpar_hpte_updatepp_v3;
433 ppc_md.hpte_updateboltedpp = beat_lpar_hpte_updateboltedpp;
434 ppc_md.hpte_insert = beat_lpar_hpte_insert_v3;
435 ppc_md.hpte_remove = beat_lpar_hpte_remove;
436 ppc_md.hpte_clear_all = beat_lpar_hptab_clear_v3;
437 } else {
438 ppc_md.hpte_invalidate = beat_lpar_hpte_invalidate;
439 ppc_md.hpte_updatepp = beat_lpar_hpte_updatepp;
440 ppc_md.hpte_updateboltedpp = beat_lpar_hpte_updateboltedpp;
441 ppc_md.hpte_insert = beat_lpar_hpte_insert;
442 ppc_md.hpte_remove = beat_lpar_hpte_remove;
443 ppc_md.hpte_clear_all = beat_lpar_hptab_clear;
444 }
445}