Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp981892pxu; Wed, 6 Jan 2021 09:15:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0Z6yCjopZHdR6qXHKgqaHU5x0oAOjKgGVtGG7hl9M7g+/4uI33B7274+mpn40Emy9VKiO X-Received: by 2002:a17:906:9888:: with SMTP id zc8mr3500374ejb.42.1609953313580; Wed, 06 Jan 2021 09:15:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609953313; cv=none; d=google.com; s=arc-20160816; b=QneO0gcbk/hPuVJNIMCOwa9wlLZtjjrssBZ+rSfXpJT9nHJzaVQDyZJVeSRHPZ5lsk +MN48fZdU25khNe961XPj8F5y0NlupGiuUxd0+a/MXl+ERqj4i6qTMEmzzgpWMvchPIl cgN7tYZ08spIwFSgObtnDCJUMODORfnUz29IXowJP+RWUs/FFMzKD3lUFIWwn22Um96h 4kuikH0ee1CPWYMazVOPClAiU3M/huhexUi31o9Ar2c4pWrTOS93YkhfWm/h7v+eI6jd 8QhYDnLXanEJzrIzJpZ9u0UYWw2+S7kfGtczrkXQi9L/8ChShC/ugCnCEhSpIoTNyLiY SaCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=ZK/Z4eMtk4pG3LBRyb7X5Jf+0RcnFpoHTrvwtv3gJ6Y=; b=NGkxE/+ZAsYGrTVNI2Xr54km3DMPBkV8haffp9xCR927+d0BViXObAc8Qd2xBRsAS+ WlBaZFyTGEbH6+cUCLx2uqOjAw3GDFojvNoPUbZpdKkYZoPkgy6IpP7z6CGZZt7OZeI/ bOyCOUF6l1H77kV7P3Mi+ZKShXASikJtkGvi98lcmEmY1WsJtO8wennkp2enJ0hn+u1s qnkDd1072YcpjHc2ScBvCUtubu5zO+fm/RwJjUdtFqOSiSnPbIq40BmS+v3sng6B579i W8PzipQBkCYGRS3hhLml8uQ2j6noXdLhGxvo2T7dbEATVZOgwu+umcXCPnz2OyNtvxSO btKQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cf6si1065892edb.557.2021.01.06.09.14.49; Wed, 06 Jan 2021 09:15:13 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727194AbhAFRNd (ORCPT + 99 others); Wed, 6 Jan 2021 12:13:33 -0500 Received: from foss.arm.com ([217.140.110.172]:44484 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726458AbhAFRNc (ORCPT ); Wed, 6 Jan 2021 12:13:32 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2CF011FB; Wed, 6 Jan 2021 09:12:47 -0800 (PST) Received: from [192.168.0.110] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A49AE3F70D; Wed, 6 Jan 2021 09:12:45 -0800 (PST) Subject: Re: [PATCH 2/9] KVM: arm64: Fix KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION read To: Eric Auger , eric.auger.pro@gmail.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, maz@kernel.org, drjones@redhat.com Cc: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, shuah@kernel.org, pbonzini@redhat.com References: <20201212185010.26579-1-eric.auger@redhat.com> <20201212185010.26579-3-eric.auger@redhat.com> From: Alexandru Elisei Message-ID: <888cf519-8c0e-f781-98a1-86594bdfacb1@arm.com> Date: Wed, 6 Jan 2021 17:12:50 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20201212185010.26579-3-eric.auger@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eric, The patch looks correct to me. kvm_vgic_addr() masks out all the bits except index from addr, so we don't need to do it in vgic_get_common_attr(): Reviewed-by: Alexandru Elisei One nitpick below. On 12/12/20 6:50 PM, Eric Auger wrote: > The doc says: > "The characteristics of a specific redistributor region can > be read by presetting the index field in the attr data. > Only valid for KVM_DEV_TYPE_ARM_VGIC_V3" > > Unfortunately the existing code fails to read the input attr data > and thus the index always is 0. addr is allocated on the stack, I don't think it will always be 0. Thanks, Alex > > Fixes: 04c110932225 ("KVM: arm/arm64: Implement KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION") > Cc: stable@vger.kernel.org#v4.17+ > Signed-off-by: Eric Auger > --- > arch/arm64/kvm/vgic/vgic-kvm-device.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/arm64/kvm/vgic/vgic-kvm-device.c b/arch/arm64/kvm/vgic/vgic-kvm-device.c > index 44419679f91a..2f66cf247282 100644 > --- a/arch/arm64/kvm/vgic/vgic-kvm-device.c > +++ b/arch/arm64/kvm/vgic/vgic-kvm-device.c > @@ -226,6 +226,9 @@ static int vgic_get_common_attr(struct kvm_device *dev, > u64 addr; > unsigned long type = (unsigned long)attr->attr; > > + if (copy_from_user(&addr, uaddr, sizeof(addr))) > + return -EFAULT; > + > r = kvm_vgic_addr(dev->kvm, type, &addr, false); > if (r) > return (r == -ENODEV) ? -ENXIO : r;