From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paul Mackerras Date: Thu, 11 Apr 2019 03:16:25 +0000 Subject: Re: [PATCH v5 16/16] KVM: PPC: Book3S HV: XIVE: introduce a 'release' device operation Message-Id: <20190411031625.GA21252@blackberry> List-Id: References: <20190410170448.3923-1-clg@kaod.org> <20190410170448.3923-17-clg@kaod.org> In-Reply-To: <20190410170448.3923-17-clg@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: =?iso-8859-1?Q?C=E9dric?= Le Goater Cc: kvm-ppc@vger.kernel.org, David Gibson , kvm@vger.kernel.org, Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paolo Bonzini On Wed, Apr 10, 2019 at 07:04:48PM +0200, C=E9dric Le Goater wrote: > When a P9 sPAPR VM boots, the CAS negotiation process determines which > interrupt mode to use (XICS legacy or XIVE native) and invokes a > machine reset to activate the chosen mode. >=20 > To be able to switch from one mode to another, we introduce the > capability to release a KVM device without destroying the VM. The KVM > device interface is extended with a new 'release' operation which is > called when the file descriptor of the device is closed. I believe the release operation is not called until all of the mmaps using the fd are unmapped - which is a good thing for us, since it means the guest can't possibly be accessing the XIVE directly. You might want to reword that last paragraph to mention that. > Such operations are defined for the XICS-on-XIVE and the XIVE native > KVM devices. They clear the vCPU interrupt presenters that could be > attached and then destroy the device. >=20 > This is not considered as a safe operation as the vCPUs are still > running and could be referencing the KVM device through their > presenters. To protect the system from any breakage, the kvmppc_xive > objects representing both KVM devices are now stored in an array under > the VM. Allocation is performed on first usage and memory is freed > only when the VM exits. One quick comment below: > diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xiv= e.c > index 480a3fc6b9fd..064a9f2ae678 100644 > --- a/arch/powerpc/kvm/book3s_xive.c > +++ b/arch/powerpc/kvm/book3s_xive.c > @@ -1100,11 +1100,19 @@ void kvmppc_xive_disable_vcpu_interrupts(struct k= vm_vcpu *vcpu) > void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu) > { > struct kvmppc_xive_vcpu *xc =3D vcpu->arch.xive_vcpu; > - struct kvmppc_xive *xive =3D xc->xive; > + struct kvmppc_xive *xive; > int i; > =20 > + if (!kvmppc_xics_enabled(vcpu)) > + return; Should that be kvmppc_xive_enabled() rather than xics? Paul.