Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1808052ybf; Sun, 1 Mar 2020 18:42:01 -0800 (PST) X-Google-Smtp-Source: APXvYqyF8LawSlRvueHsKjczqStSRbikxSFA3s3YhNCDIC3tCfHvmkTF9NC7oom7n81ayzicrh/P X-Received: by 2002:a9d:7842:: with SMTP id c2mr10986553otm.252.1583116921653; Sun, 01 Mar 2020 18:42:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583116921; cv=none; d=google.com; s=arc-20160816; b=DPhHg/qdtmZ0lHoPMhvhywejdrga1T68H2o7Mi/SOxPe8Kat30O/MA1PJglC5ytYpd vSiPQD2z5ZC9jNMXcgTRPkU/F3ezTv4+gnCqz45E/UfIkRhbcT8EooXLqA1th2jDSWNK jI5OzrdxLCbGkESe6RwJA978uS9cpJttIQOk74vr519wsbvNqZBaE57uKbPWmnhNRFPj Wz8R9u4cFmaaNReLKqyr0/gkYJgN5gQF6qxO59npXCGx3f3grLoOXKLqriqwM8hCe6tD WMir/93M2mjvMjbHDtdEOn4+uQY8wdgDiuuYEGI3aCYCu6QxopwFixLx5qBiw3kncZut IUVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=liCKK6Hvczszv09b/1ScwTLTQO2bmqzpWJzzf7Nn0vc=; b=rIHDlO+K/c3dEU0Ulvkm63/rpm99kpJlBAUxVu8d8eKjOPeftskF1nV2P2CXIFX+jO eZv/28lVrj24B/LB6egkExpXEnKf4Fj6s4eX7FuaXoIccR6GEAcWSWAZJgZ3dXE9GWf4 4V1cBjKMM8iW854Vm1m/gQ5eocKlKWvYEKUZW6XAfu0Ws0vS2UzQM8kzB7cLLm72FNab cHS5eJSbmLnt5SK1XecP8Uq32fxComwAA9IWDEKOKt89eaJUuA71MDTQFqztDzYOSMle C36qERdrS6yyQOujkVM89NHoXGw1ggRM4FCcU2e+LuWTxV0uZSPpSjiGGz90CL6L6oGD qlhQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e23si5512071oie.105.2020.03.01.18.41.49; Sun, 01 Mar 2020 18:42:01 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726775AbgCBCkn (ORCPT + 99 others); Sun, 1 Mar 2020 21:40:43 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:60226 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726695AbgCBCkm (ORCPT ); Sun, 1 Mar 2020 21:40:42 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 66F8A3F26BA126D15212; Mon, 2 Mar 2020 10:40:39 +0800 (CST) Received: from [127.0.0.1] (10.173.222.27) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Mon, 2 Mar 2020 10:40:32 +0800 Subject: Re: [PATCH v4 16/20] KVM: arm64: GICv4.1: Allow SGIs to switch between HW and SW interrupts To: Marc Zyngier CC: , , , , Lorenzo Pieralisi , Jason Cooper , "Robert Richter" , Thomas Gleixner , "Eric Auger" , James Morse , "Julien Thierry" , Suzuki K Poulose References: <20200214145736.18550-1-maz@kernel.org> <20200214145736.18550-17-maz@kernel.org> <6798eb13-a7e9-2a92-91b2-9b657962ea79@huawei.com> <7aa668a5920b8deb8c2ee2fec3ef69b3@kernel.org> From: Zenghui Yu Message-ID: <865e3cc6-19e3-a1ec-84a6-8c15ad738345@huawei.com> Date: Mon, 2 Mar 2020 10:40:30 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: <7aa668a5920b8deb8c2ee2fec3ef69b3@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.173.222.27] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marc, On 2020/2/29 3:16, Marc Zyngier wrote: > Hi Zenghui, > > On 2020-02-20 03:55, Zenghui Yu wrote: >> Hi Marc, >> >> On 2020/2/14 22:57, 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. >>> >>> Signed-off-by: Marc Zyngier >> >> [...] >> >>> diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c >>> index 1bc09b523486..2c9fc13e2c59 100644 >>> --- a/virt/kvm/arm/vgic/vgic-v3.c >>> +++ b/virt/kvm/arm/vgic/vgic-v3.c >>> @@ -540,6 +540,8 @@ int vgic_v3_map_resources(struct kvm *kvm) >>>           goto out; >>>       } >>>   +    if (kvm_vgic_global_state.has_gicv4_1) >>> +        vgic_v4_configure_vsgis(kvm); >>>       dist->ready = true; >>>     out: >> >> Is there any reason to invoke vgic_v4_configure_vsgis() here? >> This is called on the first VCPU run, through kvm_vgic_map_resources(). >> Shouldn't the vSGI configuration only driven by a GICD_CTLR.nASSGIreq >> writing (from guest, or from userspace maybe)? > > What I'm trying to catch here is the guest that has been restored with > nASSGIreq set. At the moment, we don't do anything on the userspace > side, because the vmm could decide to write that particular bit > multiple times, and switching between the two modes is expensive (not > to mention that all the vcpus may not have been created yet). > > Moving it to the first run makes all these pitfalls go away (we have the > final nASSSGIreq value, and all the vcpus are accounted for). So what will happen on restoration is (roughly): - for GICR_ISPENR0: We will restore the pending status of vSGIs into software pending_latch, just like what we've done for normal SGIs. - for GICD_CTLR.nASSGIreq: We will only record the written value. (Note to myself: No invocation of configure_vsgis() in uaccess_write callback, I previously mixed it up with the guest write callback.) - Finally, you choose the first vcpu run as the appropriate point to potentially flush the pending status to HW according to the final nASSGIreq value. > > Does this make sense to you? Yeah, it sounds like a good idea! And please ignore what I've replied to patch #15, I obviously missed your intention at that time, sorry... But can we move this hunk to some places more appropriate, for example, put it together with the GICD_CTLR's uaccess_write change? It might make things a bit clearer for other reviewers. :-) Thanks, Zenghui