• Greg Kurz's avatar
    KVM: PPC: Book3S HV: XICS: Replace the 'destroy' method by a 'release' method · 5706d14d
    Greg Kurz authored
    Similarly to what was done with XICS-on-XIVE and XIVE native KVM devices
    with commit 5422e951 ("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: default avatarGreg Kurz <groug@kaod.org>
    Reviewed-by: default avatarCédric Le Goater <clg@kaod.org>
    Tested-by: default avatarCédric Le Goater <clg@kaod.org>
    Signed-off-by: default avatarPaul Mackerras <paulus@ozlabs.org>
    5706d14d
kvm_host.h 21.6 KB