Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3736443pxb; Tue, 17 Nov 2020 02:03:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQnrmPyeCxt/GCQuKPd4W02vKf2kOBk4brP6a2zloSg2QMUHyqltwYfUMvyewiUteHIeiV X-Received: by 2002:a17:906:77c5:: with SMTP id m5mr18863959ejn.424.1605607413819; Tue, 17 Nov 2020 02:03:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605607413; cv=none; d=google.com; s=arc-20160816; b=GOCGfZdhpPkwKeDIkJ5TwysKu0rmwZe2NMSs7VAAskDoC6GIPllMq5oxeMJ4gu7QzS qIVWP2q5OjC1Ge1WisYHLknHkMDGWPzrsDVE0hbmrF0j7EO90cRi/30X4zB8UlEbasEU MGNqfap/PcMVSp85lzsb1hqBpDOoVHJbC9bgUJyOkWz52ZFeaBDMs+rpcI7ZzKkwMZ96 Ji2NmSbVkmDIKAjwVlzuMdSoHY5PsM8H40959+cFjpAqKTGqsLKxKMylLq7YVEJ++Rze dgZBJ5rQmLrH8RQ0GyTWCEWcRqzVYc1kaUqLkuyuqxrMpMGX7IriA5hZJ5qHSHuo9Kw2 pPjw== 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:dkim-signature; bh=8mOqkemx80iqAEbsvZPEHgtzkP43+VniYkthIUbTgE4=; b=fWunsAq0KTzh40vmHbsCJhne0rtC4JsN6QBFPycH1rrS9fz7xPlY5LcqOdCowHfshl rtujm2XxXloqiUqGebJQOd3l4PUWZ9XI+jCj5BSRohFD9C3T0KX1sa8TKxeQmonrespn hVM/dV9LKG3buvjp7SJu/SwaOA8bkptR9Ewx3Qs0DBDVThJCGMNV9KPH88YEYBw7Oa45 1g9z4NtOgE/xYTo0FtMkwdJS2/VhRd726sQyw+k12kQdXSSbU4i0qvbuhrWxoMIzM67I s1hfuZ1TFqpmPgoizTJDVOHyfAio15+ZVJyUCtv0LXrNxdtM9Z4Svy9JHkD8lrR+w9X9 QOpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="jUPyGd/h"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k22si13393985eds.368.2020.11.17.02.03.10; Tue, 17 Nov 2020 02:03:33 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="jUPyGd/h"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726268AbgKQJ7i (ORCPT + 99 others); Tue, 17 Nov 2020 04:59:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:41455 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725770AbgKQJ7h (ORCPT ); Tue, 17 Nov 2020 04:59:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605607176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8mOqkemx80iqAEbsvZPEHgtzkP43+VniYkthIUbTgE4=; b=jUPyGd/h/Yjs7Ang6PQCCDLLUksFeJqpDaTdh8U5+SASUpaA/GRF5eUq02rIGs67isbGuj MdROD4rYVPFzjJFv50J53Mab4PoUeSNQbAmiy/mY9XIiQZBj0OhD7gViX9o9AV8sMTlgCD OKOVCx3Zk0p9iZ3MSIauVvNewsi6WoA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-486-_3BCSZ60ORWuvma_yhqS-Q-1; Tue, 17 Nov 2020 04:59:34 -0500 X-MC-Unique: _3BCSZ60ORWuvma_yhqS-Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5EA91899422; Tue, 17 Nov 2020 09:59:32 +0000 (UTC) Received: from [10.36.113.230] (ovpn-113-230.ams2.redhat.com [10.36.113.230]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5A335D9CC; Tue, 17 Nov 2020 09:59:29 +0000 (UTC) Subject: Re: [PATCH 1/2] KVM: arm64: vgic: Forbid invalid userspace Redistributor accesses To: Marc Zyngier , Zenghui Yu Cc: suzuki.poulose@arm.com, linux-kernel@vger.kernel.org, james.morse@arm.com, linux-arm-kernel@lists.infradead.org, wanghaibin.wang@huawei.com, Keqian Zhu , kvmarm@lists.cs.columbia.edu, julien.thierry.kdev@gmail.com 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: Auger Eric Message-ID: <5ba4a98e-276b-2462-0580-fe0e007e9b38@redhat.com> Date: Tue, 17 Nov 2020 10:59:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marc, On 11/17/20 9:49 AM, 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). > > Eric: do we have any test covering the userspace API? So as this issue seems related to the changes made when implementing the multiple RDIST regions, I volunteer to write those KVM selftests :-) Thanks Eric > > Thanks, > >         M.