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=-6.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 1DC4EC04AAB for ; Mon, 6 May 2019 15:04:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ECD582054F for ; Mon, 6 May 2019 15:04:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727386AbfEFPE1 (ORCPT ); Mon, 6 May 2019 11:04:27 -0400 Received: from 3.mo178.mail-out.ovh.net ([46.105.44.197]:59365 "EHLO 3.mo178.mail-out.ovh.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727862AbfEFPE0 (ORCPT ); Mon, 6 May 2019 11:04:26 -0400 Received: from player730.ha.ovh.net (unknown [10.109.160.232]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id 25C765BF9D for ; Mon, 6 May 2019 17:04:25 +0200 (CEST) Received: from kaod.org (lfbn-1-10649-41.w90-89.abo.wanadoo.fr [90.89.235.41]) (Authenticated sender: clg@kaod.org) by player730.ha.ovh.net (Postfix) with ESMTPSA id 6E57255802CD; Mon, 6 May 2019 15:04:18 +0000 (UTC) Subject: Re: [PATCH] KVM: PPC: Book3S HV: XIVE: Clear escalation interrupt pointers on device close To: Paul Mackerras , kvm@vger.kernel.org Cc: David Gibson , kvm-ppc@vger.kernel.org References: <20190426065414.GC12768@blackberry> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: <4d9e4296-2004-265c-9eb6-748d2f71e98e@kaod.org> Date: Mon, 6 May 2019 17:04:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190426065414.GC12768@blackberry> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 5546464419197586391 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduuddrjeejgdekiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On 4/26/19 8:54 AM, Paul Mackerras wrote: > This adds code to ensure that after a XIVE or XICS-on-XIVE KVM device > is closed, KVM will not try to enable or disable any of the escalation > interrupts for the VCPUs. Yes. This is a required cleanup. Reviewed-by: Cédric Le Goater Thanks, C. > We don't have to worry about races between > clearing the pointers and use of the pointers by the XIVE context > push/pull code, because the callers hold the vcpu->mutex, which is > also taken by the KVM_RUN code. Therefore the vcpu cannot be entering > or exiting the guest concurrently. > > Signed-off-by: Paul Mackerras > --- > arch/powerpc/kvm/book3s_xive.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c > index 4280cd8..4953957 100644 > --- a/arch/powerpc/kvm/book3s_xive.c > +++ b/arch/powerpc/kvm/book3s_xive.c > @@ -1096,6 +1096,21 @@ void kvmppc_xive_disable_vcpu_interrupts(struct kvm_vcpu *vcpu) > arch_spin_unlock(&sb->lock); > } > } > + > + /* Disable vcpu's escalation interrupt */ > + if (vcpu->arch.xive_esc_on) { > + __raw_readq((void __iomem *)(vcpu->arch.xive_esc_vaddr + > + XIVE_ESB_SET_PQ_01)); > + vcpu->arch.xive_esc_on = false; > + } > + > + /* > + * Clear pointers to escalation interrupt ESB. > + * This is safe because the vcpu->mutex is held, preventing > + * any other CPU from concurrently executing a KVM_RUN ioctl. > + */ > + vcpu->arch.xive_esc_vaddr = 0; > + vcpu->arch.xive_esc_raddr = 0; > } > > void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu) > From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Date: Mon, 06 May 2019 15:04:16 +0000 Subject: Re: [PATCH] KVM: PPC: Book3S HV: XIVE: Clear escalation interrupt pointers on device close Message-Id: <4d9e4296-2004-265c-9eb6-748d2f71e98e@kaod.org> List-Id: References: <20190426065414.GC12768@blackberry> In-Reply-To: <20190426065414.GC12768@blackberry> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Paul Mackerras , kvm@vger.kernel.org Cc: David Gibson , kvm-ppc@vger.kernel.org On 4/26/19 8:54 AM, Paul Mackerras wrote: > This adds code to ensure that after a XIVE or XICS-on-XIVE KVM device > is closed, KVM will not try to enable or disable any of the escalation > interrupts for the VCPUs. =20 Yes. This is a required cleanup. Reviewed-by: C=C3=A9dric Le Goater Thanks, C. > We don't have to worry about races between > clearing the pointers and use of the pointers by the XIVE context > push/pull code, because the callers hold the vcpu->mutex, which is > also taken by the KVM_RUN code. Therefore the vcpu cannot be entering > or exiting the guest concurrently. >=20 > Signed-off-by: Paul Mackerras > --- > arch/powerpc/kvm/book3s_xive.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) >=20 > diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xiv= e.c > index 4280cd8..4953957 100644 > --- a/arch/powerpc/kvm/book3s_xive.c > +++ b/arch/powerpc/kvm/book3s_xive.c > @@ -1096,6 +1096,21 @@ void kvmppc_xive_disable_vcpu_interrupts(struct kv= m_vcpu *vcpu) > arch_spin_unlock(&sb->lock); > } > } > + > + /* Disable vcpu's escalation interrupt */ > + if (vcpu->arch.xive_esc_on) { > + __raw_readq((void __iomem *)(vcpu->arch.xive_esc_vaddr + > + XIVE_ESB_SET_PQ_01)); > + vcpu->arch.xive_esc_on =3D false; > + } > + > + /* > + * Clear pointers to escalation interrupt ESB. > + * This is safe because the vcpu->mutex is held, preventing > + * any other CPU from concurrently executing a KVM_RUN ioctl. > + */ > + vcpu->arch.xive_esc_vaddr =3D 0; > + vcpu->arch.xive_esc_raddr =3D 0; > } > =20 > void kvmppc_xive_cleanup_vcpu(struct kvm_vcpu *vcpu) >=20