xref: /openbmc/qemu/include/hw/ppc/spapr_nested.h (revision 2df1eb27)
1 #ifndef HW_SPAPR_NESTED_H
2 #define HW_SPAPR_NESTED_H
3 
4 #include "target/ppc/cpu.h"
5 
6 /*
7  * Register state for entering a nested guest with H_ENTER_NESTED.
8  * New member must be added at the end.
9  */
10 struct kvmppc_hv_guest_state {
11     uint64_t version;      /* version of this structure layout, must be first */
12     uint32_t lpid;
13     uint32_t vcpu_token;
14     /* These registers are hypervisor privileged (at least for writing) */
15     uint64_t lpcr;
16     uint64_t pcr;
17     uint64_t amor;
18     uint64_t dpdes;
19     uint64_t hfscr;
20     int64_t tb_offset;
21     uint64_t dawr0;
22     uint64_t dawrx0;
23     uint64_t ciabr;
24     uint64_t hdec_expiry;
25     uint64_t purr;
26     uint64_t spurr;
27     uint64_t ic;
28     uint64_t vtb;
29     uint64_t hdar;
30     uint64_t hdsisr;
31     uint64_t heir;
32     uint64_t asdr;
33     /* These are OS privileged but need to be set late in guest entry */
34     uint64_t srr0;
35     uint64_t srr1;
36     uint64_t sprg[4];
37     uint64_t pidr;
38     uint64_t cfar;
39     uint64_t ppr;
40     /* Version 1 ends here */
41     uint64_t dawr1;
42     uint64_t dawrx1;
43     /* Version 2 ends here */
44 };
45 
46 /* Latest version of hv_guest_state structure */
47 #define HV_GUEST_STATE_VERSION  2
48 
49 /* Linux 64-bit powerpc pt_regs struct, used by nested HV */
50 struct kvmppc_pt_regs {
51     uint64_t gpr[32];
52     uint64_t nip;
53     uint64_t msr;
54     uint64_t orig_gpr3;    /* Used for restarting system calls */
55     uint64_t ctr;
56     uint64_t link;
57     uint64_t xer;
58     uint64_t ccr;
59     uint64_t softe;        /* Soft enabled/disabled */
60     uint64_t trap;         /* Reason for being here */
61     uint64_t dar;          /* Fault registers */
62     uint64_t dsisr;        /* on 4xx/Book-E used for ESR */
63     uint64_t result;       /* Result of a system call */
64 };
65 
66 /*
67  * nested_ppc_state is used to save the host CPU state before switching it to
68  * the guest CPU state, to be restored on H_ENTER_NESTED exit.
69  */
70 struct nested_ppc_state {
71     uint64_t gpr[32];
72     uint64_t lr;
73     uint64_t ctr;
74     uint64_t cfar;
75     uint64_t msr;
76     uint64_t nip;
77     uint32_t cr;
78 
79     uint64_t xer;
80 
81     uint64_t lpcr;
82     uint64_t lpidr;
83     uint64_t pidr;
84     uint64_t pcr;
85     uint64_t dpdes;
86     uint64_t hfscr;
87     uint64_t srr0;
88     uint64_t srr1;
89     uint64_t sprg0;
90     uint64_t sprg1;
91     uint64_t sprg2;
92     uint64_t sprg3;
93     uint64_t ppr;
94 
95     int64_t tb_offset;
96 };
97 
98 void spapr_register_nested(void);
99 void spapr_exit_nested(PowerPCCPU *cpu, int excp);
100 
101 #endif /* HW_SPAPR_NESTED_H */
102