On Mon, Aug 10, 2020 at 12:08:05PM +0200, Greg Kurz wrote: > Similarly to what was done with XICS-on-XIVE and XIVE native KVM devices > with commit 5422e95103cf ("KVM: PPC: Book3S HV: XIVE: Replace the 'destroy' > method by a 'release' method"), convert the historical XICS KVM device to > implement the 'release' method. This is needed to run nested guests with > an in-kernel IRQ chip. A typical POWER9 guest can select XICS or XIVE > during boot, which requires to be able to destroy and to re-create the > KVM device. Only the historical XICS KVM device is available under pseries > at the current time and it still uses the legacy 'destroy' method. > > Switching to 'release' means that vCPUs might still be running when the > device is destroyed. In order to avoid potential use-after-free, the > kvmppc_xics structure is allocated on first usage and kept around until > the VM exits. The same pointer is used each time a KVM XICS device is > being created, but this is okay since we only have one per VM. > > Clear the ICP of each vCPU with vcpu->mutex held. This ensures that the > next time the vCPU resumes execution, it won't be going into the XICS > code anymore. > > Signed-off-by: Greg Kurz <groug@xxxxxxxx> Thanks, applied to my kvm-ppc-next branch. Paul.