Statistics
| Branch: | Revision:

root / hw / spapr_hcall.c @ a1bc20df

History | View | Annotate | Download (20.5 kB)

1 9fdf0c29 David Gibson
#include "sysemu.h"
2 9fdf0c29 David Gibson
#include "cpu.h"
3 9fdf0c29 David Gibson
#include "qemu-char.h"
4 f43e3525 David Gibson
#include "sysemu.h"
5 f43e3525 David Gibson
#include "qemu-char.h"
6 ed120055 David Gibson
#include "helper_regs.h"
7 9fdf0c29 David Gibson
#include "hw/spapr.h"
8 9fdf0c29 David Gibson
9 f43e3525 David Gibson
#define HPTES_PER_GROUP 8
10 f43e3525 David Gibson
11 f43e3525 David Gibson
#define HPTE_V_SSIZE_SHIFT      62
12 f43e3525 David Gibson
#define HPTE_V_AVPN_SHIFT       7
13 f43e3525 David Gibson
#define HPTE_V_AVPN             0x3fffffffffffff80ULL
14 f43e3525 David Gibson
#define HPTE_V_AVPN_VAL(x)      (((x) & HPTE_V_AVPN) >> HPTE_V_AVPN_SHIFT)
15 f43e3525 David Gibson
#define HPTE_V_COMPARE(x, y)    (!(((x) ^ (y)) & 0xffffffffffffff80UL))
16 f43e3525 David Gibson
#define HPTE_V_BOLTED           0x0000000000000010ULL
17 f43e3525 David Gibson
#define HPTE_V_LOCK             0x0000000000000008ULL
18 f43e3525 David Gibson
#define HPTE_V_LARGE            0x0000000000000004ULL
19 f43e3525 David Gibson
#define HPTE_V_SECONDARY        0x0000000000000002ULL
20 f43e3525 David Gibson
#define HPTE_V_VALID            0x0000000000000001ULL
21 f43e3525 David Gibson
22 f43e3525 David Gibson
#define HPTE_R_PP0              0x8000000000000000ULL
23 f43e3525 David Gibson
#define HPTE_R_TS               0x4000000000000000ULL
24 f43e3525 David Gibson
#define HPTE_R_KEY_HI           0x3000000000000000ULL
25 f43e3525 David Gibson
#define HPTE_R_RPN_SHIFT        12
26 f43e3525 David Gibson
#define HPTE_R_RPN              0x3ffffffffffff000ULL
27 f43e3525 David Gibson
#define HPTE_R_FLAGS            0x00000000000003ffULL
28 f43e3525 David Gibson
#define HPTE_R_PP               0x0000000000000003ULL
29 f43e3525 David Gibson
#define HPTE_R_N                0x0000000000000004ULL
30 f43e3525 David Gibson
#define HPTE_R_G                0x0000000000000008ULL
31 f43e3525 David Gibson
#define HPTE_R_M                0x0000000000000010ULL
32 f43e3525 David Gibson
#define HPTE_R_I                0x0000000000000020ULL
33 f43e3525 David Gibson
#define HPTE_R_W                0x0000000000000040ULL
34 f43e3525 David Gibson
#define HPTE_R_WIMG             0x0000000000000078ULL
35 f43e3525 David Gibson
#define HPTE_R_C                0x0000000000000080ULL
36 f43e3525 David Gibson
#define HPTE_R_R                0x0000000000000100ULL
37 f43e3525 David Gibson
#define HPTE_R_KEY_LO           0x0000000000000e00ULL
38 f43e3525 David Gibson
39 f43e3525 David Gibson
#define HPTE_V_1TB_SEG          0x4000000000000000ULL
40 f43e3525 David Gibson
#define HPTE_V_VRMA_MASK        0x4001ffffff000000ULL
41 f43e3525 David Gibson
42 f43e3525 David Gibson
static target_ulong compute_tlbie_rb(target_ulong v, target_ulong r,
43 f43e3525 David Gibson
                                     target_ulong pte_index)
44 f43e3525 David Gibson
{
45 f43e3525 David Gibson
    target_ulong rb, va_low;
46 f43e3525 David Gibson
47 f43e3525 David Gibson
    rb = (v & ~0x7fULL) << 16; /* AVA field */
48 f43e3525 David Gibson
    va_low = pte_index >> 3;
49 f43e3525 David Gibson
    if (v & HPTE_V_SECONDARY) {
50 f43e3525 David Gibson
        va_low = ~va_low;
51 f43e3525 David Gibson
    }
52 f43e3525 David Gibson
    /* xor vsid from AVA */
53 f43e3525 David Gibson
    if (!(v & HPTE_V_1TB_SEG)) {
54 f43e3525 David Gibson
        va_low ^= v >> 12;
55 f43e3525 David Gibson
    } else {
56 f43e3525 David Gibson
        va_low ^= v >> 24;
57 f43e3525 David Gibson
    }
58 f43e3525 David Gibson
    va_low &= 0x7ff;
59 f43e3525 David Gibson
    if (v & HPTE_V_LARGE) {
60 f43e3525 David Gibson
        rb |= 1;                         /* L field */
61 f43e3525 David Gibson
#if 0 /* Disable that P7 specific bit for now */
62 f43e3525 David Gibson
        if (r & 0xff000) {
63 f43e3525 David Gibson
            /* non-16MB large page, must be 64k */
64 f43e3525 David Gibson
            /* (masks depend on page size) */
65 f43e3525 David Gibson
            rb |= 0x1000;                /* page encoding in LP field */
66 f43e3525 David Gibson
            rb |= (va_low & 0x7f) << 16; /* 7b of VA in AVA/LP field */
67 f43e3525 David Gibson
            rb |= (va_low & 0xfe);       /* AVAL field */
68 f43e3525 David Gibson
        }
69 f43e3525 David Gibson
#endif
70 f43e3525 David Gibson
    } else {
71 f43e3525 David Gibson
        /* 4kB page */
72 f43e3525 David Gibson
        rb |= (va_low & 0x7ff) << 12;   /* remaining 11b of AVA */
73 f43e3525 David Gibson
    }
74 f43e3525 David Gibson
    rb |= (v >> 54) & 0x300;            /* B field */
75 f43e3525 David Gibson
    return rb;
76 f43e3525 David Gibson
}
77 f43e3525 David Gibson
78 e2684c0b Andreas Färber
static target_ulong h_enter(CPUPPCState *env, sPAPREnvironment *spapr,
79 f43e3525 David Gibson
                            target_ulong opcode, target_ulong *args)
