diff options
author | Cédric Le Goater <clg@kaod.org> | 2019-05-13 10:42:41 +0200 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2019-05-29 11:39:46 +1000 |
commit | 3bf84e99c823987704d1324cf0e34e7597e737a5 (patch) | |
tree | 32db3a77eb8146ef9dbb3012f5df2812dbbf0c27 /hw/intc/spapr_xive_kvm.c | |
parent | 56b11587dfc79dc6453d857159801dcc38f24d0c (diff) |
spapr: check for the activation of the KVM IRQ device
The activation of the KVM IRQ device depends on the interrupt mode
chosen at CAS time by the machine and some methods used at reset or by
the migration need to be protected.
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20190513084245.25755-11-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'hw/intc/spapr_xive_kvm.c')
-rw-r--r-- | hw/intc/spapr_xive_kvm.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index 259cd1db95..078d18d775 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -90,9 +90,15 @@ static void kvmppc_xive_cpu_set_state(XiveTCTX *tctx, Error **errp) void kvmppc_xive_cpu_get_state(XiveTCTX *tctx, Error **errp) { + SpaprXive *xive = SPAPR_MACHINE(qdev_get_machine())->xive; uint64_t state[2] = { 0 }; int ret; + /* The KVM XIVE device is not in use */ + if (xive->fd == -1) { + return; + } + ret = kvm_get_one_reg(tctx->cs, KVM_REG_PPC_VP_STATE, state); if (ret != 0) { error_setg_errno(errp, errno, @@ -143,6 +149,11 @@ void kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **errp) unsigned long vcpu_id; int ret; + /* The KVM XIVE device is not in use */ + if (xive->fd == -1) { + return; + } + /* Check if CPU was hot unplugged and replugged. */ if (kvm_cpu_is_enabled(tctx->cs)) { return; @@ -219,6 +230,11 @@ void kvmppc_xive_source_reset_one(XiveSource *xsrc, int srcno, Error **errp) SpaprXive *xive = SPAPR_XIVE(xsrc->xive); uint64_t state = 0; + /* The KVM XIVE device is not in use */ + if (xive->fd == -1) { + return; + } + if (xive_source_irq_is_lsi(xsrc, srcno)) { state |= KVM_XIVE_LEVEL_SENSITIVE; if (xsrc->status[srcno] & XIVE_STATUS_ASSERTED) { @@ -319,9 +335,13 @@ static void kvmppc_xive_source_get_state(XiveSource *xsrc) void kvmppc_xive_source_set_irq(void *opaque, int srcno, int val) { XiveSource *xsrc = opaque; + SpaprXive *xive = SPAPR_XIVE(xsrc->xive); struct kvm_irq_level args; int rc; + /* The KVM XIVE device should be in use */ + assert(xive->fd != -1); + args.irq = srcno; if (!xive_source_irq_is_lsi(xsrc, srcno)) { if (!val) { @@ -546,6 +566,11 @@ static void kvmppc_xive_change_state_handler(void *opaque, int running, void kvmppc_xive_synchronize_state(SpaprXive *xive, Error **errp) { + /* The KVM XIVE device is not in use */ + if (xive->fd == -1) { + return; + } + /* * When the VM is stopped, the sources are masked and the previous * state is saved in anticipation of a migration. We should not @@ -571,6 +596,11 @@ int kvmppc_xive_pre_save(SpaprXive *xive) { Error *local_err = NULL; + /* The KVM XIVE device is not in use */ + if (xive->fd == -1) { + return 0; + } + /* EAT: there is no extra state to query from KVM */ /* ENDT */ @@ -595,6 +625,9 @@ int kvmppc_xive_post_load(SpaprXive *xive, int version_id) CPUState *cs; int i; + /* The KVM XIVE device should be in use */ + assert(xive->fd != -1); + /* Restore the ENDT first. The targetting depends on it. */ for (i = 0; i < xive->nr_ends; i++) { if (!xive_end_is_valid(&xive->endt[i])) { |