Statistics
| Branch: | Revision:

root / hw / ppc / spapr_hcall.c @ 210b580b

History | View | Annotate | Download (20.1 kB)

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