80 f43e3525 David Gibson
{
81 f43e3525 David Gibson
    target_ulong flags = args[0];
82 f43e3525 David Gibson
    target_ulong pte_index = args[1];
83 f43e3525 David Gibson
    target_ulong pteh = args[2];
84 f43e3525 David Gibson
    target_ulong ptel = args[3];
85 f73a2575 David Gibson
    target_ulong page_shift = 12;
86 f73a2575 David Gibson
    target_ulong raddr;
87 1235a9cf David Gibson
    target_ulong i;
88 f43e3525 David Gibson
    uint8_t *hpte;
89 f43e3525 David Gibson
90 f43e3525 David Gibson
    /* only handle 4k and 16M pages for now */
91 f43e3525 David Gibson
    if (pteh & HPTE_V_LARGE) {
92 f43e3525 David Gibson
#if 0 /* We don't support 64k pages yet */
93 f43e3525 David Gibson
        if ((ptel & 0xf000) == 0x1000) {
94 f43e3525 David Gibson
            /* 64k page */
95 f43e3525 David Gibson
        } else
96 f43e3525 David Gibson
#endif
97 f43e3525 David Gibson
        if ((ptel & 0xff000) == 0) {
98 f43e3525 David Gibson
            /* 16M page */
99 f73a2575 David Gibson
            page_shift = 24;
100 f43e3525 David Gibson
            /* lowest AVA bit must be 0 for 16M pages */
101 f43e3525 David Gibson
            if (pteh & 0x80) {
102 f43e3525 David Gibson
                return H_PARAMETER;
103 f43e3525 David Gibson
            }
104 f43e3525 David Gibson
        } else {
105 f43e3525 David Gibson
            return H_PARAMETER;
106 f43e3525 David Gibson
        }
107 f43e3525 David Gibson
    }
108 f43e3525 David Gibson
109 f73a2575 David Gibson
    raddr = (ptel & HPTE_R_RPN) & ~((1ULL << page_shift) - 1);
110 f43e3525 David Gibson
111 f73a2575 David Gibson
    if (raddr < spapr->ram_limit) {
112 f73a2575 David Gibson
        /* Regular RAM - should have WIMG=0010 */
113 f73a2575 David Gibson
        if ((ptel & HPTE_R_WIMG) != HPTE_R_M) {
114 f73a2575 David Gibson
            return H_PARAMETER;
115 f73a2575 David Gibson
        }
116 f73a2575 David Gibson
    } else {
117 f73a2575 David Gibson
        /* Looks like an IO address */
118 f73a2575 David Gibson
        /* FIXME: What WIMG combinations could be sensible for IO?
119 f73a2575 David Gibson
         * For now we allow WIMG=010x, but are there others? */
120 f73a2575 David Gibson
        /* FIXME: Should we check against registered IO addresses? */
121 f73a2575 David Gibson
        if ((ptel & (HPTE_R_W | HPTE_R_I | HPTE_R_M)) != HPTE_R_I) {
122 f73a2575 David Gibson
            return H_PARAMETER;
123 f73a2575 David Gibson
        }
124 f43e3525 David Gibson
    }
125 f73a2575 David Gibson
126 f43e3525 David Gibson
    pteh &= ~0x60ULL;
127 f43e3525 David Gibson
128 f43e3525 David Gibson
    if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
129 f43e3525 David Gibson
        return H_PARAMETER;
130 f43e3525 David Gibson
    }
131 f43e3525 David Gibson
    if (likely((flags & H_EXACT) == 0)) {
132 f43e3525 David Gibson
        pte_index &= ~7ULL;
133 f43e3525 David Gibson
        hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64);
134 f43e3525 David Gibson
        for (i = 0; ; ++i) {
135 f43e3525 David Gibson
            if (i == 8) {
136 f43e3525 David Gibson
                return H_PTEG_FULL;
137 f43e3525 David Gibson
            }
138 35f9304d David Gibson
            if ((ldq_p(hpte) & HPTE_V_VALID) == 0) {
139 f43e3525 David Gibson
                break;
140 f43e3525 David Gibson
            }
141 f43e3525 David Gibson
            hpte += HASH_PTE_SIZE_64;
142 f43e3525 David Gibson
        }
143 f43e3525 David Gibson
    } else {
144 f43e3525 David Gibson
        i = 0;
145 f43e3525 David Gibson
        hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64);
146 35f9304d David Gibson
        if (ldq_p(hpte) & HPTE_V_VALID) {
147 f43e3525 David Gibson
            return H_PTEG_FULL;
148 f43e3525 David Gibson
        }
149 f43e3525 David Gibson
    }
150 f43e3525 David Gibson
    stq_p(hpte + (HASH_PTE_SIZE_64/2), ptel);
151 f43e3525 David Gibson
    /* eieio();  FIXME: need some sort of barrier for smp? */
152 f43e3525 David Gibson
    stq_p(hpte, pteh);
153 f43e3525 David Gibson
154 f43e3525 David Gibson
    args[0] = pte_index + i;
155 f43e3525 David Gibson
    return H_SUCCESS;
156 f43e3525 David Gibson
}
157 f43e3525 David Gibson
158 a3d0abae David Gibson
enum {
159 a3d0abae David Gibson
    REMOVE_SUCCESS = 0,
160 a3d0abae David Gibson
    REMOVE_NOT_FOUND = 1,
161 a3d0abae David Gibson
    REMOVE_PARM = 2,
162 a3d0abae David Gibson
    REMOVE_HW = 3,
163 a3d0abae David Gibson
};
164 a3d0abae David Gibson
165 e2684c0b Andreas Färber
static target_ulong remove_hpte(CPUPPCState *env, target_ulong ptex,
166 a3d0abae David Gibson
                                target_ulong avpn,
167 a3d0abae David Gibson
                                target_ulong flags,
168 a3d0abae David Gibson
                                target_ulong *vp, target_ulong *rp)
