Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp126188ybb; Thu, 19 Mar 2020 12:53:17 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuinw6fBUibf77UTS6+reU9Ujc5uXZL7UL/mwdvem3sKMdz2POJsZzNbtNgSXyPJwxUG6sX X-Received: by 2002:a9d:1d43:: with SMTP id m61mr3784948otm.91.1584647597030; Thu, 19 Mar 2020 12:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584647597; cv=none; d=google.com; s=arc-20160816; b=omGjZiszG9y2sLuGQInnuldP7h2RiZwmjKZDlHItcc06VLkb5oZQW4B7U2U9L6QABb avR5zmyHN5i5t90rjTCzMxJ3/alqDS6KFgyQ0hUYR8acWNY+Gjc2OnVjcNUN2IOKfyYY 9xBsJOLQCOPvtXjtcL1nDsNrBKGgVNNBRLjxZjrMYc8QnWI1g+tL+dvwZVhAcrtrsxAY USfVy13DU9BytK4WtDghQ7qo15igS7VCHMKhIyVFjFpT6HKWR1FSzFowuSQBX56wg9od sayB0o9ZKWbBKJj7fdhOGrqA8Lv8kXeV3b+JbUkzywrek5j6YlrDsbbpt0KyCdDqMLJe xyAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=SBLOrAe40AlpgFSRWxtu5lh0A5VF/jiYHQ/KKLhQfsA=; b=W8fLYJ2OnUBcMYE9GZAq5g3tNMLhw/eQUTSPX9SVbLS1tJXF/ZMLafxEkUuron5fZH fdNfASnFxY7ZcpmcqlNxufn7TkHHY58CSC4fuU4ADVQveRo0NSMduPRcr2v/Sr53F2ZJ gr+eK83dJf8zk1umt5KggSW/DUgg5KdkYurlp5oqc2z3CJOF3KpX3srKDhCxoG7OV2ia UuphpZiin731jhxXTDku8W4plv8SW+iwV0Q4LKtsGBS90ThiEldMloSsURiCkhi+b5lW nIuXPY6sUeJ3Nb3YZ1+zI6PksrrYIHFobAiZ6vzlpYUcG8TyQMn4sI7Oeg252lfwTsoY Ol8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qkSTKb4u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g206si1498594oib.17.2020.03.19.12.53.05; Thu, 19 Mar 2020 12:53:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qkSTKb4u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727732AbgCSTwp (ORCPT + 99 others); Thu, 19 Mar 2020 15:52:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:34816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725787AbgCSTwp (ORCPT ); Thu, 19 Mar 2020 15:52:45 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 19B8A206D7; Thu, 19 Mar 2020 19:52:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584647564; bh=UMFRuMeWN29pb4882uOYxANHVABCplgj+koAb1z+2dE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qkSTKb4utIarMQd8CDJcC0r66jjv4E6Grgajl0GaZ2NsWZFpgnSsxvNw5d1trhyVf m/hfAowH8zpNjr3UjCBAXtljDdoHJ8gci0Db/rlJFpoF62Ej37wABUnI3eg2J6bWh9 n0uwur1NEU7m4GqQdTUpOURPTJro6MWBSuqnHrzk= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jF1Dd-00E46F-Ts; Thu, 19 Mar 2020 19:52:42 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 19 Mar 2020 19:52:41 +0000 From: Marc Zyngier To: Auger Eric Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Lorenzo Pieralisi , Jason Cooper , Robert Richter , Thomas Gleixner , Zenghui Yu , James Morse , Julien Thierry , Suzuki K Poulose Subject: Re: [PATCH v5 19/23] KVM: arm64: GICv4.1: Allow SGIs to switch between HW and SW interrupts In-Reply-To: <8a6cf87a-7eee-5502-3b54-093ea0ab5e2d@redhat.com> References: <20200304203330.4967-1-maz@kernel.org> <20200304203330.4967-20-maz@kernel.org> <8a6cf87a-7eee-5502-3b54-093ea0ab5e2d@redhat.com> Message-ID: <877ba4711c6b9456314ea580b9c4718c@kernel.org> X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/1.3.10 X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: eric.auger@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, lorenzo.pieralisi@arm.com, jason@lakedaemon.net, rrichter@marvell.com, tglx@linutronix.de, yuzenghui@huawei.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eric, On 2020-03-19 16:16, Auger Eric wrote: > Hi Marc, > > On 3/4/20 9:33 PM, Marc Zyngier wrote: >> In order to let a guest buy in the new, active-less SGIs, we >> need to be able to switch between the two modes. >> >> Handle this by stopping all guest activity, transfer the state >> from one mode to the other, and resume the guest. Nothing calls >> this code so far, but a later patch will plug it into the MMIO >> emulation. >> >> Signed-off-by: Marc Zyngier >> --- >> include/kvm/arm_vgic.h | 3 ++ >> virt/kvm/arm/vgic/vgic-v4.c | 94 >> +++++++++++++++++++++++++++++++++++++ >> virt/kvm/arm/vgic/vgic.h | 1 + >> 3 files changed, 98 insertions(+) >> >> diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h >> index 63457908c9c4..69f4164d6477 100644 >> --- a/include/kvm/arm_vgic.h >> +++ b/include/kvm/arm_vgic.h >> @@ -231,6 +231,9 @@ struct vgic_dist { >> /* distributor enabled */ >> bool enabled; >> >> + /* Wants SGIs without active state */ >> + bool nassgireq; >> + >> struct vgic_irq *spis; >> >> struct vgic_io_device dist_iodev; >> diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c >> index c2fcde104ea2..a65dc1c85363 100644 >> --- a/virt/kvm/arm/vgic/vgic-v4.c >> +++ b/virt/kvm/arm/vgic/vgic-v4.c >> @@ -97,6 +97,100 @@ static irqreturn_t vgic_v4_doorbell_handler(int >> irq, void *info) >> return IRQ_HANDLED; >> } >> >> +static void vgic_v4_sync_sgi_config(struct its_vpe *vpe, struct >> vgic_irq *irq) >> +{ >> + vpe->sgi_config[irq->intid].enabled = irq->enabled; >> + vpe->sgi_config[irq->intid].group = irq->group; >> + vpe->sgi_config[irq->intid].priority = irq->priority; >> +} >> + >> +static void vgic_v4_enable_vsgis(struct kvm_vcpu *vcpu) >> +{ >> + struct its_vpe *vpe = &vcpu->arch.vgic_cpu.vgic_v3.its_vpe; >> + int i; >> + >> + /* >> + * With GICv4.1, every virtual SGI can be directly injected. So >> + * let's pretend that they are HW interrupts, tied to a host >> + * IRQ. The SGI code will do its magic. >> + */ >> + for (i = 0; i < VGIC_NR_SGIS; i++) { >> + struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, i); >> + struct irq_desc *desc; >> + int ret; > Is is safe without holding the irq->irq_lock? The assumption here is that we're coming vgic_v4_configure_vsgis(), which starts by stopping the whole guest. My guess is that it should be safe enough, but maybe you are thinking of something else? Thanks, M. -- Jazz is not dead. It just smells funny...