Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3676109ybb; Mon, 23 Mar 2020 05:42:46 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuDvEf449KLAA3Op4qL29jm90UpnZN4azm0r3w2jit7LN5hRlaZLv0C/O8C8Cyf59b0t3y6 X-Received: by 2002:a05:6830:1d4f:: with SMTP id p15mr16799478oth.38.1584967366262; Mon, 23 Mar 2020 05:42:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584967366; cv=none; d=google.com; s=arc-20160816; b=Ia9cFOO//um1VI28QAqZSSZuLZlsw7HePSigC2j/4vYqucxNXET6uLBCp0iU5pfjW2 WBR/ZORX0DGvYMCuPHSNBEDI4c6MwnVgm8muMkI2AxvTpZURLj+5cxj1aa++hmVagnsE EHwglsPid6oBVcYvh+QQxLPyhSs9dmt4aO7FMm1BhYvswowMqq3a+WnYFsjLy9uTzQ0S 9nd7/cJrhBiIHyqGJ43JT3UXVmXyZGplepNvbkhtR/rxWHZQM810K2Xpnu0VTeAiiZ0Q UG6DDDgqzLeEWz8WaKNMo4hjuTF5dzVFwCd8ETpChpOulu5lD8CH2ejjzmNa45PClepk 9LHQ== 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=98WsMtko6qE2eiFEvn235C+W8Hn9OIgtM3QiQfV8az0=; b=dwBOThFqcK43rmPzW3Rw9UVXMKD/7RbS62JXCUU+NCleOJrvtqRsoB8q07huj7850l p14Bh2FttiYfqSSGsbyZ0+gpt4WypJN9uFHW3dOv4rjZ5N+Z6X7bQjNY/8L/syAWl+Tf e4k/FVfgeqt9EqB/oG9Bu5VnDqPMzv4kFVX/LWmMTYHUDYTh/idbzbnuYr8UBlvVKQV4 /2y3UpIH0JrszV+SBQu2hNeMyxBeNjHu5MHX72GvRal7bG5obiFwVKRbBzknbpDrehp+ 7W5xI1V6Dsn6rsJ8XkCmUZ25ioLcNIPVn9ZfyqX77dUA8i60oW/MZJ4UsshKE9lI5yg6 8A2w== 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 145si7973122oie.185.2020.03.23.05.42.33; Mon, 23 Mar 2020 05:42:46 -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; 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 S1727840AbgCWMk4 (ORCPT + 99 others); Mon, 23 Mar 2020 08:40:56 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12178 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727130AbgCWMk4 (ORCPT ); Mon, 23 Mar 2020 08:40:56 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 63E252ECE21C08DF8A96; Mon, 23 Mar 2020 20:40:18 +0800 (CST) Received: from [127.0.0.1] (10.173.222.27) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Mon, 23 Mar 2020 20:40:11 +0800 Subject: Re: [PATCH v5 20/23] KVM: arm64: GICv4.1: Plumb SGI implementation selection in the distributor To: Marc Zyngier CC: , , , , Lorenzo Pieralisi , Jason Cooper , "Robert Richter" , Thomas Gleixner , "Eric Auger" , James Morse , "Julien Thierry" , Suzuki K Poulose References: <20200304203330.4967-1-maz@kernel.org> <20200304203330.4967-21-maz@kernel.org> <72832f51-bbde-8502-3e03-189ac20a0143@huawei.com> <4a06fae9c93e10351276d173747d17f4@kernel.org> <1c9fdfc8-bdb2-88b6-4bdc-2b9254dfa55c@huawei.com> <256b58a9679412c96600217f316f424f@kernel.org> <1c10593ac5b75f37c6853fbc74daa481@kernel.org> From: Zenghui Yu Message-ID: <49fedfb3-ea4a-a18b-f453-86f43be7f18f@huawei.com> Date: Mon, 23 Mar 2020 20:40:10 +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: <1c10593ac5b75f37c6853fbc74daa481@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/3/23 16:25, Marc Zyngier wrote: > Hi Zenghui, > > [...] > >>> And actually, maybe we can handle that pretty cheaply. If userspace >>> tries to restore GICD_TYPER2 to a value that isn't what KVM can >>> offer, we just return an error. Exactly like we do for GICD_IIDR. >>> Hence the following patch: >>> >>> diff --git a/virt/kvm/arm/vgic/vgic-mmio-v3.c >>> b/virt/kvm/arm/vgic/vgic-mmio-v3.c >>> index 28b639fd1abc..e72dcc454247 100644 >>> --- a/virt/kvm/arm/vgic/vgic-mmio-v3.c >>> +++ b/virt/kvm/arm/vgic/vgic-mmio-v3.c >>> @@ -156,6 +156,7 @@ static int vgic_mmio_uaccess_write_v3_misc(struct >>> kvm_vcpu *vcpu, >>>       struct vgic_dist *dist = &vcpu->kvm->arch.vgic; >>> >>>       switch (addr & 0x0c) { >>> +    case GICD_TYPER2: >>>       case GICD_IIDR: >>>           if (val != vgic_mmio_read_v3_misc(vcpu, addr, len)) >>>               return -EINVAL; >>> >>> Being a RO register, writing something that isn't compatible with the >>> possible behaviour of the hypervisor will just return an error. >> >> This is really a nice point to address my concern! I'm happy to see >> this in v6 now. >> >>> >>> What do you think? >> >> I agreed with you, with a bit nervous though. Some old guests (which >> have no knowledge about GICv4.1 vSGIs and don't care about nASSGIcap >> at all) will also fail to migrate from A to B, just because now we >> present two different (unused) GICD_TYPER2 registers to them. >> >> Is it a little unfair to them :-) ? > > I never pretended to be fair! ;-) > > I'm happy to prevent migrating from a v4.1 system (A) to a v4.0 > system (B). As soon as the guest has run, it isn't safe to do so > (it may have read TYPER2, and now knows about vSGIs). We *could* > track this and find ways to migrate this state as well, but it > feels fragile. > > Migrating from B to A is more appealing. It should be possible to > do so without much difficulty (just check that the nASSGIcap bit > is either 0 or equal to KVM's view of the capability). > > But overall I seriously doubt we can easily migrate guests across > very different HW. We've been talking about this for years, and > we still don't have a good solution for it given the diversity > of the ecosystem... :-/ Fair enough. Thanks for your detailed explanation! Zenghui