169 f43e3525 David Gibson
{
170 f43e3525 David Gibson
    uint8_t *hpte;
171 f43e3525 David Gibson
    target_ulong v, r, rb;
172 f43e3525 David Gibson
173 a3d0abae David Gibson
    if ((ptex * HASH_PTE_SIZE_64) & ~env->htab_mask) {
174 a3d0abae David Gibson
        return REMOVE_PARM;
175 f43e3525 David Gibson
    }
176 f43e3525 David Gibson
177 a3d0abae David Gibson
    hpte = env->external_htab + (ptex * HASH_PTE_SIZE_64);
178 f43e3525 David Gibson
179 f43e3525 David Gibson
    v = ldq_p(hpte);
180 f43e3525 David Gibson
    r = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
181 f43e3525 David Gibson
182 f43e3525 David Gibson
    if ((v & HPTE_V_VALID) == 0 ||
183 f43e3525 David Gibson
        ((flags & H_AVPN) && (v & ~0x7fULL) != avpn) ||
184 f43e3525 David Gibson
        ((flags & H_ANDCOND) && (v & avpn) != 0)) {
185 a3d0abae David Gibson
        return REMOVE_NOT_FOUND;
186 f43e3525 David Gibson
    }
187 35f9304d David Gibson
    *vp = v;
188 a3d0abae David Gibson
    *rp = r;
189 f43e3525 David Gibson
    stq_p(hpte, 0);
190 a3d0abae David Gibson
    rb = compute_tlbie_rb(v, r, ptex);
191 f43e3525 David Gibson
    ppc_tlb_invalidate_one(env, rb);
192 a3d0abae David Gibson
    return REMOVE_SUCCESS;
193 a3d0abae David Gibson
}
194 a3d0abae David Gibson
195 e2684c0b Andreas Färber
static target_ulong h_remove(CPUPPCState *env, sPAPREnvironment *spapr,
196 a3d0abae David Gibson
                             target_ulong opcode, target_ulong *args)
197 a3d0abae David Gibson
{
198 a3d0abae David Gibson
    target_ulong flags = args[0];
199 a3d0abae David Gibson
    target_ulong pte_index = args[1];
200 a3d0abae David Gibson
    target_ulong avpn = args[2];
201 a3d0abae David Gibson
    int ret;
202 a3d0abae David Gibson
203 a3d0abae David Gibson
    ret = remove_hpte(env, pte_index, avpn, flags,
204 a3d0abae David Gibson
                      &args[0], &args[1]);
205 a3d0abae David Gibson
206 a3d0abae David Gibson
    switch (ret) {
207 a3d0abae David Gibson
    case REMOVE_SUCCESS:
208 a3d0abae David Gibson
        return H_SUCCESS;
209 a3d0abae David Gibson
210 a3d0abae David Gibson
    case REMOVE_NOT_FOUND:
211 a3d0abae David Gibson
        return H_NOT_FOUND;
212 a3d0abae David Gibson
213 a3d0abae David Gibson
    case REMOVE_PARM:
214 a3d0abae David Gibson
        return H_PARAMETER;
215 a3d0abae David Gibson
216 a3d0abae David Gibson
    case REMOVE_HW:
217 a3d0abae David Gibson
        return H_HARDWARE;
218 a3d0abae David Gibson
    }
219 a3d0abae David Gibson
220 a3d0abae David Gibson
    assert(0);
221 a3d0abae David Gibson
}
222 a3d0abae David Gibson
223 a3d0abae David Gibson
#define H_BULK_REMOVE_TYPE             0xc000000000000000ULL
224 a3d0abae David Gibson
#define   H_BULK_REMOVE_REQUEST        0x4000000000000000ULL
225 a3d0abae David Gibson
#define   H_BULK_REMOVE_RESPONSE       0x8000000000000000ULL
226 a3d0abae David Gibson
#define   H_BULK_REMOVE_END            0xc000000000000000ULL
227 a3d0abae David Gibson
#define H_BULK_REMOVE_CODE             0x3000000000000000ULL
228 a3d0abae David Gibson
#define   H_BULK_REMOVE_SUCCESS        0x0000000000000000ULL
229 a3d0abae David Gibson
#define   H_BULK_REMOVE_NOT_FOUND      0x1000000000000000ULL
230 a3d0abae David Gibson
#define   H_BULK_REMOVE_PARM           0x2000000000000000ULL
231 a3d0abae David Gibson
#define   H_BULK_REMOVE_HW             0x3000000000000000ULL
232 a3d0abae David Gibson
#define H_BULK_REMOVE_RC               0x0c00000000000000ULL
233 a3d0abae David Gibson
#define H_BULK_REMOVE_FLAGS            0x0300000000000000ULL
234 a3d0abae David Gibson
#define   H_BULK_REMOVE_ABSOLUTE       0x0000000000000000ULL
235 a3d0abae David Gibson
#define   H_BULK_REMOVE_ANDCOND        0x0100000000000000ULL
236 a3d0abae David Gibson
#define   H_BULK_REMOVE_AVPN           0x0200000000000000ULL
237 a3d0abae David Gibson
#define H_BULK_REMOVE_PTEX             0x00ffffffffffffffULL
238 a3d0abae David Gibson
239 a3d0abae David Gibson
#define H_BULK_REMOVE_MAX_BATCH        4
240 a3d0abae David Gibson
241 e2684c0b Andreas Färber
static target_ulong h_bulk_remove(CPUPPCState *env, sPAPREnvironment *spapr,
242 a3d0abae David Gibson
                                  target_ulong opcode, target_ulong *args)
243 a3d0abae David Gibson
{
244 a3d0abae David Gibson
    int i;
245 a3d0abae David Gibson
246 a3d0abae David Gibson
    for (i = 0; i < H_BULK_REMOVE_MAX_BATCH; i++) {
247 a3d0abae David Gibson
        target_ulong *tsh = &args[i*2];
248 a3d0abae David Gibson
        target_ulong tsl = args[i*2 + 1];
249 a3d0abae David Gibson
        target_ulong v, r, ret;
250 a3d0abae David Gibson
251 a3d0abae David Gibson
        if ((*tsh & H_BULK_REMOVE_TYPE) == H_BULK_REMOVE_END) {
252 a3d0abae David Gibson
            break;
253 a3d0abae David Gibson
        } else if ((*tsh & H_BULK_REMOVE_TYPE) != H_BULK_REMOVE_REQUEST) {
254 a3d0abae David Gibson
            return H_PARAMETER;
255 a3d0abae David Gibson
        }
256 a3d0abae David Gibson
257 a3d0abae David Gibson
        *tsh &= H_BULK_REMOVE_PTEX | H_BULK_REMOVE_FLAGS;
258 a3d0abae David Gibson
        *tsh |= H_BULK_REMOVE_RESPONSE;
259 a3d0abae David Gibson
260 a3d0abae David Gibson
        if ((*tsh & H_BULK_REMOVE_ANDCOND) && (*tsh & H_BULK_REMOVE_AVPN)) {
261 a3d0abae David Gibson
            *tsh |= H_BULK_REMOVE_PARM;
262 a3d0abae David Gibson
            return H_PARAMETER;
263 a3d0abae David Gibson
        }
264 a3d0abae David Gibson
265 a3d0abae David Gibson
        ret = remove_hpte(env, *tsh & H_BULK_REMOVE_PTEX, tsl,
266 a3d0abae David Gibson
                          (*tsh & H_BULK_REMOVE_FLAGS) >> 26,
267 a3d0abae David Gibson
                          &v, &r);
268 a3d0abae David Gibson
269 a3d0abae David Gibson
        *tsh |= ret << 60;
270 a3d0abae David Gibson
271 a3d0abae David Gibson
        switch (ret) {
272 a3d0abae David Gibson
        case REMOVE_SUCCESS:
273 a3d0abae David Gibson
            *tsh |= (r & (HPTE_R_C | HPTE_R_R)) << 43;
274 a3d0abae David Gibson
            break;
275 a3d0abae David Gibson
276 a3d0abae David Gibson
        case REMOVE_PARM:
277 a3d0abae David Gibson
            return H_PARAMETER;
278 a3d0abae David Gibson
279 a3d0abae David Gibson
        case REMOVE_HW:
280 a3d0abae David Gibson
            return H_HARDWARE;
281 a3d0abae David Gibson
        }
282 a3d0abae David Gibson
    }
283 a3d0abae David Gibson
284 f43e3525 David Gibson
    return H_SUCCESS;
285 f43e3525 David Gibson
}
286 f43e3525 David Gibson
287 e2684c0b Andreas Färber
static target_ulong h_protect(CPUPPCState *env, sPAPREnvironment *spapr,
288 f43e3525 David Gibson
                              target_ulong opcode, target_ulong *args)
