xref: /qemu/include/hw/ppc/spapr.h (revision c982f5cf9ab9e60a8255f9cc72362c932c252471)
12a6a4076SMarkus Armbruster #ifndef HW_SPAPR_H
22a6a4076SMarkus Armbruster #define HW_SPAPR_H
39fdf0c29SDavid Gibson 
4ab3dd749SPhilippe Mathieu-Daudé #include "qemu/units.h"
59c17d615SPaolo Bonzini #include "sysemu/dma.h"
628e02042SDavid Gibson #include "hw/boards.h"
731fe14d1SNathan Fontenot #include "hw/ppc/spapr_drc.h"
84a1c9cf0SBharata B Rao #include "hw/mem/pc-dimm.h"
9facdb8b6SMichael Roth #include "hw/ppc/spapr_ovec.h"
1082cffa2eSCédric Le Goater #include "hw/ppc/spapr_irq.h"
110d8d6a24SThomas Huth #include "hw/ppc/spapr_xive.h"  /* For sPAPRXive */
120d8d6a24SThomas Huth #include "hw/ppc/xics.h"        /* For ICSState */
13277f9acfSPaolo Bonzini 
144040ab72SDavid Gibson struct VIOsPAPRBus;
153384f95cSDavid Gibson struct sPAPRPHBState;
16639e8102SDavid Gibson struct sPAPRNVRAM;
170d8d6a24SThomas Huth 
1831fe14d1SNathan Fontenot typedef struct sPAPREventLogEntry sPAPREventLogEntry;
19ffbb1705SMichael Roth typedef struct sPAPREventSource sPAPREventSource;
200b0b8310SDavid Gibson typedef struct sPAPRPendingHPT sPAPRPendingHPT;
214040ab72SDavid Gibson 
224be21d56SDavid Gibson #define HPTE64_V_HPTE_DIRTY     0x0000000000000040ULL
231b718907SDavid Gibson #define SPAPR_ENTRY_POINT       0x100
244be21d56SDavid Gibson 
25afd10a0fSBharata B Rao #define SPAPR_TIMEBASE_FREQ     512000000ULL
26afd10a0fSBharata B Rao 
27147ff807SCédric Le Goater #define TYPE_SPAPR_RTC "spapr-rtc"
28147ff807SCédric Le Goater 
29147ff807SCédric Le Goater #define SPAPR_RTC(obj)                                  \
30147ff807SCédric Le Goater     OBJECT_CHECK(sPAPRRTCState, (obj), TYPE_SPAPR_RTC)
31147ff807SCédric Le Goater 
32147ff807SCédric Le Goater typedef struct sPAPRRTCState sPAPRRTCState;
33147ff807SCédric Le Goater struct sPAPRRTCState {
34147ff807SCédric Le Goater     /*< private >*/
35147ff807SCédric Le Goater     DeviceState parent_obj;
36147ff807SCédric Le Goater     int64_t ns_offset;
37147ff807SCédric Le Goater };
38147ff807SCédric Le Goater 
390cffce56SDavid Gibson typedef struct sPAPRDIMMState sPAPRDIMMState;
40183930c0SDavid Gibson typedef struct sPAPRMachineClass sPAPRMachineClass;
4128e02042SDavid Gibson 
4228e02042SDavid Gibson #define TYPE_SPAPR_MACHINE      "spapr-machine"
4328e02042SDavid Gibson #define SPAPR_MACHINE(obj) \
4428e02042SDavid Gibson     OBJECT_CHECK(sPAPRMachineState, (obj), TYPE_SPAPR_MACHINE)
45183930c0SDavid Gibson #define SPAPR_MACHINE_GET_CLASS(obj) \
46183930c0SDavid Gibson     OBJECT_GET_CLASS(sPAPRMachineClass, obj, TYPE_SPAPR_MACHINE)
47183930c0SDavid Gibson #define SPAPR_MACHINE_CLASS(klass) \
48183930c0SDavid Gibson     OBJECT_CLASS_CHECK(sPAPRMachineClass, klass, TYPE_SPAPR_MACHINE)
49183930c0SDavid Gibson 
5030f4b05bSDavid Gibson typedef enum {
5130f4b05bSDavid Gibson     SPAPR_RESIZE_HPT_DEFAULT = 0,
5230f4b05bSDavid Gibson     SPAPR_RESIZE_HPT_DISABLED,
5330f4b05bSDavid Gibson     SPAPR_RESIZE_HPT_ENABLED,
5430f4b05bSDavid Gibson     SPAPR_RESIZE_HPT_REQUIRED,
5530f4b05bSDavid Gibson } sPAPRResizeHPT;
5630f4b05bSDavid Gibson 
57183930c0SDavid Gibson /**
5833face6bSDavid Gibson  * Capabilities
5933face6bSDavid Gibson  */
6033face6bSDavid Gibson 
61ee76a09fSDavid Gibson /* Hardware Transactional Memory */
624e5fe368SSuraj Jitindar Singh #define SPAPR_CAP_HTM                   0x00
6329386642SDavid Gibson /* Vector Scalar Extensions */
644e5fe368SSuraj Jitindar Singh #define SPAPR_CAP_VSX                   0x01
652d1fb9bcSDavid Gibson /* Decimal Floating Point */
664e5fe368SSuraj Jitindar Singh #define SPAPR_CAP_DFP                   0x02
678f38eaf8SSuraj Jitindar Singh /* Cache Flush on Privilege Change */
688f38eaf8SSuraj Jitindar Singh #define SPAPR_CAP_CFPC                  0x03
6909114fd8SSuraj Jitindar Singh /* Speculation Barrier Bounds Checking */
7009114fd8SSuraj Jitindar Singh #define SPAPR_CAP_SBBC                  0x04
714be8d4e7SSuraj Jitindar Singh /* Indirect Branch Serialisation */
724be8d4e7SSuraj Jitindar Singh #define SPAPR_CAP_IBS                   0x05
732309832aSDavid Gibson /* HPT Maximum Page Size (encoded as a shift) */
742309832aSDavid Gibson #define SPAPR_CAP_HPT_MAXPAGESIZE       0x06
75b9a477b7SSuraj Jitindar Singh /* Nested KVM-HV */
76b9a477b7SSuraj Jitindar Singh #define SPAPR_CAP_NESTED_KVM_HV         0x07
77*c982f5cfSSuraj Jitindar Singh /* Large Decrementer */
78*c982f5cfSSuraj Jitindar Singh #define SPAPR_CAP_LARGE_DECREMENTER     0x08
794e5fe368SSuraj Jitindar Singh /* Num Caps */
80*c982f5cfSSuraj Jitindar Singh #define SPAPR_CAP_NUM                   (SPAPR_CAP_LARGE_DECREMENTER + 1)
814e5fe368SSuraj Jitindar Singh 
824e5fe368SSuraj Jitindar Singh /*
834e5fe368SSuraj Jitindar Singh  * Capability Values
844e5fe368SSuraj Jitindar Singh  */
854e5fe368SSuraj Jitindar Singh /* Bool Caps */
864e5fe368SSuraj Jitindar Singh #define SPAPR_CAP_OFF                   0x00
874e5fe368SSuraj Jitindar Singh #define SPAPR_CAP_ON                    0x01
88c76c0d30SSuraj Jitindar Singh /* Custom Caps */
896898aed7SSuraj Jitindar Singh #define SPAPR_CAP_BROKEN                0x00
906898aed7SSuraj Jitindar Singh #define SPAPR_CAP_WORKAROUND            0x01
916898aed7SSuraj Jitindar Singh #define SPAPR_CAP_FIXED                 0x02
92c76c0d30SSuraj Jitindar Singh #define SPAPR_CAP_FIXED_IBS             0x02
93c76c0d30SSuraj Jitindar Singh #define SPAPR_CAP_FIXED_CCD             0x03
942d1fb9bcSDavid Gibson 
9533face6bSDavid Gibson typedef struct sPAPRCapabilities sPAPRCapabilities;
9633face6bSDavid Gibson struct sPAPRCapabilities {
974e5fe368SSuraj Jitindar Singh     uint8_t caps[SPAPR_CAP_NUM];
9833face6bSDavid Gibson };
9933face6bSDavid Gibson 
10033face6bSDavid Gibson /**
101183930c0SDavid Gibson  * sPAPRMachineClass:
102183930c0SDavid Gibson  */
103183930c0SDavid Gibson struct sPAPRMachineClass {
104183930c0SDavid Gibson     /*< private >*/
105183930c0SDavid Gibson     MachineClass parent_class;
106183930c0SDavid Gibson 
107183930c0SDavid Gibson     /*< public >*/
108224245bfSDavid Gibson     bool dr_lmb_enabled;       /* enable dynamic-reconfig/hotplug of LMBs */
109962b6c36SMichael Roth     bool dr_phb_enabled;       /* enable dynamic-reconfig/hotplug of PHBs */
110fea35ca4SAlexey Kardashevskiy     bool update_dt_enabled;    /* enable KVMPPC_H_UPDATE_DT */
11157040d45SThomas Huth     bool use_ohci_by_default;  /* use USB-OHCI instead of XHCI */
11246f7afa3SGreg Kurz     bool pre_2_10_has_unused_icps;
11382cffa2eSCédric Le Goater     bool legacy_irq_allocation;
11482cffa2eSCédric Le Goater 
1156737d9adSDavid Gibson     void (*phb_placement)(sPAPRMachineState *spapr, uint32_t index,
116daa23699SDavid Gibson                           uint64_t *buid, hwaddr *pio,
117daa23699SDavid Gibson                           hwaddr *mmio32, hwaddr *mmio64,
1186737d9adSDavid Gibson                           unsigned n_dma, uint32_t *liobns, Error **errp);
11930f4b05bSDavid Gibson     sPAPRResizeHPT resize_hpt_default;
12033face6bSDavid Gibson     sPAPRCapabilities default_caps;
121ef01ed9dSCédric Le Goater     sPAPRIrq *irq;
122183930c0SDavid Gibson };
12328e02042SDavid Gibson 
12428e02042SDavid Gibson /**
12528e02042SDavid Gibson  * sPAPRMachineState:
12628e02042SDavid Gibson  */
12728e02042SDavid Gibson struct sPAPRMachineState {
12828e02042SDavid Gibson     /*< private >*/
12928e02042SDavid Gibson     MachineState parent_obj;
13028e02042SDavid Gibson 
1314040ab72SDavid Gibson     struct VIOsPAPRBus *vio_bus;
1323384f95cSDavid Gibson     QLIST_HEAD(, sPAPRPHBState) phbs;
133639e8102SDavid Gibson     struct sPAPRNVRAM *nvram;
134681bfadeSCédric Le Goater     ICSState *ics;
135147ff807SCédric Le Goater     sPAPRRTCState rtc;
136a3467baaSDavid Gibson 
13730f4b05bSDavid Gibson     sPAPRResizeHPT resize_hpt;
138a3467baaSDavid Gibson     void *htab;
1394be21d56SDavid Gibson     uint32_t htab_shift;
1409861bb3eSSuraj Jitindar Singh     uint64_t patb_entry; /* Process tbl registed in H_REGISTER_PROCESS_TABLE */
1410b0b8310SDavid Gibson     sPAPRPendingHPT *pending_hpt; /* in-progress resize */
1420b0b8310SDavid Gibson 
143a8170e5eSAvi Kivity     hwaddr rma_size;
1447f763a5dSDavid Gibson     int vrma_adjust;
145b7d1f77aSBenjamin Herrenschmidt     ssize_t rtas_size;
146b7d1f77aSBenjamin Herrenschmidt     void *rtas_blob;
147fea35ca4SAlexey Kardashevskiy     uint32_t fdt_size;
148fea35ca4SAlexey Kardashevskiy     uint32_t fdt_initial_size;
149fea35ca4SAlexey Kardashevskiy     void *fdt_blob;
150a19f7fb0SDavid Gibson     long kernel_size;
151a19f7fb0SDavid Gibson     bool kernel_le;
152a19f7fb0SDavid Gibson     uint32_t initrd_base;
153a19f7fb0SDavid Gibson     long initrd_size;
154880ae7deSDavid Gibson     uint64_t rtc_offset; /* Now used only during incoming migration */
15598a8b524SAlexey Kardashevskiy     struct PPCTimebase tb;
1563fc5acdeSAlexander Graf     bool has_graphics;
157fa98fbfcSSam Bobroff     uint32_t vsmt;       /* Virtual SMT mode (KVM's "core stride") */
15874d042e5SDavid Gibson 
15974d042e5SDavid Gibson     Notifier epow_notifier;
16031fe14d1SNathan Fontenot     QTAILQ_HEAD(, sPAPREventLogEntry) pending_events;
161ffbb1705SMichael Roth     bool use_hotplug_event_source;
162ffbb1705SMichael Roth     sPAPREventSource *event_sources;
1634be21d56SDavid Gibson 
1647843c0d6SDavid Gibson     /* ibm,client-architecture-support option negotiation */
1657843c0d6SDavid Gibson     bool cas_reboot;
1667843c0d6SDavid Gibson     bool cas_legacy_guest_workaround;
1677843c0d6SDavid Gibson     sPAPROptionVector *ov5;         /* QEMU-supported option vectors */
1687843c0d6SDavid Gibson     sPAPROptionVector *ov5_cas;     /* negotiated (via CAS) option vectors */
1697843c0d6SDavid Gibson     uint32_t max_compat_pvr;
1707843c0d6SDavid Gibson 
1714be21d56SDavid Gibson     /* Migration state */
1724be21d56SDavid Gibson     int htab_save_index;
1734be21d56SDavid Gibson     bool htab_first_pass;
174e68cb8b4SAlexey Kardashevskiy     int htab_fd;
17546503c2bSMichael Roth 
1760cffce56SDavid Gibson     /* Pending DIMM unplug cache. It is populated when a LMB
1770cffce56SDavid Gibson      * unplug starts. It can be regenerated if a migration
1780cffce56SDavid Gibson      * occurs during the unplug process. */
1790cffce56SDavid Gibson     QTAILQ_HEAD(, sPAPRDIMMState) pending_dimm_unplugs;
1800cffce56SDavid Gibson 
18128e02042SDavid Gibson     /*< public >*/
18228e02042SDavid Gibson     char *kvm_type;
18327461d69SPrasad J Pandit     char *host_model;
18427461d69SPrasad J Pandit     char *host_serial;
185852ad27eSCédric Le Goater 
18682cffa2eSCédric Le Goater     int32_t irq_map_nr;
18782cffa2eSCédric Le Goater     unsigned long *irq_map;
188dcc345b6SCédric Le Goater     sPAPRXive  *xive;
1893ba3d0bcSCédric Le Goater     sPAPRIrq *irq;
190872ff3deSCédric Le Goater     qemu_irq *qirqs;
19133face6bSDavid Gibson 
1924e5fe368SSuraj Jitindar Singh     bool cmd_line_caps[SPAPR_CAP_NUM];
1934e5fe368SSuraj Jitindar Singh     sPAPRCapabilities def, eff, mig;
19428e02042SDavid Gibson };
1959fdf0c29SDavid Gibson 
1969fdf0c29SDavid Gibson #define H_SUCCESS         0
1979fdf0c29SDavid Gibson #define H_BUSY            1        /* Hardware busy -- retry later */
1989fdf0c29SDavid Gibson #define H_CLOSED          2        /* Resource closed */
1999fdf0c29SDavid Gibson #define H_NOT_AVAILABLE   3
2009fdf0c29SDavid Gibson #define H_CONSTRAINED     4        /* Resource request constrained to max allowed */
2019fdf0c29SDavid Gibson #define H_PARTIAL         5
2029fdf0c29SDavid Gibson #define H_IN_PROGRESS     14       /* Kind of like busy */
2039fdf0c29SDavid Gibson #define H_PAGE_REGISTERED 15
2049fdf0c29SDavid Gibson #define H_PARTIAL_STORE   16
2059fdf0c29SDavid Gibson #define H_PENDING         17       /* returned from H_POLL_PENDING */
2069fdf0c29SDavid Gibson #define H_CONTINUE        18       /* Returned from H_Join on success */
2079fdf0c29SDavid Gibson #define H_LONG_BUSY_START_RANGE         9900  /* Start of long busy range */
2089fdf0c29SDavid Gibson #define H_LONG_BUSY_ORDER_1_MSEC        9900  /* Long busy, hint that 1msec \
2099fdf0c29SDavid Gibson                                                  is a good time to retry */
2109fdf0c29SDavid Gibson #define H_LONG_BUSY_ORDER_10_MSEC       9901  /* Long busy, hint that 10msec \
2119fdf0c29SDavid Gibson                                                  is a good time to retry */
2129fdf0c29SDavid Gibson #define H_LONG_BUSY_ORDER_100_MSEC      9902  /* Long busy, hint that 100msec \
2139fdf0c29SDavid Gibson                                                  is a good time to retry */
2149fdf0c29SDavid Gibson #define H_LONG_BUSY_ORDER_1_SEC         9903  /* Long busy, hint that 1sec \
2159fdf0c29SDavid Gibson                                                  is a good time to retry */
2169fdf0c29SDavid Gibson #define H_LONG_BUSY_ORDER_10_SEC        9904  /* Long busy, hint that 10sec \
2179fdf0c29SDavid Gibson                                                  is a good time to retry */
2189fdf0c29SDavid Gibson #define H_LONG_BUSY_ORDER_100_SEC       9905  /* Long busy, hint that 100sec \
2199fdf0c29SDavid Gibson                                                  is a good time to retry */
2209fdf0c29SDavid Gibson #define H_LONG_BUSY_END_RANGE           9905  /* End of long busy range */
2219fdf0c29SDavid Gibson #define H_HARDWARE        -1       /* Hardware error */
2229fdf0c29SDavid Gibson #define H_FUNCTION        -2       /* Function not supported */
2239fdf0c29SDavid Gibson #define H_PRIVILEGE       -3       /* Caller not privileged */
2249fdf0c29SDavid Gibson #define H_PARAMETER       -4       /* Parameter invalid, out-of-range or conflicting */
2259fdf0c29SDavid Gibson #define H_BAD_MODE        -5       /* Illegal msr value */
2269fdf0c29SDavid Gibson #define H_PTEG_FULL       -6       /* PTEG is full */
2279fdf0c29SDavid Gibson #define H_NOT_FOUND       -7       /* PTE was not found" */
2289fdf0c29SDavid Gibson #define H_RESERVED_DABR   -8       /* DABR address is reserved by the hypervisor on this processor" */
2299fdf0c29SDavid Gibson #define H_NO_MEM          -9
2309fdf0c29SDavid Gibson #define H_AUTHORITY       -10
2319fdf0c29SDavid Gibson #define H_PERMISSION      -11
2329fdf0c29SDavid Gibson #define H_DROPPED         -12
2339fdf0c29SDavid Gibson #define H_SOURCE_PARM     -13
2349fdf0c29SDavid Gibson #define H_DEST_PARM       -14
2359fdf0c29SDavid Gibson #define H_REMOTE_PARM     -15
2369fdf0c29SDavid Gibson #define H_RESOURCE        -16
2379fdf0c29SDavid Gibson #define H_ADAPTER_PARM    -17
2389fdf0c29SDavid Gibson #define H_RH_PARM         -18
2399fdf0c29SDavid Gibson #define H_RCQ_PARM        -19
2409fdf0c29SDavid Gibson #define H_SCQ_PARM        -20
2419fdf0c29SDavid Gibson #define H_EQ_PARM         -21
2429fdf0c29SDavid Gibson #define H_RT_PARM         -22
2439fdf0c29SDavid Gibson #define H_ST_PARM         -23
2449fdf0c29SDavid Gibson #define H_SIGT_PARM       -24
2459fdf0c29SDavid Gibson #define H_TOKEN_PARM      -25
2469fdf0c29SDavid Gibson #define H_MLENGTH_PARM    -27
2479fdf0c29SDavid Gibson #define H_MEM_PARM        -28
2489fdf0c29SDavid Gibson #define H_MEM_ACCESS_PARM -29
2499fdf0c29SDavid Gibson #define H_ATTR_PARM       -30
2509fdf0c29SDavid Gibson #define H_PORT_PARM       -31
2519fdf0c29SDavid Gibson #define H_MCG_PARM        -32
2529fdf0c29SDavid Gibson #define H_VL_PARM         -33
2539fdf0c29SDavid Gibson #define H_TSIZE_PARM      -34
2549fdf0c29SDavid Gibson #define H_TRACE_PARM      -35
2559fdf0c29SDavid Gibson 
2569fdf0c29SDavid Gibson #define H_MASK_PARM       -37
2579fdf0c29SDavid Gibson #define H_MCG_FULL        -38
2589fdf0c29SDavid Gibson #define H_ALIAS_EXIST     -39
2599fdf0c29SDavid Gibson #define H_P_COUNTER       -40
2609fdf0c29SDavid Gibson #define H_TABLE_FULL      -41
2619fdf0c29SDavid Gibson #define H_ALT_TABLE       -42
2629fdf0c29SDavid Gibson #define H_MR_CONDITION    -43
2639fdf0c29SDavid Gibson #define H_NOT_ENOUGH_RESOURCES -44
2649fdf0c29SDavid Gibson #define H_R_STATE         -45
2659fdf0c29SDavid Gibson #define H_RESCINDEND      -46
26642561bf2SAnton Blanchard #define H_P2              -55
26742561bf2SAnton Blanchard #define H_P3              -56
26842561bf2SAnton Blanchard #define H_P4              -57
26942561bf2SAnton Blanchard #define H_P5              -58
27042561bf2SAnton Blanchard #define H_P6              -59
27142561bf2SAnton Blanchard #define H_P7              -60
27242561bf2SAnton Blanchard #define H_P8              -61
27342561bf2SAnton Blanchard #define H_P9              -62
27442561bf2SAnton Blanchard #define H_UNSUPPORTED_FLAG -256
2759fdf0c29SDavid Gibson #define H_MULTI_THREADS_ACTIVE -9005
2769fdf0c29SDavid Gibson 
2779fdf0c29SDavid Gibson 
2789fdf0c29SDavid Gibson /* Long Busy is a condition that can be returned by the firmware
2799fdf0c29SDavid Gibson  * when a call cannot be completed now, but the identical call
2809fdf0c29SDavid Gibson  * should be retried later.  This prevents calls blocking in the
2819fdf0c29SDavid Gibson  * firmware for long periods of time.  Annoyingly the firmware can return
2829fdf0c29SDavid Gibson  * a range of return codes, hinting at how long we should wait before
2839fdf0c29SDavid Gibson  * retrying.  If you don't care for the hint, the macro below is a good
2849fdf0c29SDavid Gibson  * way to check for the long_busy return codes
2859fdf0c29SDavid Gibson  */
2869fdf0c29SDavid Gibson #define H_IS_LONG_BUSY(x)  ((x >= H_LONG_BUSY_START_RANGE) \
2879fdf0c29SDavid Gibson                             && (x <= H_LONG_BUSY_END_RANGE))
2889fdf0c29SDavid Gibson 
2899fdf0c29SDavid Gibson /* Flags */
2909fdf0c29SDavid Gibson #define H_LARGE_PAGE      (1ULL<<(63-16))
2919fdf0c29SDavid Gibson #define H_EXACT           (1ULL<<(63-24))       /* Use exact PTE or return H_PTEG_FULL */
2929fdf0c29SDavid Gibson #define H_R_XLATE         (1ULL<<(63-25))       /* include a valid logical page num in the pte if the valid bit is set */
2939fdf0c29SDavid Gibson #define H_READ_4          (1ULL<<(63-26))       /* Return 4 PTEs */
2949fdf0c29SDavid Gibson #define H_PAGE_STATE_CHANGE (1ULL<<(63-28))
2959fdf0c29SDavid Gibson #define H_PAGE_UNUSED     ((1ULL<<(63-29)) | (1ULL<<(63-30)))
2969fdf0c29SDavid Gibson #define H_PAGE_SET_UNUSED (H_PAGE_STATE_CHANGE | H_PAGE_UNUSED)
2979fdf0c29SDavid Gibson #define H_PAGE_SET_LOANED (H_PAGE_SET_UNUSED | (1ULL<<(63-31)))
2989fdf0c29SDavid Gibson #define H_PAGE_SET_ACTIVE H_PAGE_STATE_CHANGE
2999fdf0c29SDavid Gibson #define H_AVPN            (1ULL<<(63-32))       /* An avpn is provided as a sanity test */
3009fdf0c29SDavid Gibson #define H_ANDCOND         (1ULL<<(63-33))
3019fdf0c29SDavid Gibson #define H_ICACHE_INVALIDATE (1ULL<<(63-40))     /* icbi, etc.  (ignored for IO pages) */
3029fdf0c29SDavid Gibson #define H_ICACHE_SYNCHRONIZE (1ULL<<(63-41))    /* dcbst, icbi, etc (ignored for IO pages */
3039fdf0c29SDavid Gibson #define H_ZERO_PAGE       (1ULL<<(63-48))       /* zero the page before mapping (ignored for IO pages) */
3049fdf0c29SDavid Gibson #define H_COPY_PAGE       (1ULL<<(63-49))
3059fdf0c29SDavid Gibson #define H_N               (1ULL<<(63-61))
3069fdf0c29SDavid Gibson #define H_PP1             (1ULL<<(63-62))
3079fdf0c29SDavid Gibson #define H_PP2             (1ULL<<(63-63))
3089fdf0c29SDavid Gibson 
309a46622fdSAlexey Kardashevskiy /* Values for 2nd argument to H_SET_MODE */
310a46622fdSAlexey Kardashevskiy #define H_SET_MODE_RESOURCE_SET_CIABR           1
311a46622fdSAlexey Kardashevskiy #define H_SET_MODE_RESOURCE_SET_DAWR            2
312a46622fdSAlexey Kardashevskiy #define H_SET_MODE_RESOURCE_ADDR_TRANS_MODE     3
313a46622fdSAlexey Kardashevskiy #define H_SET_MODE_RESOURCE_LE                  4
314a46622fdSAlexey Kardashevskiy 
315a46622fdSAlexey Kardashevskiy /* Flags for H_SET_MODE_RESOURCE_LE */
31642561bf2SAnton Blanchard #define H_SET_MODE_ENDIAN_BIG    0
31742561bf2SAnton Blanchard #define H_SET_MODE_ENDIAN_LITTLE 1
31842561bf2SAnton Blanchard 
3199fdf0c29SDavid Gibson /* VASI States */
3209fdf0c29SDavid Gibson #define H_VASI_INVALID    0
3219fdf0c29SDavid Gibson #define H_VASI_ENABLED    1
3229fdf0c29SDavid Gibson #define H_VASI_ABORTED    2
3239fdf0c29SDavid Gibson #define H_VASI_SUSPENDING 3
3249fdf0c29SDavid Gibson #define H_VASI_SUSPENDED  4
3259fdf0c29SDavid Gibson #define H_VASI_RESUMED    5
3269fdf0c29SDavid Gibson #define H_VASI_COMPLETED  6
3279fdf0c29SDavid Gibson 
3289fdf0c29SDavid Gibson /* DABRX flags */
3299fdf0c29SDavid Gibson #define H_DABRX_HYPERVISOR (1ULL<<(63-61))
3309fdf0c29SDavid Gibson #define H_DABRX_KERNEL     (1ULL<<(63-62))
3319fdf0c29SDavid Gibson #define H_DABRX_USER       (1ULL<<(63-63))
3329fdf0c29SDavid Gibson 
3338acc2ae5SSuraj Jitindar Singh /* Values for KVM_PPC_GET_CPU_CHAR & H_GET_CPU_CHARACTERISTICS */
3348acc2ae5SSuraj Jitindar Singh #define H_CPU_CHAR_SPEC_BAR_ORI31               PPC_BIT(0)
3358acc2ae5SSuraj Jitindar Singh #define H_CPU_CHAR_BCCTRL_SERIALISED            PPC_BIT(1)
3368acc2ae5SSuraj Jitindar Singh #define H_CPU_CHAR_L1D_FLUSH_ORI30              PPC_BIT(2)
3378acc2ae5SSuraj Jitindar Singh #define H_CPU_CHAR_L1D_FLUSH_TRIG2              PPC_BIT(3)
3388acc2ae5SSuraj Jitindar Singh #define H_CPU_CHAR_L1D_THREAD_PRIV              PPC_BIT(4)
3398acc2ae5SSuraj Jitindar Singh #define H_CPU_CHAR_HON_BRANCH_HINTS             PPC_BIT(5)
3408acc2ae5SSuraj Jitindar Singh #define H_CPU_CHAR_THR_RECONF_TRIG              PPC_BIT(6)
341c76c0d30SSuraj Jitindar Singh #define H_CPU_CHAR_CACHE_COUNT_DIS              PPC_BIT(7)
3428acc2ae5SSuraj Jitindar Singh #define H_CPU_BEHAV_FAVOUR_SECURITY             PPC_BIT(0)
3438acc2ae5SSuraj Jitindar Singh #define H_CPU_BEHAV_L1D_FLUSH_PR                PPC_BIT(1)
3448acc2ae5SSuraj Jitindar Singh #define H_CPU_BEHAV_BNDS_CHK_SPEC_BAR           PPC_BIT(2)
3458acc2ae5SSuraj Jitindar Singh 
34666a0a2cbSDong Xu Wang /* Each control block has to be on a 4K boundary */
3479fdf0c29SDavid Gibson #define H_CB_ALIGNMENT     4096
3489fdf0c29SDavid Gibson 
3499fdf0c29SDavid Gibson /* pSeries hypervisor opcodes */
3509fdf0c29SDavid Gibson #define H_REMOVE                0x04
3519fdf0c29SDavid Gibson #define H_ENTER                 0x08
3529fdf0c29SDavid Gibson #define H_READ                  0x0c
3539fdf0c29SDavid Gibson #define H_CLEAR_MOD             0x10
3549fdf0c29SDavid Gibson #define H_CLEAR_REF             0x14
3559fdf0c29SDavid Gibson #define H_PROTECT               0x18
3569fdf0c29SDavid Gibson #define H_GET_TCE               0x1c
3579fdf0c29SDavid Gibson #define H_PUT_TCE               0x20
3589fdf0c29SDavid Gibson #define H_SET_SPRG0             0x24
3599fdf0c29SDavid Gibson #define H_SET_DABR              0x28
3609fdf0c29SDavid Gibson #define H_PAGE_INIT             0x2c
3619fdf0c29SDavid Gibson #define H_SET_ASR               0x30
3629fdf0c29SDavid Gibson #define H_ASR_ON                0x34
3639fdf0c29SDavid Gibson #define H_ASR_OFF               0x38
3649fdf0c29SDavid Gibson #define H_LOGICAL_CI_LOAD       0x3c
3659fdf0c29SDavid Gibson #define H_LOGICAL_CI_STORE      0x40
3669fdf0c29SDavid Gibson #define H_LOGICAL_CACHE_LOAD    0x44
3679fdf0c29SDavid Gibson #define H_LOGICAL_CACHE_STORE   0x48
3689fdf0c29SDavid Gibson #define H_LOGICAL_ICBI          0x4c
3699fdf0c29SDavid Gibson #define H_LOGICAL_DCBF          0x50
3709fdf0c29SDavid Gibson #define H_GET_TERM_CHAR         0x54
3719fdf0c29SDavid Gibson #define H_PUT_TERM_CHAR         0x58
3729fdf0c29SDavid Gibson #define H_REAL_TO_LOGICAL       0x5c
3739fdf0c29SDavid Gibson #define H_HYPERVISOR_DATA       0x60
3749fdf0c29SDavid Gibson #define H_EOI                   0x64
3759fdf0c29SDavid Gibson #define H_CPPR                  0x68
3769fdf0c29SDavid Gibson #define H_IPI                   0x6c
3779fdf0c29SDavid Gibson #define H_IPOLL                 0x70
3789fdf0c29SDavid Gibson #define H_XIRR                  0x74
3799fdf0c29SDavid Gibson #define H_PERFMON               0x7c
3809fdf0c29SDavid Gibson #define H_MIGRATE_DMA           0x78
3819fdf0c29SDavid Gibson #define H_REGISTER_VPA          0xDC
3829fdf0c29SDavid Gibson #define H_CEDE                  0xE0
3839fdf0c29SDavid Gibson #define H_CONFER                0xE4
3849fdf0c29SDavid Gibson #define H_PROD                  0xE8
3859fdf0c29SDavid Gibson #define H_GET_PPP               0xEC
3869fdf0c29SDavid Gibson #define H_SET_PPP               0xF0
3879fdf0c29SDavid Gibson #define H_PURR                  0xF4
3889fdf0c29SDavid Gibson #define H_PIC                   0xF8
3899fdf0c29SDavid Gibson #define H_REG_CRQ               0xFC
3909fdf0c29SDavid Gibson #define H_FREE_CRQ              0x100
3919fdf0c29SDavid Gibson #define H_VIO_SIGNAL            0x104
3929fdf0c29SDavid Gibson #define H_SEND_CRQ              0x108
3939fdf0c29SDavid Gibson #define H_COPY_RDMA             0x110
3949fdf0c29SDavid Gibson #define H_REGISTER_LOGICAL_LAN  0x114
3959fdf0c29SDavid Gibson #define H_FREE_LOGICAL_LAN      0x118
3969fdf0c29SDavid Gibson #define H_ADD_LOGICAL_LAN_BUFFER 0x11C
3979fdf0c29SDavid Gibson #define H_SEND_LOGICAL_LAN      0x120
3989fdf0c29SDavid Gibson #define H_BULK_REMOVE           0x124
3999fdf0c29SDavid Gibson #define H_MULTICAST_CTRL        0x130
4009fdf0c29SDavid Gibson #define H_SET_XDABR             0x134
4019fdf0c29SDavid Gibson #define H_STUFF_TCE             0x138
4029fdf0c29SDavid Gibson #define H_PUT_TCE_INDIRECT      0x13C
4039fdf0c29SDavid Gibson #define H_CHANGE_LOGICAL_LAN_MAC 0x14C
4049fdf0c29SDavid Gibson #define H_VTERM_PARTNER_INFO    0x150
4059fdf0c29SDavid Gibson #define H_REGISTER_VTERM        0x154
4069fdf0c29SDavid Gibson #define H_FREE_VTERM            0x158
4079fdf0c29SDavid Gibson #define H_RESET_EVENTS          0x15C
4089fdf0c29SDavid Gibson #define H_ALLOC_RESOURCE        0x160
4099fdf0c29SDavid Gibson #define H_FREE_RESOURCE         0x164
4109fdf0c29SDavid Gibson #define H_MODIFY_QP             0x168
4119fdf0c29SDavid Gibson #define H_QUERY_QP              0x16C
4129fdf0c29SDavid Gibson #define H_REREGISTER_PMR        0x170
4139fdf0c29SDavid Gibson #define H_REGISTER_SMR          0x174
4149fdf0c29SDavid Gibson #define H_QUERY_MR              0x178
4159fdf0c29SDavid Gibson #define H_QUERY_MW              0x17C
4169fdf0c29SDavid Gibson #define H_QUERY_HCA             0x180
4179fdf0c29SDavid Gibson #define H_QUERY_PORT            0x184
4189fdf0c29SDavid Gibson #define H_MODIFY_PORT           0x188
4199fdf0c29SDavid Gibson #define H_DEFINE_AQP1           0x18C
4209fdf0c29SDavid Gibson #define H_GET_TRACE_BUFFER      0x190
4219fdf0c29SDavid Gibson #define H_DEFINE_AQP0           0x194
4229fdf0c29SDavid Gibson #define H_RESIZE_MR             0x198
4239fdf0c29SDavid Gibson #define H_ATTACH_MCQP           0x19C
4249fdf0c29SDavid Gibson #define H_DETACH_MCQP           0x1A0
4259fdf0c29SDavid Gibson #define H_CREATE_RPT            0x1A4
4269fdf0c29SDavid Gibson #define H_REMOVE_RPT            0x1A8
4279fdf0c29SDavid Gibson #define H_REGISTER_RPAGES       0x1AC
4289fdf0c29SDavid Gibson #define H_DISABLE_AND_GETC      0x1B0
4299fdf0c29SDavid Gibson #define H_ERROR_DATA            0x1B4
4309fdf0c29SDavid Gibson #define H_GET_HCA_INFO          0x1B8
4319fdf0c29SDavid Gibson #define H_GET_PERF_COUNT        0x1BC
4329fdf0c29SDavid Gibson #define H_MANAGE_TRACE          0x1C0
433c59704b2SSuraj Jitindar Singh #define H_GET_CPU_CHARACTERISTICS 0x1C8
4349fdf0c29SDavid Gibson #define H_FREE_LOGICAL_LAN_BUFFER 0x1D4
4359fdf0c29SDavid Gibson #define H_QUERY_INT_STATE       0x1E4
4369fdf0c29SDavid Gibson #define H_POLL_PENDING          0x1D8
4379fdf0c29SDavid Gibson #define H_ILLAN_ATTRIBUTES      0x244
4389fdf0c29SDavid Gibson #define H_MODIFY_HEA_QP         0x250
4399fdf0c29SDavid Gibson #define H_QUERY_HEA_QP          0x254
4409fdf0c29SDavid Gibson #define H_QUERY_HEA             0x258
4419fdf0c29SDavid Gibson #define H_QUERY_HEA_PORT        0x25C
4429fdf0c29SDavid Gibson #define H_MODIFY_HEA_PORT       0x260
4439fdf0c29SDavid Gibson #define H_REG_BCMC              0x264
4449fdf0c29SDavid Gibson #define H_DEREG_BCMC            0x268
4459fdf0c29SDavid Gibson #define H_REGISTER_HEA_RPAGES   0x26C
4469fdf0c29SDavid Gibson #define H_DISABLE_AND_GET_HEA   0x270
4479fdf0c29SDavid Gibson #define H_GET_HEA_INFO          0x274
4489fdf0c29SDavid Gibson #define H_ALLOC_HEA_RESOURCE    0x278
4499fdf0c29SDavid Gibson #define H_ADD_CONN              0x284
4509fdf0c29SDavid Gibson #define H_DEL_CONN              0x288
4519fdf0c29SDavid Gibson #define H_JOIN                  0x298
4529fdf0c29SDavid Gibson #define H_VASI_STATE            0x2A4
4539fdf0c29SDavid Gibson #define H_ENABLE_CRQ            0x2B0
4549fdf0c29SDavid Gibson #define H_GET_EM_PARMS          0x2B8
4559fdf0c29SDavid Gibson #define H_SET_MPP               0x2D0
4569fdf0c29SDavid Gibson #define H_GET_MPP               0x2D4
457c24ba3d0SLaurent Vivier #define H_HOME_NODE_ASSOCIATIVITY 0x2EC
4585d87e4b7SBenjamin Herrenschmidt #define H_XIRR_X                0x2FC
4594d9392beSThomas Huth #define H_RANDOM                0x300
46042561bf2SAnton Blanchard #define H_SET_MODE              0x31C
46130f4b05bSDavid Gibson #define H_RESIZE_HPT_PREPARE    0x36C
46230f4b05bSDavid Gibson #define H_RESIZE_HPT_COMMIT     0x370
463d77a98b0SSuraj Jitindar Singh #define H_CLEAN_SLB             0x374
464d77a98b0SSuraj Jitindar Singh #define H_INVALIDATE_PID        0x378
465d77a98b0SSuraj Jitindar Singh #define H_REGISTER_PROC_TBL     0x37C
4661c7ad77eSNicholas Piggin #define H_SIGNAL_SYS_RESET      0x380
46723bcd5ebSCédric Le Goater 
46823bcd5ebSCédric Le Goater #define H_INT_GET_SOURCE_INFO   0x3A8
46923bcd5ebSCédric Le Goater #define H_INT_SET_SOURCE_CONFIG 0x3AC
47023bcd5ebSCédric Le Goater #define H_INT_GET_SOURCE_CONFIG 0x3B0
47123bcd5ebSCédric Le Goater #define H_INT_GET_QUEUE_INFO    0x3B4
47223bcd5ebSCédric Le Goater #define H_INT_SET_QUEUE_CONFIG  0x3B8
47323bcd5ebSCédric Le Goater #define H_INT_GET_QUEUE_CONFIG  0x3BC
47423bcd5ebSCédric Le Goater #define H_INT_SET_OS_REPORTING_LINE 0x3C0
47523bcd5ebSCédric Le Goater #define H_INT_GET_OS_REPORTING_LINE 0x3C4
47623bcd5ebSCédric Le Goater #define H_INT_ESB               0x3C8
47723bcd5ebSCédric Le Goater #define H_INT_SYNC              0x3CC
47823bcd5ebSCédric Le Goater #define H_INT_RESET             0x3D0
47923bcd5ebSCédric Le Goater 
48023bcd5ebSCédric Le Goater #define MAX_HCALL_OPCODE        H_INT_RESET
4819fdf0c29SDavid Gibson 
48239ac8455SDavid Gibson /* The hcalls above are standardized in PAPR and implemented by pHyp
48339ac8455SDavid Gibson  * as well.
48439ac8455SDavid Gibson  *
48539ac8455SDavid Gibson  * We also need some hcalls which are specific to qemu / KVM-on-POWER.
486498cd995SGreg Kurz  * We put those into the 0xf000-0xfffc range which is reserved by PAPR
487498cd995SGreg Kurz  * for "platform-specific" hcalls.
48839ac8455SDavid Gibson  */
48939ac8455SDavid Gibson #define KVMPPC_HCALL_BASE       0xf000
49039ac8455SDavid Gibson #define KVMPPC_H_RTAS           (KVMPPC_HCALL_BASE + 0x0)
491c73e3771SBenjamin Herrenschmidt #define KVMPPC_H_LOGICAL_MEMOP  (KVMPPC_HCALL_BASE + 0x1)
4922a6593cbSAlexey Kardashevskiy /* Client Architecture support */
4932a6593cbSAlexey Kardashevskiy #define KVMPPC_H_CAS            (KVMPPC_HCALL_BASE + 0x2)
494fea35ca4SAlexey Kardashevskiy #define KVMPPC_H_UPDATE_DT      (KVMPPC_HCALL_BASE + 0x3)
495fea35ca4SAlexey Kardashevskiy #define KVMPPC_HCALL_MAX        KVMPPC_H_UPDATE_DT
49639ac8455SDavid Gibson 
4972a6593cbSAlexey Kardashevskiy typedef struct sPAPRDeviceTreeUpdateHeader {
4982a6593cbSAlexey Kardashevskiy     uint32_t version_id;
4992a6593cbSAlexey Kardashevskiy } sPAPRDeviceTreeUpdateHeader;
5002a6593cbSAlexey Kardashevskiy 
5019fdf0c29SDavid Gibson #define hcall_dprintf(fmt, ...) \
502aaf87c66SThomas Huth     do { \
503aaf87c66SThomas Huth         qemu_log_mask(LOG_GUEST_ERROR, "%s: " fmt, __func__, ## __VA_ARGS__); \
504aaf87c66SThomas Huth     } while (0)
5059fdf0c29SDavid Gibson 
50628e02042SDavid Gibson typedef target_ulong (*spapr_hcall_fn)(PowerPCCPU *cpu, sPAPRMachineState *sm,
5079fdf0c29SDavid Gibson                                        target_ulong opcode,
5089fdf0c29SDavid Gibson                                        target_ulong *args);
5099fdf0c29SDavid Gibson 
5109fdf0c29SDavid Gibson void spapr_register_hypercall(target_ulong opcode, spapr_hcall_fn fn);
511aa100fa4SAndreas Färber target_ulong spapr_hypercall(PowerPCCPU *cpu, target_ulong opcode,
5129fdf0c29SDavid Gibson                              target_ulong *args);
5139fdf0c29SDavid Gibson 
514ee954280SGavin Shan /* ibm,set-eeh-option */
515ee954280SGavin Shan #define RTAS_EEH_DISABLE                 0
516ee954280SGavin Shan #define RTAS_EEH_ENABLE                  1
517ee954280SGavin Shan #define RTAS_EEH_THAW_IO                 2
518ee954280SGavin Shan #define RTAS_EEH_THAW_DMA                3
519ee954280SGavin Shan 
520ee954280SGavin Shan /* ibm,get-config-addr-info2 */
521ee954280SGavin Shan #define RTAS_GET_PE_ADDR                 0
522ee954280SGavin Shan #define RTAS_GET_PE_MODE                 1
523ee954280SGavin Shan #define RTAS_PE_MODE_NONE                0
524ee954280SGavin Shan #define RTAS_PE_MODE_NOT_SHARED          1
525ee954280SGavin Shan #define RTAS_PE_MODE_SHARED              2
526ee954280SGavin Shan 
527ee954280SGavin Shan /* ibm,read-slot-reset-state2 */
528ee954280SGavin Shan #define RTAS_EEH_PE_STATE_NORMAL         0
529ee954280SGavin Shan #define RTAS_EEH_PE_STATE_RESET          1
530ee954280SGavin Shan #define RTAS_EEH_PE_STATE_STOPPED_IO_DMA 2
531ee954280SGavin Shan #define RTAS_EEH_PE_STATE_STOPPED_DMA    4
532ee954280SGavin Shan #define RTAS_EEH_PE_STATE_UNAVAIL        5
533ee954280SGavin Shan #define RTAS_EEH_NOT_SUPPORT             0
534ee954280SGavin Shan #define RTAS_EEH_SUPPORT                 1
535ee954280SGavin Shan #define RTAS_EEH_PE_UNAVAIL_INFO         1000
536ee954280SGavin Shan #define RTAS_EEH_PE_RECOVER_INFO         0
537ee954280SGavin Shan 
538ee954280SGavin Shan /* ibm,set-slot-reset */
539ee954280SGavin Shan #define RTAS_SLOT_RESET_DEACTIVATE       0
540ee954280SGavin Shan #define RTAS_SLOT_RESET_HOT              1
541ee954280SGavin Shan #define RTAS_SLOT_RESET_FUNDAMENTAL      3
542ee954280SGavin Shan 
543ee954280SGavin Shan /* ibm,slot-error-detail */
544ee954280SGavin Shan #define RTAS_SLOT_TEMP_ERR_LOG           1
545ee954280SGavin Shan #define RTAS_SLOT_PERM_ERR_LOG           2
546ee954280SGavin Shan 
547a64d325dSAlexey Kardashevskiy /* RTAS return codes */
548a64d325dSAlexey Kardashevskiy #define RTAS_OUT_SUCCESS                        0
549a64d325dSAlexey Kardashevskiy #define RTAS_OUT_NO_ERRORS_FOUND                1
550a64d325dSAlexey Kardashevskiy #define RTAS_OUT_HW_ERROR                       -1
551a64d325dSAlexey Kardashevskiy #define RTAS_OUT_BUSY                           -2
552a64d325dSAlexey Kardashevskiy #define RTAS_OUT_PARAM_ERROR                    -3
5533ada6b11SAlexey Kardashevskiy #define RTAS_OUT_NOT_SUPPORTED                  -3
5549d1852ceSMichael Roth #define RTAS_OUT_NO_SUCH_INDICATOR              -3
5553ada6b11SAlexey Kardashevskiy #define RTAS_OUT_NOT_AUTHORIZED                 -9002
556c920f7b4SDavid Gibson #define RTAS_OUT_SYSPARM_PARAM_ERROR            -9999
557a64d325dSAlexey Kardashevskiy 
558ae4de14cSAlexey Kardashevskiy /* DDW pagesize mask values from ibm,query-pe-dma-window */
559ae4de14cSAlexey Kardashevskiy #define RTAS_DDW_PGSIZE_4K       0x01
560ae4de14cSAlexey Kardashevskiy #define RTAS_DDW_PGSIZE_64K      0x02
561ae4de14cSAlexey Kardashevskiy #define RTAS_DDW_PGSIZE_16M      0x04
562ae4de14cSAlexey Kardashevskiy #define RTAS_DDW_PGSIZE_32M      0x08
563ae4de14cSAlexey Kardashevskiy #define RTAS_DDW_PGSIZE_64M      0x10
564ae4de14cSAlexey Kardashevskiy #define RTAS_DDW_PGSIZE_128M     0x20
565ae4de14cSAlexey Kardashevskiy #define RTAS_DDW_PGSIZE_256M     0x40
566ae4de14cSAlexey Kardashevskiy #define RTAS_DDW_PGSIZE_16G      0x80
567ae4de14cSAlexey Kardashevskiy 
5683a3b8502SAlexey Kardashevskiy /* RTAS tokens */
5693a3b8502SAlexey Kardashevskiy #define RTAS_TOKEN_BASE      0x2000
5703a3b8502SAlexey Kardashevskiy 
5713a3b8502SAlexey Kardashevskiy #define RTAS_DISPLAY_CHARACTER                  (RTAS_TOKEN_BASE + 0x00)
5723a3b8502SAlexey Kardashevskiy #define RTAS_GET_TIME_OF_DAY                    (RTAS_TOKEN_BASE + 0x01)
5733a3b8502SAlexey Kardashevskiy #define RTAS_SET_TIME_OF_DAY                    (RTAS_TOKEN_BASE + 0x02)
5743a3b8502SAlexey Kardashevskiy #define RTAS_POWER_OFF                          (RTAS_TOKEN_BASE + 0x03)
5753a3b8502SAlexey Kardashevskiy #define RTAS_SYSTEM_REBOOT                      (RTAS_TOKEN_BASE + 0x04)
5763a3b8502SAlexey Kardashevskiy #define RTAS_QUERY_CPU_STOPPED_STATE            (RTAS_TOKEN_BASE + 0x05)
5773a3b8502SAlexey Kardashevskiy #define RTAS_START_CPU                          (RTAS_TOKEN_BASE + 0x06)
5783a3b8502SAlexey Kardashevskiy #define RTAS_STOP_SELF                          (RTAS_TOKEN_BASE + 0x07)
5793a3b8502SAlexey Kardashevskiy #define RTAS_IBM_GET_SYSTEM_PARAMETER           (RTAS_TOKEN_BASE + 0x08)
5803a3b8502SAlexey Kardashevskiy #define RTAS_IBM_SET_SYSTEM_PARAMETER           (RTAS_TOKEN_BASE + 0x09)
5813a3b8502SAlexey Kardashevskiy #define RTAS_IBM_SET_XIVE                       (RTAS_TOKEN_BASE + 0x0A)
5823a3b8502SAlexey Kardashevskiy #define RTAS_IBM_GET_XIVE                       (RTAS_TOKEN_BASE + 0x0B)
5833a3b8502SAlexey Kardashevskiy #define RTAS_IBM_INT_OFF                        (RTAS_TOKEN_BASE + 0x0C)
5843a3b8502SAlexey Kardashevskiy #define RTAS_IBM_INT_ON                         (RTAS_TOKEN_BASE + 0x0D)
5853a3b8502SAlexey Kardashevskiy #define RTAS_CHECK_EXCEPTION                    (RTAS_TOKEN_BASE + 0x0E)
5863a3b8502SAlexey Kardashevskiy #define RTAS_EVENT_SCAN                         (RTAS_TOKEN_BASE + 0x0F)
5873a3b8502SAlexey Kardashevskiy #define RTAS_IBM_SET_TCE_BYPASS                 (RTAS_TOKEN_BASE + 0x10)
5883a3b8502SAlexey Kardashevskiy #define RTAS_QUIESCE                            (RTAS_TOKEN_BASE + 0x11)
5893a3b8502SAlexey Kardashevskiy #define RTAS_NVRAM_FETCH                        (RTAS_TOKEN_BASE + 0x12)
5903a3b8502SAlexey Kardashevskiy #define RTAS_NVRAM_STORE                        (RTAS_TOKEN_BASE + 0x13)
5913a3b8502SAlexey Kardashevskiy #define RTAS_READ_PCI_CONFIG                    (RTAS_TOKEN_BASE + 0x14)
5923a3b8502SAlexey Kardashevskiy #define RTAS_WRITE_PCI_CONFIG                   (RTAS_TOKEN_BASE + 0x15)
5933a3b8502SAlexey Kardashevskiy #define RTAS_IBM_READ_PCI_CONFIG                (RTAS_TOKEN_BASE + 0x16)
5943a3b8502SAlexey Kardashevskiy #define RTAS_IBM_WRITE_PCI_CONFIG               (RTAS_TOKEN_BASE + 0x17)
5953a3b8502SAlexey Kardashevskiy #define RTAS_IBM_QUERY_INTERRUPT_SOURCE_NUMBER  (RTAS_TOKEN_BASE + 0x18)
5963a3b8502SAlexey Kardashevskiy #define RTAS_IBM_CHANGE_MSI                     (RTAS_TOKEN_BASE + 0x19)
5973a3b8502SAlexey Kardashevskiy #define RTAS_SET_INDICATOR                      (RTAS_TOKEN_BASE + 0x1A)
5983a3b8502SAlexey Kardashevskiy #define RTAS_SET_POWER_LEVEL                    (RTAS_TOKEN_BASE + 0x1B)
5993a3b8502SAlexey Kardashevskiy #define RTAS_GET_POWER_LEVEL                    (RTAS_TOKEN_BASE + 0x1C)
6003a3b8502SAlexey Kardashevskiy #define RTAS_GET_SENSOR_STATE                   (RTAS_TOKEN_BASE + 0x1D)
6013a3b8502SAlexey Kardashevskiy #define RTAS_IBM_CONFIGURE_CONNECTOR            (RTAS_TOKEN_BASE + 0x1E)
6023a3b8502SAlexey Kardashevskiy #define RTAS_IBM_OS_TERM                        (RTAS_TOKEN_BASE + 0x1F)
603ee954280SGavin Shan #define RTAS_IBM_SET_EEH_OPTION                 (RTAS_TOKEN_BASE + 0x20)
604ee954280SGavin Shan #define RTAS_IBM_GET_CONFIG_ADDR_INFO2          (RTAS_TOKEN_BASE + 0x21)
605ee954280SGavin Shan #define RTAS_IBM_READ_SLOT_RESET_STATE2         (RTAS_TOKEN_BASE + 0x22)
606ee954280SGavin Shan #define RTAS_IBM_SET_SLOT_RESET                 (RTAS_TOKEN_BASE + 0x23)
607ee954280SGavin Shan #define RTAS_IBM_CONFIGURE_PE                   (RTAS_TOKEN_BASE + 0x24)
608ee954280SGavin Shan #define RTAS_IBM_SLOT_ERROR_DETAIL              (RTAS_TOKEN_BASE + 0x25)
609ae4de14cSAlexey Kardashevskiy #define RTAS_IBM_QUERY_PE_DMA_WINDOW            (RTAS_TOKEN_BASE + 0x26)
610ae4de14cSAlexey Kardashevskiy #define RTAS_IBM_CREATE_PE_DMA_WINDOW           (RTAS_TOKEN_BASE + 0x27)
611ae4de14cSAlexey Kardashevskiy #define RTAS_IBM_REMOVE_PE_DMA_WINDOW           (RTAS_TOKEN_BASE + 0x28)
612ae4de14cSAlexey Kardashevskiy #define RTAS_IBM_RESET_PE_DMA_WINDOW            (RTAS_TOKEN_BASE + 0x29)
6133a3b8502SAlexey Kardashevskiy 
614ae4de14cSAlexey Kardashevskiy #define RTAS_TOKEN_MAX                          (RTAS_TOKEN_BASE + 0x2A)
6153a3b8502SAlexey Kardashevskiy 
6163052d951SSam bobroff /* RTAS ibm,get-system-parameter token values */
6173b50d897SSam bobroff #define RTAS_SYSPARM_SPLPAR_CHARACTERISTICS      20
6183052d951SSam bobroff #define RTAS_SYSPARM_DIAGNOSTICS_RUN_MODE        42
619b907d7b0SSam bobroff #define RTAS_SYSPARM_UUID                        48
6203052d951SSam bobroff 
6218c8639dfSMike Day /* RTAS indicator/sensor types
6228c8639dfSMike Day  *
6238c8639dfSMike Day  * as defined by PAPR+ 2.7 7.3.5.4, Table 41
6248c8639dfSMike Day  *
6258c8639dfSMike Day  * NOTE: currently only DR-related sensors are implemented here
6268c8639dfSMike Day  */
6278c8639dfSMike Day #define RTAS_SENSOR_TYPE_ISOLATION_STATE        9001
6288c8639dfSMike Day #define RTAS_SENSOR_TYPE_DR                     9002
6298c8639dfSMike Day #define RTAS_SENSOR_TYPE_ALLOCATION_STATE       9003
6308c8639dfSMike Day #define RTAS_SENSOR_TYPE_ENTITY_SENSE RTAS_SENSOR_TYPE_ALLOCATION_STATE
6318c8639dfSMike Day 
6323052d951SSam bobroff /* Possible values for the platform-processor-diagnostics-run-mode parameter
6333052d951SSam bobroff  * of the RTAS ibm,get-system-parameter call.
6343052d951SSam bobroff  */
6353052d951SSam bobroff #define DIAGNOSTICS_RUN_MODE_DISABLED  0
6363052d951SSam bobroff #define DIAGNOSTICS_RUN_MODE_STAGGERED 1
6373052d951SSam bobroff #define DIAGNOSTICS_RUN_MODE_IMMEDIATE 2
6383052d951SSam bobroff #define DIAGNOSTICS_RUN_MODE_PERIODIC  3
6393052d951SSam bobroff 
6404fe822e0SAlexey Kardashevskiy static inline uint64_t ppc64_phys_to_real(uint64_t addr)
6414fe822e0SAlexey Kardashevskiy {
6424fe822e0SAlexey Kardashevskiy     return addr & ~0xF000000000000000ULL;
6434fe822e0SAlexey Kardashevskiy }
6444fe822e0SAlexey Kardashevskiy 
64539ac8455SDavid Gibson static inline uint32_t rtas_ld(target_ulong phys, int n)
64639ac8455SDavid Gibson {
647fdfba1a2SEdgar E. Iglesias     return ldl_be_phys(&address_space_memory, ppc64_phys_to_real(phys + 4*n));
64839ac8455SDavid Gibson }
64939ac8455SDavid Gibson 
650a14aa92bSGavin Shan static inline uint64_t rtas_ldq(target_ulong phys, int n)
651a14aa92bSGavin Shan {
652a14aa92bSGavin Shan     return (uint64_t)rtas_ld(phys, n) << 32 | rtas_ld(phys, n + 1);
653a14aa92bSGavin Shan }
654a14aa92bSGavin Shan 
65539ac8455SDavid Gibson static inline void rtas_st(target_ulong phys, int n, uint32_t val)
65639ac8455SDavid Gibson {
657ab1da857SEdgar E. Iglesias     stl_be_phys(&address_space_memory, ppc64_phys_to_real(phys + 4*n), val);
65839ac8455SDavid Gibson }
65939ac8455SDavid Gibson 
66028e02042SDavid Gibson typedef void (*spapr_rtas_fn)(PowerPCCPU *cpu, sPAPRMachineState *sm,
661210b580bSAnthony Liguori                               uint32_t token,
66239ac8455SDavid Gibson                               uint32_t nargs, target_ulong args,
66339ac8455SDavid Gibson                               uint32_t nret, target_ulong rets);
6643a3b8502SAlexey Kardashevskiy void spapr_rtas_register(int token, const char *name, spapr_rtas_fn fn);
66528e02042SDavid Gibson target_ulong spapr_rtas_call(PowerPCCPU *cpu, sPAPRMachineState *sm,
66639ac8455SDavid Gibson                              uint32_t token, uint32_t nargs, target_ulong args,
66739ac8455SDavid Gibson                              uint32_t nret, target_ulong rets);
6683f5dabceSDavid Gibson void spapr_dt_rtas_tokens(void *fdt, int rtas);
6692cac78c1SDavid Gibson void spapr_load_rtas(sPAPRMachineState *spapr, void *fdt, hwaddr addr);
67039ac8455SDavid Gibson 
671ad0ebb91SDavid Gibson #define SPAPR_TCE_PAGE_SHIFT   12
672ad0ebb91SDavid Gibson #define SPAPR_TCE_PAGE_SIZE    (1ULL << SPAPR_TCE_PAGE_SHIFT)
673ad0ebb91SDavid Gibson #define SPAPR_TCE_PAGE_MASK    (SPAPR_TCE_PAGE_SIZE - 1)
674ad0ebb91SDavid Gibson 
675ad0ebb91SDavid Gibson #define SPAPR_VIO_BASE_LIOBN    0x00000000
6764290ca49SAlexey Kardashevskiy #define SPAPR_VIO_LIOBN(reg)    (0x00000000 | (reg))
677c8545818SAlexey Kardashevskiy #define SPAPR_PCI_LIOBN(phb_index, window_num) \
678c8545818SAlexey Kardashevskiy     (0x80000000 | ((phb_index) << 8) | (window_num))
679d9d96a3cSAlexey Kardashevskiy #define SPAPR_IS_PCI_LIOBN(liobn)   (!!((liobn) & 0x80000000))
680c8545818SAlexey Kardashevskiy #define SPAPR_PCI_DMA_WINDOW_NUM(liobn) ((liobn) & 0xff)
681ad0ebb91SDavid Gibson 
68274d042e5SDavid Gibson #define RTAS_ERROR_LOG_MAX      2048
68374d042e5SDavid Gibson 
68479853e18STyrel Datwyler #define RTAS_EVENT_SCAN_RATE    1
68579853e18STyrel Datwyler 
686bb2d8ab6SGreg Kurz /* This helper should be used to encode interrupt specifiers when the related
687bb2d8ab6SGreg Kurz  * "interrupt-controller" node has its "#interrupt-cells" property set to 2 (ie,
688bb2d8ab6SGreg Kurz  * VIO devices, RTAS event sources and PHBs).
689bb2d8ab6SGreg Kurz  */
6905c7adcf4SGreg Kurz static inline void spapr_dt_irq(uint32_t *intspec, int irq, bool is_lsi)
691bb2d8ab6SGreg Kurz {
692bb2d8ab6SGreg Kurz     intspec[0] = cpu_to_be32(irq);
693bb2d8ab6SGreg Kurz     intspec[1] = is_lsi ? cpu_to_be32(1) : 0;
694bb2d8ab6SGreg Kurz }
695bb2d8ab6SGreg Kurz 
6962b7dc949SPaolo Bonzini typedef struct sPAPRTCETable sPAPRTCETable;
69774d042e5SDavid Gibson 
698a83000f5SAnthony Liguori #define TYPE_SPAPR_TCE_TABLE "spapr-tce-table"
699a83000f5SAnthony Liguori #define SPAPR_TCE_TABLE(obj) \
700a83000f5SAnthony Liguori     OBJECT_CHECK(sPAPRTCETable, (obj), TYPE_SPAPR_TCE_TABLE)
701a83000f5SAnthony Liguori 
7021221a474SAlexey Kardashevskiy #define TYPE_SPAPR_IOMMU_MEMORY_REGION "spapr-iommu-memory-region"
7031221a474SAlexey Kardashevskiy #define SPAPR_IOMMU_MEMORY_REGION(obj) \
7041221a474SAlexey Kardashevskiy         OBJECT_CHECK(IOMMUMemoryRegion, (obj), TYPE_SPAPR_IOMMU_MEMORY_REGION)
7051221a474SAlexey Kardashevskiy 
706a83000f5SAnthony Liguori struct sPAPRTCETable {
707a83000f5SAnthony Liguori     DeviceState parent;
708a83000f5SAnthony Liguori     uint32_t liobn;
709a83000f5SAnthony Liguori     uint32_t nb_table;
7101b8eceeeSAlexey Kardashevskiy     uint64_t bus_offset;
711650f33adSAlexey Kardashevskiy     uint32_t page_shift;
712a83000f5SAnthony Liguori     uint64_t *table;
713a26fdf39SAlexey Kardashevskiy     uint32_t mig_nb_table;
714a26fdf39SAlexey Kardashevskiy     uint64_t *mig_table;
715a83000f5SAnthony Liguori     bool bypass;
7166a81dd17SDavid Gibson     bool need_vfio;
717a83000f5SAnthony Liguori     int fd;
7183df9d748SAlexey Kardashevskiy     MemoryRegion root;
7193df9d748SAlexey Kardashevskiy     IOMMUMemoryRegion iommu;
720ee9a569aSAlexey Kardashevskiy     struct VIOsPAPRDevice *vdev; /* for @bypass migration compatibility only */
721a83000f5SAnthony Liguori     QLIST_ENTRY(sPAPRTCETable) list;
722a83000f5SAnthony Liguori };
723a83000f5SAnthony Liguori 
724f9ce8e0aSThomas Huth sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn);
72531fe14d1SNathan Fontenot 
7265341258eSDavid Gibson struct sPAPREventLogEntry {
727fd38804bSDaniel Henrique Barboza     uint32_t summary;
728fd38804bSDaniel Henrique Barboza     uint32_t extended_length;
729fd38804bSDaniel Henrique Barboza     void *extended_log;
73031fe14d1SNathan Fontenot     QTAILQ_ENTRY(sPAPREventLogEntry) next;
73131fe14d1SNathan Fontenot };
73231fe14d1SNathan Fontenot 
73328e02042SDavid Gibson void spapr_events_init(sPAPRMachineState *sm);
734ffbb1705SMichael Roth void spapr_dt_events(sPAPRMachineState *sm, void *fdt);
73528e02042SDavid Gibson int spapr_h_cas_compose_response(sPAPRMachineState *sm,
73603d196b7SBharata B Rao                                  target_ulong addr, target_ulong size,
7376787d27bSMichael Roth                                  sPAPROptionVector *ov5_updates);
738b4db5413SSuraj Jitindar Singh void close_htab_fd(sPAPRMachineState *spapr);
739b4db5413SSuraj Jitindar Singh void spapr_setup_hpt_and_vrma(sPAPRMachineState *spapr);
74006ec79e8SBharata B Rao void spapr_free_hpt(sPAPRMachineState *spapr);
741df7625d4SAlexey Kardashevskiy sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn);
742df7625d4SAlexey Kardashevskiy void spapr_tce_table_enable(sPAPRTCETable *tcet,
743df7625d4SAlexey Kardashevskiy                             uint32_t page_shift, uint64_t bus_offset,
744df7625d4SAlexey Kardashevskiy                             uint32_t nb_table);
745a26fdf39SAlexey Kardashevskiy void spapr_tce_table_disable(sPAPRTCETable *tcet);
746c10325d6SDavid Gibson void spapr_tce_set_need_vfio(sPAPRTCETable *tcet, bool need_vfio);
747c10325d6SDavid Gibson 
748a84bb436SPaolo Bonzini MemoryRegion *spapr_tce_get_iommu(sPAPRTCETable *tcet);
749ad0ebb91SDavid Gibson int spapr_dma_dt(void *fdt, int node_off, const char *propname,
7505c4cbcf2SAlexey Kardashevskiy                  uint32_t liobn, uint64_t window, uint32_t size);
7515c4cbcf2SAlexey Kardashevskiy int spapr_tcet_dma_dt(void *fdt, int node_off, const char *propname,
7522b7dc949SPaolo Bonzini                       sPAPRTCETable *tcet);
753eefaccc0SDavid Gibson void spapr_pci_switch_vga(bool big_endian);
7547a36ae7aSBharata B Rao void spapr_hotplug_req_add_by_index(sPAPRDRConnector *drc);
7557a36ae7aSBharata B Rao void spapr_hotplug_req_remove_by_index(sPAPRDRConnector *drc);
7567a36ae7aSBharata B Rao void spapr_hotplug_req_add_by_count(sPAPRDRConnectorType drc_type,
7577a36ae7aSBharata B Rao                                        uint32_t count);
7587a36ae7aSBharata B Rao void spapr_hotplug_req_remove_by_count(sPAPRDRConnectorType drc_type,
7597a36ae7aSBharata B Rao                                           uint32_t count);
760afdbd403SBharata B Rao void spapr_hotplug_req_add_by_count_indexed(sPAPRDRConnectorType drc_type,
761afdbd403SBharata B Rao                                             uint32_t count, uint32_t index);
762afdbd403SBharata B Rao void spapr_hotplug_req_remove_by_count_indexed(sPAPRDRConnectorType drc_type,
763afdbd403SBharata B Rao                                                uint32_t count, uint32_t index);
7640b0b8310SDavid Gibson int spapr_hpt_shift_for_ramsize(uint64_t ramsize);
7652772cf6bSDavid Gibson void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift,
7662772cf6bSDavid Gibson                           Error **errp);
76756258174SDaniel Henrique Barboza void spapr_clear_pending_events(sPAPRMachineState *spapr);
7681a518e76SCédric Le Goater int spapr_max_server_number(sPAPRMachineState *spapr);
76928df36a1SDavid Gibson 
77062d38c9bSGreg Kurz /* DRC callbacks. */
77131834723SDaniel Henrique Barboza void spapr_core_release(DeviceState *dev);
772345b12b9SGreg Kurz int spapr_core_dt_populate(sPAPRDRConnector *drc, sPAPRMachineState *spapr,
773345b12b9SGreg Kurz                            void *fdt, int *fdt_start_offset, Error **errp);
77431834723SDaniel Henrique Barboza void spapr_lmb_release(DeviceState *dev);
77562d38c9bSGreg Kurz int spapr_lmb_dt_populate(sPAPRDRConnector *drc, sPAPRMachineState *spapr,
77662d38c9bSGreg Kurz                           void *fdt, int *fdt_start_offset, Error **errp);
777bb2bdd81SGreg Kurz void spapr_phb_release(DeviceState *dev);
778bb2bdd81SGreg Kurz int spapr_phb_dt_populate(sPAPRDRConnector *drc, sPAPRMachineState *spapr,
779bb2bdd81SGreg Kurz                           void *fdt, int *fdt_start_offset, Error **errp);
78031834723SDaniel Henrique Barboza 
781147ff807SCédric Le Goater void spapr_rtc_read(sPAPRRTCState *rtc, struct tm *tm, uint32_t *ns);
782147ff807SCédric Le Goater int spapr_rtc_import_offset(sPAPRRTCState *rtc, int64_t legacy_offset);
78328df36a1SDavid Gibson 
784147ff807SCédric Le Goater #define TYPE_SPAPR_RNG "spapr-rng"
785ad0ebb91SDavid Gibson 
786db4ef288SBharata B Rao #define SPAPR_MEMORY_BLOCK_SIZE (1 << 28) /* 256MB */
787db4ef288SBharata B Rao 
7884a1c9cf0SBharata B Rao /*
7894a1c9cf0SBharata B Rao  * This defines the maximum number of DIMM slots we can have for sPAPR
7904a1c9cf0SBharata B Rao  * guest. This is not defined by sPAPR but we are defining it to 32 slots
7914a1c9cf0SBharata B Rao  * based on default number of slots provided by PowerPC kernel.
7924a1c9cf0SBharata B Rao  */
7934a1c9cf0SBharata B Rao #define SPAPR_MAX_RAM_SLOTS     32
7944a1c9cf0SBharata B Rao 
795ab3dd749SPhilippe Mathieu-Daudé /* 1GB alignment for hotplug memory region */
796ab3dd749SPhilippe Mathieu-Daudé #define SPAPR_DEVICE_MEM_ALIGN (1 * GiB)
7974a1c9cf0SBharata B Rao 
79803d196b7SBharata B Rao /*
79903d196b7SBharata B Rao  * Number of 32 bit words in each LMB list entry in ibm,dynamic-memory
80003d196b7SBharata B Rao  * property under ibm,dynamic-reconfiguration-memory node.
80103d196b7SBharata B Rao  */
80203d196b7SBharata B Rao #define SPAPR_DR_LMB_LIST_ENTRY_SIZE 6
80303d196b7SBharata B Rao 
80403d196b7SBharata B Rao /*
805d0e5a8f2SBharata B Rao  * Defines for flag value in ibm,dynamic-memory property under
806d0e5a8f2SBharata B Rao  * ibm,dynamic-reconfiguration-memory node.
80703d196b7SBharata B Rao  */
80803d196b7SBharata B Rao #define SPAPR_LMB_FLAGS_ASSIGNED 0x00000008
809d0e5a8f2SBharata B Rao #define SPAPR_LMB_FLAGS_DRC_INVALID 0x00000020
810d0e5a8f2SBharata B Rao #define SPAPR_LMB_FLAGS_RESERVED 0x00000080
81103d196b7SBharata B Rao 
8121c7ad77eSNicholas Piggin void spapr_do_system_reset_on_cpu(CPUState *cs, run_on_cpu_data arg);
8131c7ad77eSNicholas Piggin 
8140b0b8310SDavid Gibson #define HTAB_SIZE(spapr)        (1ULL << ((spapr)->htab_shift))
8150b0b8310SDavid Gibson 
81614bb4486SGreg Kurz int spapr_get_vcpu_id(PowerPCCPU *cpu);
817648edb64SGreg Kurz void spapr_set_vcpu_id(PowerPCCPU *cpu, int cpu_index, Error **errp);
8182e886fb3SSam Bobroff PowerPCCPU *spapr_find_cpu(int vcpu_id);
8192e886fb3SSam Bobroff 
8204e5fe368SSuraj Jitindar Singh int spapr_caps_pre_load(void *opaque);
8214e5fe368SSuraj Jitindar Singh int spapr_caps_pre_save(void *opaque);
8224e5fe368SSuraj Jitindar Singh 
82333face6bSDavid Gibson /*
82433face6bSDavid Gibson  * Handling of optional capabilities
82533face6bSDavid Gibson  */
8264e5fe368SSuraj Jitindar Singh extern const VMStateDescription vmstate_spapr_cap_htm;
8274e5fe368SSuraj Jitindar Singh extern const VMStateDescription vmstate_spapr_cap_vsx;
8284e5fe368SSuraj Jitindar Singh extern const VMStateDescription vmstate_spapr_cap_dfp;
8298f38eaf8SSuraj Jitindar Singh extern const VMStateDescription vmstate_spapr_cap_cfpc;
83009114fd8SSuraj Jitindar Singh extern const VMStateDescription vmstate_spapr_cap_sbbc;
8314be8d4e7SSuraj Jitindar Singh extern const VMStateDescription vmstate_spapr_cap_ibs;
832b9a477b7SSuraj Jitindar Singh extern const VMStateDescription vmstate_spapr_cap_nested_kvm_hv;
833*c982f5cfSSuraj Jitindar Singh extern const VMStateDescription vmstate_spapr_cap_large_decr;
834be85537dSDavid Gibson 
8354e5fe368SSuraj Jitindar Singh static inline uint8_t spapr_get_cap(sPAPRMachineState *spapr, int cap)
83633face6bSDavid Gibson {
8374e5fe368SSuraj Jitindar Singh     return spapr->eff.caps[cap];
83833face6bSDavid Gibson }
83933face6bSDavid Gibson 
8409f6edd06SDavid Gibson void spapr_caps_init(sPAPRMachineState *spapr);
8419f6edd06SDavid Gibson void spapr_caps_apply(sPAPRMachineState *spapr);
842e2e4f641SDavid Gibson void spapr_caps_cpu_apply(sPAPRMachineState *spapr, PowerPCCPU *cpu);
84333face6bSDavid Gibson void spapr_caps_add_properties(sPAPRMachineClass *smc, Error **errp);
844be85537dSDavid Gibson int spapr_caps_post_migration(sPAPRMachineState *spapr);
84533face6bSDavid Gibson 
846123eec65SDavid Gibson void spapr_check_pagesize(sPAPRMachineState *spapr, hwaddr pagesize,
847123eec65SDavid Gibson                           Error **errp);
848db592b5bSCédric Le Goater /*
849db592b5bSCédric Le Goater  * XIVE definitions
850db592b5bSCédric Le Goater  */
851db592b5bSCédric Le Goater #define SPAPR_OV5_XIVE_LEGACY   0x0
852db592b5bSCédric Le Goater #define SPAPR_OV5_XIVE_EXPLOIT  0x40
853db592b5bSCédric Le Goater #define SPAPR_OV5_XIVE_BOTH     0x80 /* Only to advertise on the platform */
854123eec65SDavid Gibson 
85500fd075eSBenjamin Herrenschmidt void spapr_set_all_lpcrs(target_ulong value, target_ulong mask);
8562a6a4076SMarkus Armbruster #endif /* HW_SPAPR_H */
857