Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3843700pxb; Tue, 17 Nov 2020 05:12:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJypXqgVCfHuEn0ujesSZhQ9dKpHHolsvc3Gp8Grba+Vcdx2c8LMK396V+C4o7637mDalP4l X-Received: by 2002:a17:906:bc93:: with SMTP id lv19mr6850472ejb.64.1605618755990; Tue, 17 Nov 2020 05:12:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605618755; cv=none; d=google.com; s=arc-20160816; b=iAt+8L7SrCn0Xpbg1av8pIpPGjarxyUWlk7/dYdtzDMKuGYSYT1wby4oNEp++Y4ao4 GXlyXWBaEZ1ZOOq/Bnuq2aEItvomyXXQo8Uy74aRfv4fsjZ79LsL5gIcsZZEEYHfyg3x ESGwEy4jm4NaQA+2gMru5jQvotm/1vcy0lqpGoUzAkHLZCgYMPqk3Us5OTnUsG4K+WGv CPcF9MYQ5x5eiKLYVuwnAyAugxCUlGeNVW/w76s+1V9x/zaKumhq9pD+u1+GCxIG8QNh zAbV1t8bpmkpD1VpZIRDGQVG2AWzNhxH/fByYvun5ZgBEDD16Gl6stIjb/OlgadFmj6t pVjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=QXvZVtAkqB/BUomF/bBir1/fHuQtXu1m0WtbfjYiIRI=; b=Pwdwuj4AXSgbTiofgelwPD4gZdrbSKkU27ysjTxEKxsV9fRr/mwZdD4Yn+ycjFY5tF e3V8SnqmXj667r39aPIZFKPhMwEfy0iRtPpLwnhqopZYdN2tpT6/aA3tcr7lQ+SzbMJj vVAR1kzli0Qud2sCEvhcPYGzuX2h3f3ljGmhiFIu2WtA8gKhjsTe++V9wTujinFeYw+M 2esCxi7t/IcJuP50+/+nfZEOCvqULBlRvhDa7LCooMRs+QsyWOQOTOodxaEAKQ4BkPhP d3UrTLUNTCJh9uqzMnPJnAShwv7UKC2rJVxYoc58t/9CiFV4EVh2TEG52/aBer0jr2F/ I5yQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si14345812edx.188.2020.11.17.05.12.10; Tue, 17 Nov 2020 05:12:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728754AbgKQNJk (ORCPT + 99 others); Tue, 17 Nov 2020 08:09:40 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:7695 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728893AbgKQNJe (ORCPT ); Tue, 17 Nov 2020 08:09:34 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Cb5qs1QJ5zkZ6f; Tue, 17 Nov 2020 21:09:13 +0800 (CST) Received: from [10.174.185.179] (10.174.185.179) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Tue, 17 Nov 2020 21:09:22 +0800 Subject: Re: [PATCH 1/2] KVM: arm64: vgic: Forbid invalid userspace Redistributor accesses To: Marc Zyngier CC: , , , , , , , , Keqian Zhu References: <20201113142801.1659-1-yuzenghui@huawei.com> <20201113142801.1659-2-yuzenghui@huawei.com> <724c43702b52aac0d3c9beb9604d1bfb@kernel.org> <584b7ff1-ecf2-b0ec-cea3-ccc29902f43a@huawei.com> <7e58200c-814e-3598-155a-9a7e6cc24374@huawei.com> From: Zenghui Yu Message-ID: Date: Tue, 17 Nov 2020 21:09:21 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.185.179] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/11/17 16:49, Marc Zyngier wrote: > Hi Zenghui, > > On 2020-11-16 14:57, Zenghui Yu wrote: >> Hi Marc, >> >> On 2020/11/16 22:10, Marc Zyngier wrote: >>>> My take is that only if the "[Re]Distributor base address" is specified >>>> in the system memory map, will the user-provided kvm_device_attr.offset >>>> make sense. And we can then handle the access to the register which is >>>> defined by "base address + offset". >>> >>> I'd tend to agree, but it is just that this is a large change at -rc4. >>> I'd rather have a quick fix for 5.10, and a more invasive change for >>> 5.11, >>> spanning all the possible vgic devices. >> >> So you prefer fixing it by "return a value that doesn't have the Last >> bit set" for v5.10? I'm ok with it and can send v2 for it. > > Cool. Thanks for that. > >> Btw, looking again at the way we handle the user-reading of GICR_TYPER >> >>     vgic_mmio_read_v3r_typer(vcpu, addr, len) >> >> it seems that @addr is actually the *offset* of GICR_TYPER (0x0008) and >> @addr is unlikely to be equal to last_rdist_typer, which is the *GPA* of >> the last RD. Looks like the user-reading of GICR_TYPER.Last is always >> broken? > > I think you are right. Somehow, we don't seem to track the index of > the RD in the region, so we can never compute the address of the RD > even if the base address is set. > > Let's drop the reporting of Last for userspace for now, as it never > worked. If you post a patch addressing that quickly, I'll get it to > Paolo by the end of the week (there's another fix that needs merging). OK. I'll fix it by providing a uaccess_read callback for GICR_TYPER. Thanks, Zenghui > > Eric: do we have any test covering the userspace API? > > Thanks, > >         M.