289 f43e3525 David Gibson
{
290 f43e3525 David Gibson
    target_ulong flags = args[0];
291 f43e3525 David Gibson
    target_ulong pte_index = args[1];
292 f43e3525 David Gibson
    target_ulong avpn = args[2];
293 f43e3525 David Gibson
    uint8_t *hpte;
294 f43e3525 David Gibson
    target_ulong v, r, rb;
295 f43e3525 David Gibson
296 f43e3525 David Gibson
    if ((pte_index * HASH_PTE_SIZE_64) & ~env->htab_mask) {
297 f43e3525 David Gibson
        return H_PARAMETER;
298 f43e3525 David Gibson
    }
299 f43e3525 David Gibson
300 f43e3525 David Gibson
    hpte = env->external_htab + (pte_index * HASH_PTE_SIZE_64);
301 f43e3525 David Gibson
302 f43e3525 David Gibson
    v = ldq_p(hpte);
303 f43e3525 David Gibson
    r = ldq_p(hpte + (HASH_PTE_SIZE_64/2));
304 f43e3525 David Gibson
305 f43e3525 David Gibson
    if ((v & HPTE_V_VALID) == 0 ||
306 f43e3525 David Gibson
        ((flags & H_AVPN) && (v & ~0x7fULL) != avpn)) {
307 f43e3525 David Gibson
        return H_NOT_FOUND;
308 f43e3525 David Gibson
    }
309 f43e3525 David Gibson
310 f43e3525 David Gibson
    r &= ~(HPTE_R_PP0 | HPTE_R_PP | HPTE_R_N |
311 f43e3525 David Gibson
           HPTE_R_KEY_HI | HPTE_R_KEY_LO);
312 f43e3525 David Gibson
    r |= (flags << 55) & HPTE_R_PP0;
313 f43e3525 David Gibson
    r |= (flags << 48) & HPTE_R_KEY_HI;
314 f43e3525 David Gibson
    r |= flags & (HPTE_R_PP | HPTE_R_N | HPTE_R_KEY_LO);
315 f43e3525 David Gibson
    rb = compute_tlbie_rb(v, r, pte_index);
316 f43e3525 David Gibson
    stq_p(hpte, v & ~HPTE_V_VALID);
317 f43e3525 David Gibson
    ppc_tlb_invalidate_one(env, rb);
318 f43e3525 David Gibson
    stq_p(hpte + (HASH_PTE_SIZE_64/2), r);
319 f43e3525 David Gibson
    /* Don't need a memory barrier, due to qemu's global lock */
320 35f9304d David Gibson
    stq_p(hpte, v);
321 f43e3525 David Gibson
    return H_SUCCESS;
322 f43e3525 David Gibson
}
323 f43e3525 David Gibson
324 e2684c0b Andreas Färber
static target_ulong h_set_dabr(CPUPPCState *env, sPAPREnvironment *spapr,
325 821303f5 David Gibson
                               target_ulong opcode, target_ulong *args)
