summaryrefslogtreecommitdiffstats
path: root/include/hw/ppc/spapr.h
diff options
context:
space:
mode:
authorDavid Gibson2017-12-08 00:35:35 +0100
committerDavid Gibson2018-01-16 23:35:24 +0100
commit33face6b8981add8eba1f7cdaf4cf6cede415d2e (patch)
treedc76c7c2d7d2fc9cba84e8e9fb756f854c6db92c /include/hw/ppc/spapr.h
parenttarget/ppc: Yet another fix for KVM-HV HPTE accessors (diff)
downloadqemu-33face6b8981add8eba1f7cdaf4cf6cede415d2e.tar.gz
qemu-33face6b8981add8eba1f7cdaf4cf6cede415d2e.tar.xz
qemu-33face6b8981add8eba1f7cdaf4cf6cede415d2e.zip
spapr: Capabilities infrastructure
Because PAPR is a paravirtual environment access to certain CPU (or other) facilities can be blocked by the hypervisor. PAPR provides ways to advertise in the device tree whether or not those features are available to the guest. In some places we automatically determine whether to make a feature available based on whether our host can support it, in most cases this is based on limitations in the available KVM implementation. Although we correctly advertise this to the guest, it means that host factors might make changes to the guest visible environment which is bad: as well as generaly reducing reproducibility, it means that a migration between different host environments can easily go bad. We've mostly gotten away with it because the environments considered mature enough to be well supported (basically, KVM on POWER8) have had consistent feature availability. But, it's still not right and some limitations on POWER9 is going to make it more of an issue in future. This introduces an infrastructure for defining "sPAPR capabilities". These are set by default based on the machine version, masked by the capabilities of the chosen cpu, but can be overriden with machine properties. The intention is at reset time we verify that the requested capabilities can be supported on the host (considering TCG, KVM and/or host cpu limitations). If not we simply fail, rather than silently modifying the advertised featureset to the guest. This does mean that certain configurations that "worked" may now fail, but such configurations were already more subtly broken. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Greg Kurz <groug@kaod.org>
Diffstat (limited to 'include/hw/ppc/spapr.h')
-rw-r--r--include/hw/ppc/spapr.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 14757b805e..5569caf1d4 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -51,6 +51,15 @@ typedef enum {
} sPAPRResizeHPT;
/**
+ * Capabilities
+ */
+
+typedef struct sPAPRCapabilities sPAPRCapabilities;
+struct sPAPRCapabilities {
+ uint64_t mask;
+};
+
+/**
* sPAPRMachineClass:
*/
struct sPAPRMachineClass {
@@ -66,6 +75,7 @@ struct sPAPRMachineClass {
hwaddr *mmio32, hwaddr *mmio64,
unsigned n_dma, uint32_t *liobns, Error **errp);
sPAPRResizeHPT resize_hpt_default;
+ sPAPRCapabilities default_caps;
};
/**
@@ -127,6 +137,9 @@ struct sPAPRMachineState {
MemoryHotplugState hotplug_memory;
const char *icp_type;
+
+ sPAPRCapabilities forced_caps, forbidden_caps;
+ sPAPRCapabilities effective_caps;
};
#define H_SUCCESS 0
@@ -724,4 +737,22 @@ int spapr_irq_alloc_block(sPAPRMachineState *spapr, int num, bool lsi,
void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num);
qemu_irq spapr_qirq(sPAPRMachineState *spapr, int irq);
+/*
+ * Handling of optional capabilities
+ */
+static inline sPAPRCapabilities spapr_caps(uint64_t mask)
+{
+ sPAPRCapabilities caps = { mask };
+ return caps;
+}
+
+static inline bool spapr_has_cap(sPAPRMachineState *spapr, uint64_t cap)
+{
+ return !!(spapr->effective_caps.mask & cap);
+}
+
+void spapr_caps_reset(sPAPRMachineState *spapr);
+void spapr_caps_validate(sPAPRMachineState *spapr, Error **errp);
+void spapr_caps_add_properties(sPAPRMachineClass *smc, Error **errp);
+
#endif /* HW_SPAPR_H */