xref: /openbmc/qemu/include/hw/ppc/spapr_nested.h (revision f7ceab1e)
1 #ifndef HW_SPAPR_NESTED_H
2 #define HW_SPAPR_NESTED_H
3 
4 #include "target/ppc/cpu.h"
5 
6 /* Guest State Buffer Element IDs */
7 #define GSB_HV_VCPU_IGNORED_ID  0x0000 /* An element whose value is ignored */
8 #define GSB_HV_VCPU_STATE_SIZE  0x0001 /* HV internal format VCPU state size */
9 #define GSB_VCPU_OUT_BUF_MIN_SZ 0x0002 /* Min size of the Run VCPU o/p buffer */
10 #define GSB_VCPU_LPVR           0x0003 /* Logical PVR */
11 #define GSB_TB_OFFSET           0x0004 /* Timebase Offset */
12 #define GSB_PART_SCOPED_PAGETBL 0x0005 /* Partition Scoped Page Table */
13 #define GSB_PROCESS_TBL         0x0006 /* Process Table */
14                     /* RESERVED 0x0007 - 0x0BFF */
15 #define GSB_VCPU_IN_BUFFER      0x0C00 /* Run VCPU Input Buffer */
16 #define GSB_VCPU_OUT_BUFFER     0x0C01 /* Run VCPU Out Buffer */
17 #define GSB_VCPU_VPA            0x0C02 /* HRA to Guest VCPU VPA */
18                     /* RESERVED 0x0C03 - 0x0FFF */
19 #define GSB_VCPU_GPR0           0x1000
20 #define GSB_VCPU_GPR1           0x1001
21 #define GSB_VCPU_GPR2           0x1002
22 #define GSB_VCPU_GPR3           0x1003
23 #define GSB_VCPU_GPR4           0x1004
24 #define GSB_VCPU_GPR5           0x1005
25 #define GSB_VCPU_GPR6           0x1006
26 #define GSB_VCPU_GPR7           0x1007
27 #define GSB_VCPU_GPR8           0x1008
28 #define GSB_VCPU_GPR9           0x1009
29 #define GSB_VCPU_GPR10          0x100A
30 #define GSB_VCPU_GPR11          0x100B
31 #define GSB_VCPU_GPR12          0x100C
32 #define GSB_VCPU_GPR13          0x100D
33 #define GSB_VCPU_GPR14          0x100E
34 #define GSB_VCPU_GPR15          0x100F
35 #define GSB_VCPU_GPR16          0x1010
36 #define GSB_VCPU_GPR17          0x1011
37 #define GSB_VCPU_GPR18          0x1012
38 #define GSB_VCPU_GPR19          0x1013
39 #define GSB_VCPU_GPR20          0x1014
40 #define GSB_VCPU_GPR21          0x1015
41 #define GSB_VCPU_GPR22          0x1016
42 #define GSB_VCPU_GPR23          0x1017
43 #define GSB_VCPU_GPR24          0x1018
44 #define GSB_VCPU_GPR25          0x1019
45 #define GSB_VCPU_GPR26          0x101A
46 #define GSB_VCPU_GPR27          0x101B
47 #define GSB_VCPU_GPR28          0x101C
48 #define GSB_VCPU_GPR29          0x101D
49 #define GSB_VCPU_GPR30          0x101E
50 #define GSB_VCPU_GPR31          0x101F
51 #define GSB_VCPU_HDEC_EXPIRY_TB 0x1020
52 #define GSB_VCPU_SPR_NIA        0x1021
53 #define GSB_VCPU_SPR_MSR        0x1022
54 #define GSB_VCPU_SPR_LR         0x1023
55 #define GSB_VCPU_SPR_XER        0x1024
56 #define GSB_VCPU_SPR_CTR        0x1025
57 #define GSB_VCPU_SPR_CFAR       0x1026
58 #define GSB_VCPU_SPR_SRR0       0x1027
59 #define GSB_VCPU_SPR_SRR1       0x1028
60 #define GSB_VCPU_SPR_DAR        0x1029
61 #define GSB_VCPU_DEC_EXPIRE_TB  0x102A
62 #define GSB_VCPU_SPR_VTB        0x102B
63 #define GSB_VCPU_SPR_LPCR       0x102C
64 #define GSB_VCPU_SPR_HFSCR      0x102D
65 #define GSB_VCPU_SPR_FSCR       0x102E
66 #define GSB_VCPU_SPR_FPSCR      0x102F
67 #define GSB_VCPU_SPR_DAWR0      0x1030
68 #define GSB_VCPU_SPR_DAWR1      0x1031
69 #define GSB_VCPU_SPR_CIABR      0x1032
70 #define GSB_VCPU_SPR_PURR       0x1033
71 #define GSB_VCPU_SPR_SPURR      0x1034
72 #define GSB_VCPU_SPR_IC         0x1035
73 #define GSB_VCPU_SPR_SPRG0      0x1036
74 #define GSB_VCPU_SPR_SPRG1      0x1037
75 #define GSB_VCPU_SPR_SPRG2      0x1038
76 #define GSB_VCPU_SPR_SPRG3      0x1039
77 #define GSB_VCPU_SPR_PPR        0x103A
78 #define GSB_VCPU_SPR_MMCR0      0x103B
79 #define GSB_VCPU_SPR_MMCR1      0x103C
80 #define GSB_VCPU_SPR_MMCR2      0x103D
81 #define GSB_VCPU_SPR_MMCR3      0x103E
82 #define GSB_VCPU_SPR_MMCRA      0x103F
83 #define GSB_VCPU_SPR_SIER       0x1040
84 #define GSB_VCPU_SPR_SIER2      0x1041
85 #define GSB_VCPU_SPR_SIER3      0x1042
86 #define GSB_VCPU_SPR_BESCR      0x1043
87 #define GSB_VCPU_SPR_EBBHR      0x1044
88 #define GSB_VCPU_SPR_EBBRR      0x1045
89 #define GSB_VCPU_SPR_AMR        0x1046
90 #define GSB_VCPU_SPR_IAMR       0x1047
91 #define GSB_VCPU_SPR_AMOR       0x1048
92 #define GSB_VCPU_SPR_UAMOR      0x1049
93 #define GSB_VCPU_SPR_SDAR       0x104A
94 #define GSB_VCPU_SPR_SIAR       0x104B
95 #define GSB_VCPU_SPR_DSCR       0x104C
96 #define GSB_VCPU_SPR_TAR        0x104D
97 #define GSB_VCPU_SPR_DEXCR      0x104E
98 #define GSB_VCPU_SPR_HDEXCR     0x104F
99 #define GSB_VCPU_SPR_HASHKEYR   0x1050
100 #define GSB_VCPU_SPR_HASHPKEYR  0x1051
101 #define GSB_VCPU_SPR_CTRL       0x1052
102 #define GSB_VCPU_SPR_DPDES      0x1053
103                     /* RESERVED 0x1054 - 0x1FFF */
104 #define GSB_VCPU_SPR_CR         0x2000
105 #define GSB_VCPU_SPR_PIDR       0x2001
106 #define GSB_VCPU_SPR_DSISR      0x2002
107 #define GSB_VCPU_SPR_VSCR       0x2003
108 #define GSB_VCPU_SPR_VRSAVE     0x2004
109 #define GSB_VCPU_SPR_DAWRX0     0x2005
110 #define GSB_VCPU_SPR_DAWRX1     0x2006
111 #define GSB_VCPU_SPR_PMC1       0x2007
112 #define GSB_VCPU_SPR_PMC2       0x2008
113 #define GSB_VCPU_SPR_PMC3       0x2009
114 #define GSB_VCPU_SPR_PMC4       0x200A
115 #define GSB_VCPU_SPR_PMC5       0x200B
116 #define GSB_VCPU_SPR_PMC6       0x200C
117 #define GSB_VCPU_SPR_WORT       0x200D
118 #define GSB_VCPU_SPR_PSPB       0x200E
119                     /* RESERVED 0x200F - 0x2FFF */
120 #define GSB_VCPU_SPR_VSR0       0x3000
121 #define GSB_VCPU_SPR_VSR1       0x3001
122 #define GSB_VCPU_SPR_VSR2       0x3002
123 #define GSB_VCPU_SPR_VSR3       0x3003
124 #define GSB_VCPU_SPR_VSR4       0x3004
125 #define GSB_VCPU_SPR_VSR5       0x3005
126 #define GSB_VCPU_SPR_VSR6       0x3006
127 #define GSB_VCPU_SPR_VSR7       0x3007
128 #define GSB_VCPU_SPR_VSR8       0x3008
129 #define GSB_VCPU_SPR_VSR9       0x3009
130 #define GSB_VCPU_SPR_VSR10      0x300A
131 #define GSB_VCPU_SPR_VSR11      0x300B
132 #define GSB_VCPU_SPR_VSR12      0x300C
133 #define GSB_VCPU_SPR_VSR13      0x300D
134 #define GSB_VCPU_SPR_VSR14      0x300E
135 #define GSB_VCPU_SPR_VSR15      0x300F
136 #define GSB_VCPU_SPR_VSR16      0x3010
137 #define GSB_VCPU_SPR_VSR17      0x3011
138 #define GSB_VCPU_SPR_VSR18      0x3012
139 #define GSB_VCPU_SPR_VSR19      0x3013
140 #define GSB_VCPU_SPR_VSR20      0x3014
141 #define GSB_VCPU_SPR_VSR21      0x3015
142 #define GSB_VCPU_SPR_VSR22      0x3016
143 #define GSB_VCPU_SPR_VSR23      0x3017
144 #define GSB_VCPU_SPR_VSR24      0x3018
145 #define GSB_VCPU_SPR_VSR25      0x3019
146 #define GSB_VCPU_SPR_VSR26      0x301A
147 #define GSB_VCPU_SPR_VSR27      0x301B
148 #define GSB_VCPU_SPR_VSR28      0x301C
149 #define GSB_VCPU_SPR_VSR29      0x301D
150 #define GSB_VCPU_SPR_VSR30      0x301E
151 #define GSB_VCPU_SPR_VSR31      0x301F
152 #define GSB_VCPU_SPR_VSR32      0x3020
153 #define GSB_VCPU_SPR_VSR33      0x3021
154 #define GSB_VCPU_SPR_VSR34      0x3022
155 #define GSB_VCPU_SPR_VSR35      0x3023
156 #define GSB_VCPU_SPR_VSR36      0x3024
157 #define GSB_VCPU_SPR_VSR37      0x3025
158 #define GSB_VCPU_SPR_VSR38      0x3026
159 #define GSB_VCPU_SPR_VSR39      0x3027
160 #define GSB_VCPU_SPR_VSR40      0x3028
161 #define GSB_VCPU_SPR_VSR41      0x3029
162 #define GSB_VCPU_SPR_VSR42      0x302A
163 #define GSB_VCPU_SPR_VSR43      0x302B
164 #define GSB_VCPU_SPR_VSR44      0x302C
165 #define GSB_VCPU_SPR_VSR45      0x302D
166 #define GSB_VCPU_SPR_VSR46      0x302E
167 #define GSB_VCPU_SPR_VSR47      0x302F
168 #define GSB_VCPU_SPR_VSR48      0x3030
169 #define GSB_VCPU_SPR_VSR49      0x3031
170 #define GSB_VCPU_SPR_VSR50      0x3032
171 #define GSB_VCPU_SPR_VSR51      0x3033
172 #define GSB_VCPU_SPR_VSR52      0x3034
173 #define GSB_VCPU_SPR_VSR53      0x3035
174 #define GSB_VCPU_SPR_VSR54      0x3036
175 #define GSB_VCPU_SPR_VSR55      0x3037
176 #define GSB_VCPU_SPR_VSR56      0x3038
177 #define GSB_VCPU_SPR_VSR57      0x3039
178 #define GSB_VCPU_SPR_VSR58      0x303A
179 #define GSB_VCPU_SPR_VSR59      0x303B
180 #define GSB_VCPU_SPR_VSR60      0x303C
181 #define GSB_VCPU_SPR_VSR61      0x303D
182 #define GSB_VCPU_SPR_VSR62      0x303E
183 #define GSB_VCPU_SPR_VSR63      0x303F
184                     /* RESERVED 0x3040 - 0xEFFF */
185 #define GSB_VCPU_SPR_HDAR       0xF000
186 #define GSB_VCPU_SPR_HDSISR     0xF001
187 #define GSB_VCPU_SPR_HEIR       0xF002
188 #define GSB_VCPU_SPR_ASDR       0xF003
189 /* End of list of Guest State Buffer Element IDs */
190 #define GSB_LAST                GSB_VCPU_SPR_ASDR
191 
192 typedef struct SpaprMachineStateNested {
193     uint64_t ptcr;
194     uint8_t api;
195 #define NESTED_API_KVM_HV  1
196 #define NESTED_API_PAPR    2
197     bool capabilities_set;
198     uint32_t pvr_base;
199     GHashTable *guests;
200 } SpaprMachineStateNested;
201 
202 typedef struct SpaprMachineStateNestedGuest {
203     uint32_t pvr_logical;
204     unsigned long nr_vcpus;
205     uint64_t parttbl[2];
206     uint64_t tb_offset;
207     struct SpaprMachineStateNestedGuestVcpu *vcpus;
208 } SpaprMachineStateNestedGuest;
209 
210 /* Nested PAPR API related macros */
211 #define H_GUEST_CAPABILITIES_COPY_MEM 0x8000000000000000
212 #define H_GUEST_CAPABILITIES_P9_MODE  0x4000000000000000
213 #define H_GUEST_CAPABILITIES_P10_MODE 0x2000000000000000
214 #define H_GUEST_CAPABILITIES_P11_MODE 0x1000000000000000
215 #define H_GUEST_CAP_VALID_MASK        (H_GUEST_CAPABILITIES_P11_MODE | \
216                                        H_GUEST_CAPABILITIES_P10_MODE | \
217                                        H_GUEST_CAPABILITIES_P9_MODE)
218 #define H_GUEST_CAP_COPY_MEM_BMAP     0
219 #define H_GUEST_CAP_P9_MODE_BMAP      1
220 #define H_GUEST_CAP_P10_MODE_BMAP     2
221 #define H_GUEST_CAP_P11_MODE_BMAP     3
222 #define PAPR_NESTED_GUEST_MAX         4096
223 #define H_GUEST_DELETE_ALL_FLAG       0x8000000000000000ULL
224 #define PAPR_NESTED_GUEST_VCPU_MAX    2048
225 #define VCPU_OUT_BUF_MIN_SZ           0x80ULL
226 #define HVMASK_DEFAULT                0xffffffffffffffff
227 #define HVMASK_LPCR                   0x0070000003820800
228 #define HVMASK_MSR                    0xEBFFFFFFFFBFEFFF
229 #define HVMASK_HDEXCR                 0x00000000FFFFFFFF
230 #define HVMASK_TB_OFFSET              0x000000FFFFFFFFFF
231 #define GSB_MAX_BUF_SIZE              (1024 * 1024)
232 #define H_GUEST_GETSET_STATE_FLAG_GUEST_WIDE 0x8000000000000000
233 #define GUEST_STATE_REQUEST_GUEST_WIDE       0x1
234 #define GUEST_STATE_REQUEST_SET              0x2
235 
236 /*
237  * As per ISA v3.1B, following bits are reserved:
238  *      0:2
239  *      4:57  (ISA mentions bit 58 as well but it should be used for P10)
240  *      61:63 (hence, haven't included PCR bits for v2.06 and v2.05
241  *             in LOW BITS)
242  */
243 #define PCR_LOW_BITS   (PCR_COMPAT_3_10 | PCR_COMPAT_3_00)
244 #define HVMASK_PCR     (~PCR_LOW_BITS)
245 
246 #define GUEST_STATE_ELEMENT(i, sz, s, f, ptr, c) { \
247     .id = (i),                                     \
248     .size = (sz),                                  \
249     .location = ptr,                               \
250     .offset = offsetof(struct s, f),               \
251     .copy = (c)                                    \
252 }
253 
254 #define GSBE_NESTED(i, sz, f, c) {                             \
255     .id = (i),                                                 \
256     .size = (sz),                                              \
257     .location = get_guest_ptr,                                 \
258     .offset = offsetof(struct SpaprMachineStateNestedGuest, f),\
259     .copy = (c),                                               \
260     .mask = HVMASK_DEFAULT                                     \
261 }
262 
263 #define GSBE_NESTED_MSK(i, sz, f, c, m) {                      \
264     .id = (i),                                                 \
265     .size = (sz),                                              \
266     .location = get_guest_ptr,                                 \
267     .offset = offsetof(struct SpaprMachineStateNestedGuest, f),\
268     .copy = (c),                                               \
269     .mask = (m)                                                \
270 }
271 
272 #define GSBE_NESTED_VCPU(i, sz, f, c) {                            \
273     .id = (i),                                                     \
274     .size = (sz),                                                  \
275     .location = get_vcpu_ptr,                                      \
276     .offset = offsetof(struct SpaprMachineStateNestedGuestVcpu, f),\
277     .copy = (c),                                                   \
278     .mask = HVMASK_DEFAULT                                         \
279 }
280 
281 #define GUEST_STATE_ELEMENT_NOP(i, sz) { \
282     .id = (i),                             \
283     .size = (sz),                          \
284     .location = NULL,                      \
285     .offset = 0,                           \
286     .copy = NULL,                          \
287     .mask = HVMASK_DEFAULT                 \
288 }
289 
290 #define GUEST_STATE_ELEMENT_NOP_DW(i)   \
291         GUEST_STATE_ELEMENT_NOP(i, 8)
292 #define GUEST_STATE_ELEMENT_NOP_W(i) \
293         GUEST_STATE_ELEMENT_NOP(i, 4)
294 
295 #define GUEST_STATE_ELEMENT_BASE(i, s, c) {  \
296             .id = (i),                           \
297             .size = (s),                         \
298             .location = get_vcpu_state_ptr,      \
299             .offset = 0,                         \
300             .copy = (c),                         \
301             .mask = HVMASK_DEFAULT               \
302     }
303 
304 #define GUEST_STATE_ELEMENT_OFF(i, s, f, c) {    \
305             .id = (i),                           \
306             .size = (s),                         \
307             .location = get_vcpu_state_ptr,      \
308             .offset = offsetof(struct nested_ppc_state, f),  \
309             .copy = (c),                         \
310             .mask = HVMASK_DEFAULT               \
311     }
312 
313 #define GUEST_STATE_ELEMENT_MSK(i, s, f, c, m) { \
314             .id = (i),                           \
315             .size = (s),                         \
316             .location = get_vcpu_state_ptr,      \
317             .offset = offsetof(struct nested_ppc_state, f),  \
318             .copy = (c),                         \
319             .mask = (m)                          \
320     }
321 
322 #define GUEST_STATE_ELEMENT_ENV_QW(i, f) \
323     GUEST_STATE_ELEMENT_OFF(i, 16, f, copy_state_16to16)
324 #define GUEST_STATE_ELEMENT_ENV_DW(i, f) \
325     GUEST_STATE_ELEMENT_OFF(i, 8, f, copy_state_8to8)
326 #define GUEST_STATE_ELEMENT_ENV_W(i, f) \
327     GUEST_STATE_ELEMENT_OFF(i, 4, f, copy_state_4to8)
328 #define GUEST_STATE_ELEMENT_ENV_WW(i, f) \
329     GUEST_STATE_ELEMENT_OFF(i, 4, f, copy_state_4to4)
330 #define GSE_ENV_DWM(i, f, m) \
331     GUEST_STATE_ELEMENT_MSK(i, 8, f, copy_state_8to8, m)
332 
333 struct guest_state_element {
334     uint16_t id;
335     uint16_t size;
336     uint8_t value[];
337 } QEMU_PACKED;
338 
339 struct guest_state_buffer {
340     uint32_t num_elements;
341     struct guest_state_element elements[];
342 } QEMU_PACKED;
343 
344 /* Actual buffer plus some metadata about the request */
345 struct guest_state_request {
346     struct guest_state_buffer *gsb;
347     int64_t buf;
348     int64_t len;
349     uint16_t flags;
350 };
351 
352 /*
353  * Register state for entering a nested guest with H_ENTER_NESTED.
354  * New member must be added at the end.
355  */
356 struct kvmppc_hv_guest_state {
357     uint64_t version;      /* version of this structure layout, must be first */
358     uint32_t lpid;
359     uint32_t vcpu_token;
360     /* These registers are hypervisor privileged (at least for writing) */
361     uint64_t lpcr;
362     uint64_t pcr;
363     uint64_t amor;
364     uint64_t dpdes;
365     uint64_t hfscr;
366     int64_t tb_offset;
367     uint64_t dawr0;
368     uint64_t dawrx0;
369     uint64_t ciabr;
370     uint64_t hdec_expiry;
371     uint64_t purr;
372     uint64_t spurr;
373     uint64_t ic;
374     uint64_t vtb;
375     uint64_t hdar;
376     uint64_t hdsisr;
377     uint64_t heir;
378     uint64_t asdr;
379     /* These are OS privileged but need to be set late in guest entry */
380     uint64_t srr0;
381     uint64_t srr1;
382     uint64_t sprg[4];
383     uint64_t pidr;
384     uint64_t cfar;
385     uint64_t ppr;
386     /* Version 1 ends here */
387     uint64_t dawr1;
388     uint64_t dawrx1;
389     /* Version 2 ends here */
390 };
391 
392 /* Latest version of hv_guest_state structure */
393 #define HV_GUEST_STATE_VERSION  2
394 
395 /* Linux 64-bit powerpc pt_regs struct, used by nested HV */
396 struct kvmppc_pt_regs {
397     uint64_t gpr[32];
398     uint64_t nip;
399     uint64_t msr;
400     uint64_t orig_gpr3;    /* Used for restarting system calls */
401     uint64_t ctr;
402     uint64_t link;
403     uint64_t xer;
404     uint64_t ccr;
405     uint64_t softe;        /* Soft enabled/disabled */
406     uint64_t trap;         /* Reason for being here */
407     uint64_t dar;          /* Fault registers */
408     uint64_t dsisr;        /* on 4xx/Book-E used for ESR */
409     uint64_t result;       /* Result of a system call */
410 };
411 
412 /*
413  * nested_ppc_state is used to save the host CPU state before switching it to
414  * the guest CPU state, to be restored on H_ENTER_NESTED exit.
415  */
416 struct nested_ppc_state {
417     uint64_t gpr[32];
418     uint64_t lr;
419     uint64_t ctr;
420     uint64_t cfar;
421     uint64_t msr;
422     uint64_t nip;
423     uint32_t cr;
424 
425     uint64_t xer;
426 
427     uint64_t lpcr;
428     uint64_t lpidr;
429     uint64_t pidr;
430     uint64_t pcr;
431     uint64_t dpdes;
432     uint64_t hfscr;
433     uint64_t srr0;
434     uint64_t srr1;
435     uint64_t sprg0;
436     uint64_t sprg1;
437     uint64_t sprg2;
438     uint64_t sprg3;
439     uint64_t ppr;
440 
441     int64_t tb_offset;
442     /* Nested PAPR API */
443     uint64_t amor;
444     uint64_t dawr0;
445     uint64_t dawrx0;
446     uint64_t ciabr;
447     uint64_t purr;
448     uint64_t spurr;
449     uint64_t ic;
450     uint64_t vtb;
451     uint64_t hdar;
452     uint64_t hdsisr;
453     uint64_t heir;
454     uint64_t asdr;
455     uint64_t dawr1;
456     uint64_t dawrx1;
457     uint64_t dexcr;
458     uint64_t hdexcr;
459     uint64_t hashkeyr;
460     uint64_t hashpkeyr;
461     ppc_vsr_t vsr[64] QEMU_ALIGNED(16);
462     uint64_t ebbhr;
463     uint64_t tar;
464     uint64_t ebbrr;
465     uint64_t bescr;
466     uint64_t iamr;
467     uint64_t amr;
468     uint64_t uamor;
469     uint64_t dscr;
470     uint64_t fscr;
471     uint64_t pspb;
472     uint64_t ctrl;
473     uint64_t vrsave;
474     uint64_t dar;
475     uint64_t dsisr;
476     uint64_t pmc1;
477     uint64_t pmc2;
478     uint64_t pmc3;
479     uint64_t pmc4;
480     uint64_t pmc5;
481     uint64_t pmc6;
482     uint64_t mmcr0;
483     uint64_t mmcr1;
484     uint64_t mmcr2;
485     uint64_t mmcra;
486     uint64_t sdar;
487     uint64_t siar;
488     uint64_t sier;
489     uint32_t vscr;
490     uint64_t fpscr;
491     int64_t dec_expiry_tb;
492 };
493 
494 struct SpaprMachineStateNestedGuestVcpuRunBuf {
495     uint64_t addr;
496     uint64_t size;
497 };
498 
499 typedef struct SpaprMachineStateNestedGuestVcpu {
500     bool enabled;
501     struct nested_ppc_state state;
502     struct SpaprMachineStateNestedGuestVcpuRunBuf runbufin;
503     struct SpaprMachineStateNestedGuestVcpuRunBuf runbufout;
504     int64_t tb_offset;
505     uint64_t hdecr_expiry_tb;
506 } SpaprMachineStateNestedGuestVcpu;
507 
508 struct guest_state_element_type {
509     uint16_t id;
510     int size;
511 #define GUEST_STATE_ELEMENT_TYPE_FLAG_GUEST_WIDE 0x1
512 #define GUEST_STATE_ELEMENT_TYPE_FLAG_READ_ONLY  0x2
513    uint16_t flags;
514     void *(*location)(SpaprMachineStateNestedGuest *, target_ulong);
515     size_t offset;
516     void (*copy)(void *, void *, bool);
517     uint64_t mask;
518 };
519 
520 void spapr_exit_nested(PowerPCCPU *cpu, int excp);
521 typedef struct SpaprMachineState SpaprMachineState;
522 bool spapr_get_pate_nested_hv(SpaprMachineState *spapr, PowerPCCPU *cpu,
523                               target_ulong lpid, ppc_v3_pate_t *entry);
524 uint8_t spapr_nested_api(SpaprMachineState *spapr);
525 void spapr_nested_gsb_init(void);
526 bool spapr_get_pate_nested_papr(SpaprMachineState *spapr, PowerPCCPU *cpu,
527                                 target_ulong lpid, ppc_v3_pate_t *entry);
528 #endif /* HW_SPAPR_NESTED_H */
529