326 821303f5 David Gibson
{
327 821303f5 David Gibson
    /* FIXME: actually implement this */
328 821303f5 David Gibson
    return H_HARDWARE;
329 821303f5 David Gibson
}
330 821303f5 David Gibson
331 ed120055 David Gibson
#define FLAGS_REGISTER_VPA         0x0000200000000000ULL
332 ed120055 David Gibson
#define FLAGS_REGISTER_DTL         0x0000400000000000ULL
333 ed120055 David Gibson
#define FLAGS_REGISTER_SLBSHADOW   0x0000600000000000ULL
334 ed120055 David Gibson
#define FLAGS_DEREGISTER_VPA       0x0000a00000000000ULL
335 ed120055 David Gibson
#define FLAGS_DEREGISTER_DTL       0x0000c00000000000ULL
336 ed120055 David Gibson
#define FLAGS_DEREGISTER_SLBSHADOW 0x0000e00000000000ULL
337 ed120055 David Gibson
338 ed120055 David Gibson
#define VPA_MIN_SIZE           640
339 ed120055 David Gibson
#define VPA_SIZE_OFFSET        0x4
340 ed120055 David Gibson
#define VPA_SHARED_PROC_OFFSET 0x9
341 ed120055 David Gibson
#define VPA_SHARED_PROC_VAL    0x2
342 ed120055 David Gibson
343 e2684c0b Andreas Färber
static target_ulong register_vpa(CPUPPCState *env, target_ulong vpa)
344 ed120055 David Gibson
{
345 ed120055 David Gibson
    uint16_t size;
346 ed120055 David Gibson
    uint8_t tmp;
347 ed120055 David Gibson
348 ed120055 David Gibson
    if (vpa == 0) {
349 ed120055 David Gibson
        hcall_dprintf("Can't cope with registering a VPA at logical 0\n");
350 ed120055 David Gibson
        return H_HARDWARE;
351 ed120055 David Gibson
    }
352 ed120055 David Gibson
353 ed120055 David Gibson
    if (vpa % env->dcache_line_size) {
354 ed120055 David Gibson
        return H_PARAMETER;
355 ed120055 David Gibson
    }
356 ed120055 David Gibson
    /* FIXME: bounds check the address */
357 ed120055 David Gibson
358 06c46bba Alexander Graf
    size = lduw_be_phys(vpa + 0x4);
359 ed120055 David Gibson
360 ed120055 David Gibson
    if (size < VPA_MIN_SIZE) {
361 ed120055 David Gibson
        return H_PARAMETER;
362 ed120055 David Gibson
    }
363 ed120055 David Gibson
364 ed120055 David Gibson
    /* VPA is not allowed to cross a page boundary */
365 ed120055 David Gibson
    if ((vpa / 4096) != ((vpa + size - 1) / 4096)) {
366 ed120055 David Gibson
        return H_PARAMETER;
367 ed120055 David Gibson
    }
368 ed120055 David Gibson
369 1bfb37d1 David Gibson
    env->vpa_addr = vpa;
370 ed120055 David Gibson
371 1bfb37d1 David Gibson
    tmp = ldub_phys(env->vpa_addr + VPA_SHARED_PROC_OFFSET);
372 ed120055 David Gibson
    tmp |= VPA_SHARED_PROC_VAL;
373 1bfb37d1 David Gibson
    stb_phys(env->vpa_addr + VPA_SHARED_PROC_OFFSET, tmp);
374 ed120055 David Gibson
375 ed120055 David Gibson
    return H_SUCCESS;
376 ed120055 David Gibson
}
377 ed120055 David Gibson
378 e2684c0b Andreas Färber
static target_ulong deregister_vpa(CPUPPCState *env, target_ulong vpa)
379 ed120055 David Gibson
{
380 1bfb37d1 David Gibson
    if (env->slb_shadow_addr) {
381 ed120055 David Gibson
        return H_RESOURCE;
382 ed120055 David Gibson
    }
383 ed120055 David Gibson
384 1bfb37d1 David Gibson
    if (env->dtl_addr) {
385 ed120055 David Gibson
        return H_RESOURCE;
386 ed120055 David Gibson
    }
387 ed120055 David Gibson
388 1bfb37d1 David Gibson
    env->vpa_addr = 0;
389 ed120055 David Gibson
    return H_SUCCESS;
390 ed120055 David Gibson
}
391 ed120055 David Gibson
392 e2684c0b Andreas Färber
static target_ulong register_slb_shadow(CPUPPCState *env, target_ulong addr)
393 ed120055 David Gibson
{
394 ed120055 David Gibson
    uint32_t size;
395 ed120055 David Gibson
396 ed120055 David Gibson
    if (addr == 0) {
397 ed120055 David Gibson
        hcall_dprintf("Can't cope with SLB shadow at logical 0\n");
398 ed120055 David Gibson
        return H_HARDWARE;
399 ed120055 David Gibson
    }
400 ed120055 David Gibson
401 06c46bba Alexander Graf
    size = ldl_be_phys(addr + 0x4);
402 ed120055 David Gibson
    if (size < 0x8) {
403 ed120055 David Gibson
        return H_PARAMETER;
404 ed120055 David Gibson
    }
405 ed120055 David Gibson
406 ed120055 David Gibson
    if ((addr / 4096) != ((addr + size - 1) / 4096)) {
407 ed120055 David Gibson
        return H_PARAMETER;
408 ed120055 David Gibson
    }
409 ed120055 David Gibson
410 1bfb37d1 David Gibson
    if (!env->vpa_addr) {
411 ed120055 David Gibson
        return H_RESOURCE;
412 ed120055 David Gibson
    }
413 ed120055 David Gibson
414 1bfb37d1 David Gibson
    env->slb_shadow_addr = addr;
415 1bfb37d1 David Gibson
    env->slb_shadow_size = size;
416 ed120055 David Gibson
417 ed120055 David Gibson
    return H_SUCCESS;
418 ed120055 David Gibson
}
419 ed120055 David Gibson
420 e2684c0b Andreas Färber
static target_ulong deregister_slb_shadow(CPUPPCState *env, target_ulong addr)
421 ed120055 David Gibson
{
422 1bfb37d1 David Gibson
    env->slb_shadow_addr = 0;
423 1bfb37d1 David Gibson
    env->slb_shadow_size = 0;
424 ed120055 David Gibson
    return H_SUCCESS;
425 ed120055 David Gibson
}
426 ed120055 David Gibson
427 e2684c0b Andreas Färber
static target_ulong register_dtl(CPUPPCState *env, target_ulong addr)
428 ed120055 David Gibson
{
429 ed120055 David Gibson
    uint32_t size;
430 ed120055 David Gibson
431 ed120055 David Gibson
    if (addr == 0) {
432 ed120055 David Gibson
        hcall_dprintf("Can't cope with DTL at logical 0\n");
433 ed120055 David Gibson
        return H_HARDWARE;
434 ed120055 David Gibson
    }
435 ed120055 David Gibson
436 06c46bba Alexander Graf
    size = ldl_be_phys(addr + 0x4);
437 ed120055 David Gibson
438 ed120055 David Gibson
    if (size < 48) {
439 ed120055 David Gibson
        return H_PARAMETER;
440 ed120055 David Gibson
    }
441 ed120055 David Gibson
442 1bfb37d1 David Gibson
    if (!env->vpa_addr) {
443 ed120055 David Gibson
        return H_RESOURCE;
444 ed120055 David Gibson
    }
445 ed120055 David Gibson
446 1bfb37d1 David Gibson
    env->dtl_addr = addr;
447 ed120055 David Gibson
    env->dtl_size = size;
448 ed120055 David Gibson
449 ed120055 David Gibson
    return H_SUCCESS;
450 ed120055 David Gibson
}
451 ed120055 David Gibson
452 73f7821b Peter Portante
static target_ulong deregister_dtl(CPUPPCState *env, target_ulong addr)
453 ed120055 David Gibson
{
454 1bfb37d1 David Gibson
    env->dtl_addr = 0;
455 ed120055 David Gibson
    env->dtl_size = 0;
456 ed120055 David Gibson
457 ed120055 David Gibson
    return H_SUCCESS;
458 ed120055 David Gibson
}
459 ed120055 David Gibson
460 e2684c0b Andreas Färber
static target_ulong h_register_vpa(CPUPPCState *env, sPAPREnvironment *spapr,
461 ed120055 David Gibson
                                   target_ulong opcode, target_ulong *args)
