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