From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_PASS,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B884C10F11 for ; Thu, 11 Apr 2019 03:16:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8220217F4 for ; Thu, 11 Apr 2019 03:16:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ozlabs.org header.i=@ozlabs.org header.b="b0ypBdod" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726624AbfDKDQa (ORCPT ); Wed, 10 Apr 2019 23:16:30 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:37659 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726536AbfDKDQa (ORCPT ); Wed, 10 Apr 2019 23:16:30 -0400 Received: by ozlabs.org (Postfix, from userid 1003) id 44fmQN0VRlz9s71; Thu, 11 Apr 2019 13:16:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1554952588; bh=ogizDjhR016Ty7xjWcdRKvgsaqrWqbpGkzQDlVKPKqw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=b0ypBdodFLFdHWi9PwQ6E4Jnsk1CEZPQMutWOJ6TAcyog/UyVE9N6xwKxCWZ/lJyY wyr1CRj5jDwnbdhIR02Fes2AK63jkadxy6u1Ef7Nw9N+CkanlQCmMFz0j5seFHkMic bVllekbgBDS1GK23yMxQS2LkZHs3I84+X/or/P9m0p3Z4TVNFudR1RZmWA+BWgNBui f8yil4X1yHl5PE2KXj5fRKcbzrOf6exoouLSotAcZHAjbXTCpUWEJjT0hjxgsZmsG/ lczX3Dw9EGri7ibz/+sBA0mVsYeIz+4u+0zsOkwKQPNft5OKtowNHGlW2Vd0KWYlgJ upPb34IgPAywg== Date: Thu, 11 Apr 2019 13:16:25 +1000 From: Paul Mackerras 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 Subject: Re: [PATCH v5 16/16] KVM: PPC: Book3S HV: XIVE: introduce a 'release' device operation Message-ID: <20190411031625.GA21252@blackberry> References: <20190410170448.3923-1-clg@kaod.org> <20190410170448.3923-17-clg@kaod.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190410170448.3923-17-clg@kaod.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Wed, Apr 10, 2019 at 07:04:48PM +0200, Cédric 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. > > 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. > > 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_xive.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 kvm_vcpu *vcpu) > void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu) > { > struct kvmppc_xive_vcpu *xc = vcpu->arch.xive_vcpu; > - struct kvmppc_xive *xive = xc->xive; > + struct kvmppc_xive *xive; > int i; > > + if (!kvmppc_xics_enabled(vcpu)) > + return; Should that be kvmppc_xive_enabled() rather than xics? Paul.