462 ed120055 David Gibson
{
463 ed120055 David Gibson
    target_ulong flags = args[0];
464 ed120055 David Gibson
    target_ulong procno = args[1];
465 ed120055 David Gibson
    target_ulong vpa = args[2];
466 ed120055 David Gibson
    target_ulong ret = H_PARAMETER;
467 e2684c0b Andreas Färber
    CPUPPCState *tenv;
468 ed120055 David Gibson
469 ed120055 David Gibson
    for (tenv = first_cpu; tenv; tenv = tenv->next_cpu) {
470 ed120055 David Gibson
        if (tenv->cpu_index == procno) {
471 ed120055 David Gibson
            break;
472 ed120055 David Gibson
        }
473 ed120055 David Gibson
    }
474 ed120055 David Gibson
475 ed120055 David Gibson
    if (!tenv) {
476 ed120055 David Gibson
        return H_PARAMETER;
477 ed120055 David Gibson
    }
478 ed120055 David Gibson
479 ed120055 David Gibson
    switch (flags) {
480 ed120055 David Gibson
    case FLAGS_REGISTER_VPA:
481 ed120055 David Gibson
        ret = register_vpa(tenv, vpa);
482 ed120055 David Gibson
        break;
483 ed120055 David Gibson
484 ed120055 David Gibson
    case FLAGS_DEREGISTER_VPA:
485 ed120055 David Gibson
        ret = deregister_vpa(tenv, vpa);
486 ed120055 David Gibson
        break;
487 ed120055 David Gibson
488 ed120055 David Gibson
    case FLAGS_REGISTER_SLBSHADOW:
489 ed120055 David Gibson
        ret = register_slb_shadow(tenv, vpa);
490 ed120055 David Gibson
        break;
491 ed120055 David Gibson
492 ed120055 David Gibson
    case FLAGS_DEREGISTER_SLBSHADOW:
493 ed120055 David Gibson
        ret = deregister_slb_shadow(tenv, vpa);
494 ed120055 David Gibson
        break;
495 ed120055 David Gibson
496 ed120055 David Gibson
    case FLAGS_REGISTER_DTL:
497 ed120055 David Gibson
        ret = register_dtl(tenv, vpa);
498 ed120055 David Gibson
        break;
499 ed120055 David Gibson
500 ed120055 David Gibson
    case FLAGS_DEREGISTER_DTL:
501 ed120055 David Gibson
        ret = deregister_dtl(tenv, vpa);
502 ed120055 David Gibson
        break;
503 ed120055 David Gibson
    }
504 ed120055 David Gibson
505 ed120055 David Gibson
    return ret;
506 ed120055 David Gibson
}
507 ed120055 David Gibson
508 e2684c0b Andreas Färber
static target_ulong h_cede(CPUPPCState *env, sPAPREnvironment *spapr,
509 ed120055 David Gibson
                           target_ulong opcode, target_ulong *args)
510 ed120055 David Gibson
{
511 ed120055 David Gibson
    env->msr |= (1ULL << MSR_EE);
512 ed120055 David Gibson
    hreg_compute_hflags(env);
513 ed120055 David Gibson
    if (!cpu_has_work(env)) {
514 ed120055 David Gibson
        env->halted = 1;
515 1dd08894 David Gibson
        env->exception_index = EXCP_HLT;
516 1dd08894 David Gibson
        env->exit_request = 1;
517 ed120055 David Gibson
    }
518 ed120055 David Gibson
    return H_SUCCESS;
519 ed120055 David Gibson
}
520 ed120055 David Gibson
521 e2684c0b Andreas Färber
static target_ulong h_rtas(CPUPPCState *env, sPAPREnvironment *spapr,
522 39ac8455 David Gibson
                           target_ulong opcode, target_ulong *args)
523 39ac8455 David Gibson
{
524 39ac8455 David Gibson
    target_ulong rtas_r3 = args[0];
525 06c46bba Alexander Graf
    uint32_t token = ldl_be_phys(rtas_r3);
526 06c46bba Alexander Graf
    uint32_t nargs = ldl_be_phys(rtas_r3 + 4);
527 06c46bba Alexander Graf
    uint32_t nret = ldl_be_phys(rtas_r3 + 8);
528 39ac8455 David Gibson
529 39ac8455 David Gibson
    return spapr_rtas_call(spapr, token, nargs, rtas_r3 + 12,
530 39ac8455 David Gibson
                           nret, rtas_r3 + 12 + 4*nargs);
531 39ac8455 David Gibson
}
532 39ac8455 David Gibson
533 e2684c0b Andreas Färber
static target_ulong h_logical_load(CPUPPCState *env, sPAPREnvironment *spapr,
534 827200a2 David Gibson
                                   target_ulong opcode, target_ulong *args)
535 827200a2 David Gibson
{
536 827200a2 David Gibson
    target_ulong size = args[0];
537 827200a2 David Gibson
    target_ulong addr = args[1];
538 827200a2 David Gibson
539 827200a2 David Gibson
    switch (size) {
540 827200a2 David Gibson
    case 1:
541 827200a2 David Gibson
        args[0] = ldub_phys(addr);
542 827200a2 David Gibson
        return H_SUCCESS;
543 827200a2 David Gibson
    case 2:
544 827200a2 David Gibson
        args[0] = lduw_phys(addr);
545 827200a2 David Gibson
        return H_SUCCESS;
546 827200a2 David Gibson
    case 4:
547 827200a2 David Gibson
        args[0] = ldl_phys(addr);
548 827200a2 David Gibson
        return H_SUCCESS;
549 827200a2 David Gibson
    case 8:
550 827200a2 David Gibson
        args[0] = ldq_phys(addr);
551 827200a2 David Gibson
        return H_SUCCESS;
552 827200a2 David Gibson
    }
553 827200a2 David Gibson
    return H_PARAMETER;
554 827200a2 David Gibson
}
555 827200a2 David Gibson
556 e2684c0b Andreas Färber
static target_ulong h_logical_store(CPUPPCState *env, sPAPREnvironment *spapr,
557 827200a2 David Gibson
                                    target_ulong opcode, target_ulong *args)
558 827200a2 David Gibson
{
559 827200a2 David Gibson
    target_ulong size = args[0];
560 827200a2 David Gibson
    target_ulong addr = args[1];
561 827200a2 David Gibson
    target_ulong val  = args[2];
562 827200a2 David Gibson
563 827200a2 David Gibson
    switch (size) {
564 827200a2 David Gibson
    case 1:
565 827200a2 David Gibson
        stb_phys(addr, val);
566 827200a2 David Gibson
        return H_SUCCESS;
567 827200a2 David Gibson
    case 2:
568 827200a2 David Gibson
        stw_phys(addr, val);
569 827200a2 David Gibson
        return H_SUCCESS;
570 827200a2 David Gibson
    case 4:
571 827200a2 David Gibson
        stl_phys(addr, val);
572 827200a2 David Gibson
        return H_SUCCESS;
573 827200a2 David Gibson
    case 8:
574 827200a2 David Gibson
        stq_phys(addr, val);
575 827200a2 David Gibson
        return H_SUCCESS;
576 827200a2 David Gibson
    }
577 827200a2 David Gibson
    return H_PARAMETER;
578 827200a2 David Gibson
}
579 827200a2 David Gibson
580 c73e3771 Benjamin Herrenschmidt
static target_ulong h_logical_memop(CPUPPCState *env, sPAPREnvironment *spapr,
581 c73e3771 Benjamin Herrenschmidt
                                    target_ulong opcode, target_ulong *args)
