* [Qemu-devel] [PATCH] spapr/xive: Add proper rollback to kvmppc_xive_connect()
@ 2019-06-16 17:22 Greg Kurz
2019-06-18 7:05 ` Cédric Le Goater
2019-06-19 9:36 ` David Gibson
0 siblings, 2 replies; 6+ messages in thread
From: Greg Kurz @ 2019-06-16 17:22 UTC (permalink / raw)
To: David Gibson; +Cc: qemu-ppc, Cédric Le Goater, qemu-devel
Make kvmppc_xive_disconnect() able to undo the changes of a partial
execution of kvmppc_xive_connect() and use it to perform rollback.
Based-on: <20190614165920.12670-2-clg@kaod.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
---
hw/intc/spapr_xive_kvm.c | 48 ++++++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
index 5559f8bce5ef..3bf8e7a20e14 100644
--- a/hw/intc/spapr_xive_kvm.c
+++ b/hw/intc/spapr_xive_kvm.c
@@ -724,8 +724,7 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
xsrc->esb_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len,
&local_err);
if (local_err) {
- error_propagate(errp, local_err);
- return;
+ goto fail;
}
memory_region_init_ram_device_ptr(&xsrc->esb_mmio_kvm, OBJECT(xsrc),
@@ -743,8 +742,7 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
xive->tm_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len,
&local_err);
if (local_err) {
- error_propagate(errp, local_err);
- return;
+ goto fail;
}
memory_region_init_ram_device_ptr(&xive->tm_mmio_kvm, OBJECT(xive),
"xive.tima", tima_len, xive->tm_mmap);
@@ -760,21 +758,24 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, &local_err);
if (local_err) {
- error_propagate(errp, local_err);
- return;
+ goto fail;
}
}
/* Update the KVM sources */
kvmppc_xive_source_reset(xsrc, &local_err);
if (local_err) {
- error_propagate(errp, local_err);
- return;
+ goto fail;
}
kvm_kernel_irqchip = true;
kvm_msi_via_irqfd_allowed = true;
kvm_gsi_direct_mapping = true;
+ return;
+
+fail:
+ error_propagate(errp, local_err);
+ kvmppc_xive_disconnect(xive, NULL);
}
void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
@@ -796,23 +797,29 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
xsrc = &xive->source;
esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
- memory_region_del_subregion(&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
- object_unparent(OBJECT(&xsrc->esb_mmio_kvm));
- munmap(xsrc->esb_mmap, esb_len);
- xsrc->esb_mmap = NULL;
+ if (xsrc->esb_mmap) {
+ memory_region_del_subregion(&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
+ object_unparent(OBJECT(&xsrc->esb_mmio_kvm));
+ munmap(xsrc->esb_mmap, esb_len);
+ xsrc->esb_mmap = NULL;
+ }
- memory_region_del_subregion(&xive->tm_mmio, &xive->tm_mmio_kvm);
- object_unparent(OBJECT(&xive->tm_mmio_kvm));
- munmap(xive->tm_mmap, 4ull << TM_SHIFT);
- xive->tm_mmap = NULL;
+ if (xive->tm_mmap) {
+ memory_region_del_subregion(&xive->tm_mmio, &xive->tm_mmio_kvm);
+ object_unparent(OBJECT(&xive->tm_mmio_kvm));
+ munmap(xive->tm_mmap, 4ull << TM_SHIFT);
+ xive->tm_mmap = NULL;
+ }
/*
* When the KVM device fd is closed, the KVM device is destroyed
* and removed from the list of devices of the VM. The VCPU
* presenters are also detached from the device.
*/
- close(xive->fd);
- xive->fd = -1;
+ if (xive->fd != -1) {
+ close(xive->fd);
+ xive->fd = -1;
+ }
kvm_kernel_irqchip = false;
kvm_msi_via_irqfd_allowed = false;
@@ -822,5 +829,8 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
kvm_cpu_disable_all();
/* VM Change state handler is not needed anymore */
- qemu_del_vm_change_state_handler(xive->change);
+ if (xive->change) {
+ qemu_del_vm_change_state_handler(xive->change);
+ xive->change = NULL;
+ }
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] spapr/xive: Add proper rollback to kvmppc_xive_connect()
2019-06-16 17:22 [Qemu-devel] [PATCH] spapr/xive: Add proper rollback to kvmppc_xive_connect() Greg Kurz
@ 2019-06-18 7:05 ` Cédric Le Goater
2019-06-19 9:36 ` David Gibson
1 sibling, 0 replies; 6+ messages in thread
From: Cédric Le Goater @ 2019-06-18 7:05 UTC (permalink / raw)
To: Greg Kurz, David Gibson; +Cc: qemu-ppc, qemu-devel
On 16/06/2019 19:22, Greg Kurz wrote:
> Make kvmppc_xive_disconnect() able to undo the changes of a partial
> execution of kvmppc_xive_connect() and use it to perform rollback.
>
> Based-on: <20190614165920.12670-2-clg@kaod.org>
> Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Thanks,
C.
> ---
> hw/intc/spapr_xive_kvm.c | 48 ++++++++++++++++++++++++++++------------------
> 1 file changed, 29 insertions(+), 19 deletions(-)
>
> diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
> index 5559f8bce5ef..3bf8e7a20e14 100644
> --- a/hw/intc/spapr_xive_kvm.c
> +++ b/hw/intc/spapr_xive_kvm.c
> @@ -724,8 +724,7 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
> xsrc->esb_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len,
> &local_err);
> if (local_err) {
> - error_propagate(errp, local_err);
> - return;
> + goto fail;
> }
>
> memory_region_init_ram_device_ptr(&xsrc->esb_mmio_kvm, OBJECT(xsrc),
> @@ -743,8 +742,7 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
> xive->tm_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len,
> &local_err);
> if (local_err) {
> - error_propagate(errp, local_err);
> - return;
> + goto fail;
> }
> memory_region_init_ram_device_ptr(&xive->tm_mmio_kvm, OBJECT(xive),
> "xive.tima", tima_len, xive->tm_mmap);
> @@ -760,21 +758,24 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>
> kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, &local_err);
> if (local_err) {
> - error_propagate(errp, local_err);
> - return;
> + goto fail;
> }
> }
>
> /* Update the KVM sources */
> kvmppc_xive_source_reset(xsrc, &local_err);
> if (local_err) {
> - error_propagate(errp, local_err);
> - return;
> + goto fail;
> }
>
> kvm_kernel_irqchip = true;
> kvm_msi_via_irqfd_allowed = true;
> kvm_gsi_direct_mapping = true;
> + return;
> +
> +fail:
> + error_propagate(errp, local_err);
> + kvmppc_xive_disconnect(xive, NULL);
> }
>
> void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
> @@ -796,23 +797,29 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
> xsrc = &xive->source;
> esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
>
> - memory_region_del_subregion(&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
> - object_unparent(OBJECT(&xsrc->esb_mmio_kvm));
> - munmap(xsrc->esb_mmap, esb_len);
> - xsrc->esb_mmap = NULL;
> + if (xsrc->esb_mmap) {
> + memory_region_del_subregion(&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
> + object_unparent(OBJECT(&xsrc->esb_mmio_kvm));
> + munmap(xsrc->esb_mmap, esb_len);
> + xsrc->esb_mmap = NULL;
> + }
>
> - memory_region_del_subregion(&xive->tm_mmio, &xive->tm_mmio_kvm);
> - object_unparent(OBJECT(&xive->tm_mmio_kvm));
> - munmap(xive->tm_mmap, 4ull << TM_SHIFT);
> - xive->tm_mmap = NULL;
> + if (xive->tm_mmap) {
> + memory_region_del_subregion(&xive->tm_mmio, &xive->tm_mmio_kvm);
> + object_unparent(OBJECT(&xive->tm_mmio_kvm));
> + munmap(xive->tm_mmap, 4ull << TM_SHIFT);
> + xive->tm_mmap = NULL;
> + }
>
> /*
> * When the KVM device fd is closed, the KVM device is destroyed
> * and removed from the list of devices of the VM. The VCPU
> * presenters are also detached from the device.
> */
> - close(xive->fd);
> - xive->fd = -1;
> + if (xive->fd != -1) {
> + close(xive->fd);
> + xive->fd = -1;
> + }
>
> kvm_kernel_irqchip = false;
> kvm_msi_via_irqfd_allowed = false;
> @@ -822,5 +829,8 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
> kvm_cpu_disable_all();
>
> /* VM Change state handler is not needed anymore */
> - qemu_del_vm_change_state_handler(xive->change);
> + if (xive->change) {
> + qemu_del_vm_change_state_handler(xive->change);
> + xive->change = NULL;
> + }
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] spapr/xive: Add proper rollback to kvmppc_xive_connect()
2019-06-16 17:22 [Qemu-devel] [PATCH] spapr/xive: Add proper rollback to kvmppc_xive_connect() Greg Kurz
2019-06-18 7:05 ` Cédric Le Goater
@ 2019-06-19 9:36 ` David Gibson
2019-06-19 9:56 ` Cédric Le Goater
2019-07-01 6:13 ` Cédric Le Goater
1 sibling, 2 replies; 6+ messages in thread
From: David Gibson @ 2019-06-19 9:36 UTC (permalink / raw)
To: Greg Kurz; +Cc: qemu-ppc, Cédric Le Goater, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 4605 bytes --]
On Sun, Jun 16, 2019 at 07:22:23PM +0200, Greg Kurz wrote:
> Make kvmppc_xive_disconnect() able to undo the changes of a partial
> execution of kvmppc_xive_connect() and use it to perform rollback.
>
> Based-on: <20190614165920.12670-2-clg@kaod.org>
> Signed-off-by: Greg Kurz <groug@kaod.org>
I'm afraid this doesn't apply clean on my current ppc-for-4.1.
> ---
> hw/intc/spapr_xive_kvm.c | 48 ++++++++++++++++++++++++++++------------------
> 1 file changed, 29 insertions(+), 19 deletions(-)
>
> diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
> index 5559f8bce5ef..3bf8e7a20e14 100644
> --- a/hw/intc/spapr_xive_kvm.c
> +++ b/hw/intc/spapr_xive_kvm.c
> @@ -724,8 +724,7 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
> xsrc->esb_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len,
> &local_err);
> if (local_err) {
> - error_propagate(errp, local_err);
> - return;
> + goto fail;
> }
>
> memory_region_init_ram_device_ptr(&xsrc->esb_mmio_kvm, OBJECT(xsrc),
> @@ -743,8 +742,7 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
> xive->tm_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len,
> &local_err);
> if (local_err) {
> - error_propagate(errp, local_err);
> - return;
> + goto fail;
> }
> memory_region_init_ram_device_ptr(&xive->tm_mmio_kvm, OBJECT(xive),
> "xive.tima", tima_len, xive->tm_mmap);
> @@ -760,21 +758,24 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>
> kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, &local_err);
> if (local_err) {
> - error_propagate(errp, local_err);
> - return;
> + goto fail;
> }
> }
>
> /* Update the KVM sources */
> kvmppc_xive_source_reset(xsrc, &local_err);
> if (local_err) {
> - error_propagate(errp, local_err);
> - return;
> + goto fail;
> }
>
> kvm_kernel_irqchip = true;
> kvm_msi_via_irqfd_allowed = true;
> kvm_gsi_direct_mapping = true;
> + return;
> +
> +fail:
> + error_propagate(errp, local_err);
> + kvmppc_xive_disconnect(xive, NULL);
> }
>
> void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
> @@ -796,23 +797,29 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
> xsrc = &xive->source;
> esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
>
> - memory_region_del_subregion(&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
> - object_unparent(OBJECT(&xsrc->esb_mmio_kvm));
> - munmap(xsrc->esb_mmap, esb_len);
> - xsrc->esb_mmap = NULL;
> + if (xsrc->esb_mmap) {
> + memory_region_del_subregion(&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
> + object_unparent(OBJECT(&xsrc->esb_mmio_kvm));
> + munmap(xsrc->esb_mmap, esb_len);
> + xsrc->esb_mmap = NULL;
> + }
>
> - memory_region_del_subregion(&xive->tm_mmio, &xive->tm_mmio_kvm);
> - object_unparent(OBJECT(&xive->tm_mmio_kvm));
> - munmap(xive->tm_mmap, 4ull << TM_SHIFT);
> - xive->tm_mmap = NULL;
> + if (xive->tm_mmap) {
> + memory_region_del_subregion(&xive->tm_mmio, &xive->tm_mmio_kvm);
> + object_unparent(OBJECT(&xive->tm_mmio_kvm));
> + munmap(xive->tm_mmap, 4ull << TM_SHIFT);
> + xive->tm_mmap = NULL;
> + }
>
> /*
> * When the KVM device fd is closed, the KVM device is destroyed
> * and removed from the list of devices of the VM. The VCPU
> * presenters are also detached from the device.
> */
> - close(xive->fd);
> - xive->fd = -1;
> + if (xive->fd != -1) {
> + close(xive->fd);
> + xive->fd = -1;
> + }
>
> kvm_kernel_irqchip = false;
> kvm_msi_via_irqfd_allowed = false;
> @@ -822,5 +829,8 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
> kvm_cpu_disable_all();
>
> /* VM Change state handler is not needed anymore */
> - qemu_del_vm_change_state_handler(xive->change);
> + if (xive->change) {
> + qemu_del_vm_change_state_handler(xive->change);
> + xive->change = NULL;
> + }
> }
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] spapr/xive: Add proper rollback to kvmppc_xive_connect()
2019-06-19 9:36 ` David Gibson
@ 2019-06-19 9:56 ` Cédric Le Goater
2019-07-01 6:13 ` Cédric Le Goater
1 sibling, 0 replies; 6+ messages in thread
From: Cédric Le Goater @ 2019-06-19 9:56 UTC (permalink / raw)
To: David Gibson, Greg Kurz; +Cc: qemu-ppc, qemu-devel
Hello,
On 19/06/2019 11:36, David Gibson wrote:
> On Sun, Jun 16, 2019 at 07:22:23PM +0200, Greg Kurz wrote:
>> Make kvmppc_xive_disconnect() able to undo the changes of a partial
>> execution of kvmppc_xive_connect() and use it to perform rollback.
>>
>> Based-on: <20190614165920.12670-2-clg@kaod.org>
>> Signed-off-by: Greg Kurz <groug@kaod.org>
>
> I'm afraid this doesn't apply clean on my current ppc-for-4.1.
You need these before :
spapr/xive: simplify spapr_irq_init_device() to remove the emulated init
spapr/xive: rework the mapping the KVM memory regions
https://patchwork.ozlabs.org/patch/1116146/
https://patchwork.ozlabs.org/patch/1116152/
Then, these should follow :
xics/spapr: Only emulated XICS should use RTAS/hypercalls emulation
xics/spapr: Drop unused function declaration
xics/spapr: Rename xics_kvm_init()
xics/kvm: Skip rollback when KVM XICS is absent
xics/kvm: Always use local_err in xics_kvm_init()
xics/kvm: Add error propagation to ic*_set_kvm_state() functions
xics/kvm: Add proper rollback to xics_kvm_init()
You can take a look at :
https://github.com/legoater/qemu/commits/xive-next
Thanks,
C.
>> ---
>> hw/intc/spapr_xive_kvm.c | 48 ++++++++++++++++++++++++++++------------------
>> 1 file changed, 29 insertions(+), 19 deletions(-)
>>
>> diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
>> index 5559f8bce5ef..3bf8e7a20e14 100644
>> --- a/hw/intc/spapr_xive_kvm.c
>> +++ b/hw/intc/spapr_xive_kvm.c
>> @@ -724,8 +724,7 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>> xsrc->esb_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len,
>> &local_err);
>> if (local_err) {
>> - error_propagate(errp, local_err);
>> - return;
>> + goto fail;
>> }
>>
>> memory_region_init_ram_device_ptr(&xsrc->esb_mmio_kvm, OBJECT(xsrc),
>> @@ -743,8 +742,7 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>> xive->tm_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len,
>> &local_err);
>> if (local_err) {
>> - error_propagate(errp, local_err);
>> - return;
>> + goto fail;
>> }
>> memory_region_init_ram_device_ptr(&xive->tm_mmio_kvm, OBJECT(xive),
>> "xive.tima", tima_len, xive->tm_mmap);
>> @@ -760,21 +758,24 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>>
>> kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, &local_err);
>> if (local_err) {
>> - error_propagate(errp, local_err);
>> - return;
>> + goto fail;
>> }
>> }
>>
>> /* Update the KVM sources */
>> kvmppc_xive_source_reset(xsrc, &local_err);
>> if (local_err) {
>> - error_propagate(errp, local_err);
>> - return;
>> + goto fail;
>> }
>>
>> kvm_kernel_irqchip = true;
>> kvm_msi_via_irqfd_allowed = true;
>> kvm_gsi_direct_mapping = true;
>> + return;
>> +
>> +fail:
>> + error_propagate(errp, local_err);
>> + kvmppc_xive_disconnect(xive, NULL);
>> }
>>
>> void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
>> @@ -796,23 +797,29 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
>> xsrc = &xive->source;
>> esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
>>
>> - memory_region_del_subregion(&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
>> - object_unparent(OBJECT(&xsrc->esb_mmio_kvm));
>> - munmap(xsrc->esb_mmap, esb_len);
>> - xsrc->esb_mmap = NULL;
>> + if (xsrc->esb_mmap) {
>> + memory_region_del_subregion(&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
>> + object_unparent(OBJECT(&xsrc->esb_mmio_kvm));
>> + munmap(xsrc->esb_mmap, esb_len);
>> + xsrc->esb_mmap = NULL;
>> + }
>>
>> - memory_region_del_subregion(&xive->tm_mmio, &xive->tm_mmio_kvm);
>> - object_unparent(OBJECT(&xive->tm_mmio_kvm));
>> - munmap(xive->tm_mmap, 4ull << TM_SHIFT);
>> - xive->tm_mmap = NULL;
>> + if (xive->tm_mmap) {
>> + memory_region_del_subregion(&xive->tm_mmio, &xive->tm_mmio_kvm);
>> + object_unparent(OBJECT(&xive->tm_mmio_kvm));
>> + munmap(xive->tm_mmap, 4ull << TM_SHIFT);
>> + xive->tm_mmap = NULL;
>> + }
>>
>> /*
>> * When the KVM device fd is closed, the KVM device is destroyed
>> * and removed from the list of devices of the VM. The VCPU
>> * presenters are also detached from the device.
>> */
>> - close(xive->fd);
>> - xive->fd = -1;
>> + if (xive->fd != -1) {
>> + close(xive->fd);
>> + xive->fd = -1;
>> + }
>>
>> kvm_kernel_irqchip = false;
>> kvm_msi_via_irqfd_allowed = false;
>> @@ -822,5 +829,8 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
>> kvm_cpu_disable_all();
>>
>> /* VM Change state handler is not needed anymore */
>> - qemu_del_vm_change_state_handler(xive->change);
>> + if (xive->change) {
>> + qemu_del_vm_change_state_handler(xive->change);
>> + xive->change = NULL;
>> + }
>> }
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] spapr/xive: Add proper rollback to kvmppc_xive_connect()
2019-06-19 9:36 ` David Gibson
2019-06-19 9:56 ` Cédric Le Goater
@ 2019-07-01 6:13 ` Cédric Le Goater
2019-07-01 6:52 ` David Gibson
1 sibling, 1 reply; 6+ messages in thread
From: Cédric Le Goater @ 2019-07-01 6:13 UTC (permalink / raw)
To: David Gibson, Greg Kurz; +Cc: qemu-ppc, qemu-devel
On 19/06/2019 11:36, David Gibson wrote:
> On Sun, Jun 16, 2019 at 07:22:23PM +0200, Greg Kurz wrote:
>> Make kvmppc_xive_disconnect() able to undo the changes of a partial
>> execution of kvmppc_xive_connect() and use it to perform rollback.
>>
>> Based-on: <20190614165920.12670-2-clg@kaod.org>
>> Signed-off-by: Greg Kurz <groug@kaod.org>
>
> I'm afraid this doesn't apply clean on my current ppc-for-4.1.
With the patch you have taken, this one should now apply.
Thanks,
C.
>
>> ---
>> hw/intc/spapr_xive_kvm.c | 48 ++++++++++++++++++++++++++++------------------
>> 1 file changed, 29 insertions(+), 19 deletions(-)
>>
>> diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
>> index 5559f8bce5ef..3bf8e7a20e14 100644
>> --- a/hw/intc/spapr_xive_kvm.c
>> +++ b/hw/intc/spapr_xive_kvm.c
>> @@ -724,8 +724,7 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>> xsrc->esb_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_ESB_PAGE_OFFSET, esb_len,
>> &local_err);
>> if (local_err) {
>> - error_propagate(errp, local_err);
>> - return;
>> + goto fail;
>> }
>>
>> memory_region_init_ram_device_ptr(&xsrc->esb_mmio_kvm, OBJECT(xsrc),
>> @@ -743,8 +742,7 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>> xive->tm_mmap = kvmppc_xive_mmap(xive, KVM_XIVE_TIMA_PAGE_OFFSET, tima_len,
>> &local_err);
>> if (local_err) {
>> - error_propagate(errp, local_err);
>> - return;
>> + goto fail;
>> }
>> memory_region_init_ram_device_ptr(&xive->tm_mmio_kvm, OBJECT(xive),
>> "xive.tima", tima_len, xive->tm_mmap);
>> @@ -760,21 +758,24 @@ void kvmppc_xive_connect(SpaprXive *xive, Error **errp)
>>
>> kvmppc_xive_cpu_connect(spapr_cpu_state(cpu)->tctx, &local_err);
>> if (local_err) {
>> - error_propagate(errp, local_err);
>> - return;
>> + goto fail;
>> }
>> }
>>
>> /* Update the KVM sources */
>> kvmppc_xive_source_reset(xsrc, &local_err);
>> if (local_err) {
>> - error_propagate(errp, local_err);
>> - return;
>> + goto fail;
>> }
>>
>> kvm_kernel_irqchip = true;
>> kvm_msi_via_irqfd_allowed = true;
>> kvm_gsi_direct_mapping = true;
>> + return;
>> +
>> +fail:
>> + error_propagate(errp, local_err);
>> + kvmppc_xive_disconnect(xive, NULL);
>> }
>>
>> void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
>> @@ -796,23 +797,29 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
>> xsrc = &xive->source;
>> esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
>>
>> - memory_region_del_subregion(&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
>> - object_unparent(OBJECT(&xsrc->esb_mmio_kvm));
>> - munmap(xsrc->esb_mmap, esb_len);
>> - xsrc->esb_mmap = NULL;
>> + if (xsrc->esb_mmap) {
>> + memory_region_del_subregion(&xsrc->esb_mmio, &xsrc->esb_mmio_kvm);
>> + object_unparent(OBJECT(&xsrc->esb_mmio_kvm));
>> + munmap(xsrc->esb_mmap, esb_len);
>> + xsrc->esb_mmap = NULL;
>> + }
>>
>> - memory_region_del_subregion(&xive->tm_mmio, &xive->tm_mmio_kvm);
>> - object_unparent(OBJECT(&xive->tm_mmio_kvm));
>> - munmap(xive->tm_mmap, 4ull << TM_SHIFT);
>> - xive->tm_mmap = NULL;
>> + if (xive->tm_mmap) {
>> + memory_region_del_subregion(&xive->tm_mmio, &xive->tm_mmio_kvm);
>> + object_unparent(OBJECT(&xive->tm_mmio_kvm));
>> + munmap(xive->tm_mmap, 4ull << TM_SHIFT);
>> + xive->tm_mmap = NULL;
>> + }
>>
>> /*
>> * When the KVM device fd is closed, the KVM device is destroyed
>> * and removed from the list of devices of the VM. The VCPU
>> * presenters are also detached from the device.
>> */
>> - close(xive->fd);
>> - xive->fd = -1;
>> + if (xive->fd != -1) {
>> + close(xive->fd);
>> + xive->fd = -1;
>> + }
>>
>> kvm_kernel_irqchip = false;
>> kvm_msi_via_irqfd_allowed = false;
>> @@ -822,5 +829,8 @@ void kvmppc_xive_disconnect(SpaprXive *xive, Error **errp)
>> kvm_cpu_disable_all();
>>
>> /* VM Change state handler is not needed anymore */
>> - qemu_del_vm_change_state_handler(xive->change);
>> + if (xive->change) {
>> + qemu_del_vm_change_state_handler(xive->change);
>> + xive->change = NULL;
>> + }
>> }
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] spapr/xive: Add proper rollback to kvmppc_xive_connect()
2019-07-01 6:13 ` Cédric Le Goater
@ 2019-07-01 6:52 ` David Gibson
0 siblings, 0 replies; 6+ messages in thread
From: David Gibson @ 2019-07-01 6:52 UTC (permalink / raw)
To: Cédric Le Goater; +Cc: qemu-ppc, Greg Kurz, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 907 bytes --]
On Mon, Jul 01, 2019 at 08:13:07AM +0200, Cédric Le Goater wrote:
> On 19/06/2019 11:36, David Gibson wrote:
> > On Sun, Jun 16, 2019 at 07:22:23PM +0200, Greg Kurz wrote:
> >> Make kvmppc_xive_disconnect() able to undo the changes of a partial
> >> execution of kvmppc_xive_connect() and use it to perform rollback.
> >>
> >> Based-on: <20190614165920.12670-2-clg@kaod.org>
> >> Signed-off-by: Greg Kurz <groug@kaod.org>
> >
> > I'm afraid this doesn't apply clean on my current ppc-for-4.1.
>
> With the patch you have taken, this one should now apply.
I'm afraid I've lost track of what's still left. Can you rebase on my
current ppc-for-4.1, and repost anything that's still outstanding.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-07-01 6:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-16 17:22 [Qemu-devel] [PATCH] spapr/xive: Add proper rollback to kvmppc_xive_connect() Greg Kurz
2019-06-18 7:05 ` Cédric Le Goater
2019-06-19 9:36 ` David Gibson
2019-06-19 9:56 ` Cédric Le Goater
2019-07-01 6:13 ` Cédric Le Goater
2019-07-01 6:52 ` David Gibson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).