582 c73e3771 Benjamin Herrenschmidt
{
583 c73e3771 Benjamin Herrenschmidt
    target_ulong dst   = args[0]; /* Destination address */
584 c73e3771 Benjamin Herrenschmidt
    target_ulong src   = args[1]; /* Source address */
585 c73e3771 Benjamin Herrenschmidt
    target_ulong esize = args[2]; /* Element size (0=1,1=2,2=4,3=8) */
586 c73e3771 Benjamin Herrenschmidt
    target_ulong count = args[3]; /* Element count */
587 c73e3771 Benjamin Herrenschmidt
    target_ulong op    = args[4]; /* 0 = copy, 1 = invert */
588 c73e3771 Benjamin Herrenschmidt
    uint64_t tmp;
589 c73e3771 Benjamin Herrenschmidt
    unsigned int mask = (1 << esize) - 1;
590 c73e3771 Benjamin Herrenschmidt
    int step = 1 << esize;
591 c73e3771 Benjamin Herrenschmidt
592 c73e3771 Benjamin Herrenschmidt
    if (count > 0x80000000) {
593 c73e3771 Benjamin Herrenschmidt
        return H_PARAMETER;
594 c73e3771 Benjamin Herrenschmidt
    }
595 c73e3771 Benjamin Herrenschmidt
596 c73e3771 Benjamin Herrenschmidt
    if ((dst & mask) || (src & mask) || (op > 1)) {
597 c73e3771 Benjamin Herrenschmidt
        return H_PARAMETER;
598 c73e3771 Benjamin Herrenschmidt
    }
599 c73e3771 Benjamin Herrenschmidt
600 c73e3771 Benjamin Herrenschmidt
    if (dst >= src && dst < (src + (count << esize))) {
601 c73e3771 Benjamin Herrenschmidt
            dst = dst + ((count - 1) << esize);
602 c73e3771 Benjamin Herrenschmidt
            src = src + ((count - 1) << esize);
603 c73e3771 Benjamin Herrenschmidt
            step = -step;
604 c73e3771 Benjamin Herrenschmidt
    }
605 c73e3771 Benjamin Herrenschmidt
606 c73e3771 Benjamin Herrenschmidt
    while (count--) {
607 c73e3771 Benjamin Herrenschmidt
        switch (esize) {
608 c73e3771 Benjamin Herrenschmidt
        case 0:
609 c73e3771 Benjamin Herrenschmidt
            tmp = ldub_phys(src);
610 c73e3771 Benjamin Herrenschmidt
            break;
611 c73e3771 Benjamin Herrenschmidt
        case 1:
612 c73e3771 Benjamin Herrenschmidt
            tmp = lduw_phys(src);
613 c73e3771 Benjamin Herrenschmidt
            break;
614 c73e3771 Benjamin Herrenschmidt
        case 2:
615 c73e3771 Benjamin Herrenschmidt
            tmp = ldl_phys(src);
616 c73e3771 Benjamin Herrenschmidt
            break;
617 c73e3771 Benjamin Herrenschmidt
        case 3:
618 c73e3771 Benjamin Herrenschmidt
            tmp = ldq_phys(src);
619 c73e3771 Benjamin Herrenschmidt
            break;
620 c73e3771 Benjamin Herrenschmidt
        default:
621 c73e3771 Benjamin Herrenschmidt
            return H_PARAMETER;
622 c73e3771 Benjamin Herrenschmidt
        }
623 c73e3771 Benjamin Herrenschmidt
        if (op == 1) {
624 c73e3771 Benjamin Herrenschmidt
            tmp = ~tmp;
625 c73e3771 Benjamin Herrenschmidt
        }
626 c73e3771 Benjamin Herrenschmidt
        switch (esize) {
627 c73e3771 Benjamin Herrenschmidt
        case 0:
628 c73e3771 Benjamin Herrenschmidt
            stb_phys(dst, tmp);
629 c73e3771 Benjamin Herrenschmidt
            break;
630 c73e3771 Benjamin Herrenschmidt
        case 1:
631 c73e3771 Benjamin Herrenschmidt
            stw_phys(dst, tmp);
632 c73e3771 Benjamin Herrenschmidt
            break;
633 c73e3771 Benjamin Herrenschmidt
        case 2:
634 c73e3771 Benjamin Herrenschmidt
            stl_phys(dst, tmp);
635 c73e3771 Benjamin Herrenschmidt
            break;
636 c73e3771 Benjamin Herrenschmidt
        case 3:
637 c73e3771 Benjamin Herrenschmidt
            stq_phys(dst, tmp);
638 c73e3771 Benjamin Herrenschmidt
            break;
639 c73e3771 Benjamin Herrenschmidt
        }
640 c73e3771 Benjamin Herrenschmidt
        dst = dst + step;
641 c73e3771 Benjamin Herrenschmidt
        src = src + step;
642 c73e3771 Benjamin Herrenschmidt
    }
643 c73e3771 Benjamin Herrenschmidt
644 c73e3771 Benjamin Herrenschmidt
    return H_SUCCESS;
645 c73e3771 Benjamin Herrenschmidt
}
646 c73e3771 Benjamin Herrenschmidt
647 e2684c0b Andreas Färber
static target_ulong h_logical_icbi(CPUPPCState *env, sPAPREnvironment *spapr,
648 827200a2 David Gibson
                                   target_ulong opcode, target_ulong *args)
649 827200a2 David Gibson
{
650 827200a2 David Gibson
    /* Nothing to do on emulation, KVM will trap this in the kernel */
651 827200a2 David Gibson
    return H_SUCCESS;
652 827200a2 David Gibson
}
653 827200a2 David Gibson
654 e2684c0b Andreas Färber
static target_ulong h_logical_dcbf(CPUPPCState *env, sPAPREnvironment *spapr,
655 827200a2 David Gibson
                                   target_ulong opcode, target_ulong *args)
656 827200a2 David Gibson
{
657 827200a2 David Gibson
    /* Nothing to do on emulation, KVM will trap this in the kernel */
658 827200a2 David Gibson
    return H_SUCCESS;
659 827200a2 David Gibson
}
660 827200a2 David Gibson
661 7d7ba3fe David Gibson
static spapr_hcall_fn papr_hypercall_table[(MAX_HCALL_OPCODE / 4) + 1];
662 7d7ba3fe David Gibson
static spapr_hcall_fn kvmppc_hypercall_table[KVMPPC_HCALL_MAX - KVMPPC_HCALL_BASE + 1];
663 9fdf0c29 David Gibson
664 9fdf0c29 David Gibson
void spapr_register_hypercall(target_ulong opcode, spapr_hcall_fn fn)
665 9fdf0c29 David Gibson
{
666 39ac8455 David Gibson
    spapr_hcall_fn *slot;
667 39ac8455 David Gibson
668 39ac8455 David Gibson
    if (opcode <= MAX_HCALL_OPCODE) {
669 39ac8455 David Gibson
        assert((opcode & 0x3) == 0);
670 9fdf0c29 David Gibson
671 39ac8455 David Gibson
        slot = &papr_hypercall_table[opcode / 4];
672 39ac8455 David Gibson
    } else {
673 39ac8455 David Gibson
        assert((opcode >= KVMPPC_HCALL_BASE) && (opcode <= KVMPPC_HCALL_MAX));
674 9fdf0c29 David Gibson
675 39ac8455 David Gibson
        slot = &kvmppc_hypercall_table[opcode - KVMPPC_HCALL_BASE];
676 39ac8455 David Gibson
    }
677 9fdf0c29 David Gibson
678 c89d5299 David Gibson
    assert(!(*slot));
679 39ac8455 David Gibson
    *slot = fn;
680 9fdf0c29 David Gibson
}
681 9fdf0c29 David Gibson
682 e2684c0b Andreas Färber
target_ulong spapr_hypercall(CPUPPCState *env, target_ulong opcode,
683 9fdf0c29 David Gibson
                             target_ulong *args)
684 9fdf0c29 David Gibson
{
685 9fdf0c29 David Gibson
    if ((opcode <= MAX_HCALL_OPCODE)
686 9fdf0c29 David Gibson
        && ((opcode & 0x3) == 0)) {
687 39ac8455 David Gibson
        spapr_hcall_fn fn = papr_hypercall_table[opcode / 4];
688 39ac8455 David Gibson
689 39ac8455 David Gibson
        if (fn) {
690 39ac8455 David Gibson
            return fn(env, spapr, opcode, args);
691 39ac8455 David Gibson
        }
692 39ac8455 David Gibson
    } else if ((opcode >= KVMPPC_HCALL_BASE) &&
693 39ac8455 David Gibson
               (opcode <= KVMPPC_HCALL_MAX)) {
694 39ac8455 David Gibson
        spapr_hcall_fn fn = kvmppc_hypercall_table[opcode - KVMPPC_HCALL_BASE];
695 9fdf0c29 David Gibson
696 9fdf0c29 David Gibson
        if (fn) {
697 9fdf0c29 David Gibson
            return fn(env, spapr, opcode, args);
698 9fdf0c29 David Gibson
        }
699 9fdf0c29 David Gibson
    }
700 9fdf0c29 David Gibson
701 9fdf0c29 David Gibson
    hcall_dprintf("Unimplemented hcall 0x" TARGET_FMT_lx "\n", opcode);
702 9fdf0c29 David Gibson
    return H_FUNCTION;
703 9fdf0c29 David Gibson
}
704 f43e3525 David Gibson
705 83f7d43a Andreas Färber
static void hypercall_register_types(void)
706 f43e3525 David Gibson
{
707 f43e3525 David Gibson
    /* hcall-pft */
708 f43e3525 David Gibson
    spapr_register_hypercall(H_ENTER, h_enter);
709 f43e3525 David Gibson
    spapr_register_hypercall(H_REMOVE, h_remove);
710 f43e3525 David Gibson
    spapr_register_hypercall(H_PROTECT, h_protect);
711 39ac8455 David Gibson
712 a3d0abae David Gibson
    /* hcall-bulk */
713 a3d0abae David Gibson
    spapr_register_hypercall(H_BULK_REMOVE, h_bulk_remove);
714 a3d0abae David Gibson
715 821303f5 David Gibson
    /* hcall-dabr */
716 821303f5 David Gibson
    spapr_register_hypercall(H_SET_DABR, h_set_dabr);
717 821303f5 David Gibson
718 ed120055 David Gibson
    /* hcall-splpar */
719 ed120055 David Gibson
    spapr_register_hypercall(H_REGISTER_VPA, h_register_vpa);
720 ed120055 David Gibson
    spapr_register_hypercall(H_CEDE, h_cede);
721 ed120055 David Gibson
722 827200a2 David Gibson
    /* "debugger" hcalls (also used by SLOF). Note: We do -not- differenciate
723 827200a2 David Gibson
     * here between the "CI" and the "CACHE" variants, they will use whatever
724 827200a2 David Gibson
     * mapping attributes qemu is using. When using KVM, the kernel will
725 827200a2 David Gibson
     * enforce the attributes more strongly
726 827200a2 David Gibson
     */
727 827200a2 David Gibson
    spapr_register_hypercall(H_LOGICAL_CI_LOAD, h_logical_load);
728 827200a2 David Gibson
    spapr_register_hypercall(H_LOGICAL_CI_STORE, h_logical_store);
729 827200a2 David Gibson
    spapr_register_hypercall(H_LOGICAL_CACHE_LOAD, h_logical_load);
730 827200a2 David Gibson
    spapr_register_hypercall(H_LOGICAL_CACHE_STORE, h_logical_store);
731 827200a2 David Gibson
    spapr_register_hypercall(H_LOGICAL_ICBI, h_logical_icbi);
732 827200a2 David Gibson
    spapr_register_hypercall(H_LOGICAL_DCBF, h_logical_dcbf);
733 c73e3771 Benjamin Herrenschmidt
    spapr_register_hypercall(KVMPPC_H_LOGICAL_MEMOP, h_logical_memop);
734 827200a2 David Gibson
735 39ac8455 David Gibson
    /* qemu/KVM-PPC specific hcalls */
736 39ac8455 David Gibson
    spapr_register_hypercall(KVMPPC_H_RTAS, h_rtas);
737 f43e3525 David Gibson
}
738 83f7d43a Andreas Färber
739 83f7d43a Andreas Färber
type_init(hypercall_register_types)