Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3976181pxb; Tue, 17 Nov 2020 08:16:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUH3DJpqelHbTSYfAsaeHWwivxKo6/GGPH9T2moYH5Rsy64ugOvt/eF+8TME9iRw9cCv9K X-Received: by 2002:a1c:abd7:: with SMTP id u206mr424464wme.33.1605629786432; Tue, 17 Nov 2020 08:16:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605629786; cv=none; d=google.com; s=arc-20160816; b=dpD94V67UrFgp/0WLQZE/lrPn7gu6JZU0RPk7Xi3LVI1JU/j98NRKC9A/+1hcyy1Qz bkMifOG1WtPTqmS4UTUB5wJPJwEECu3O3ECwHODLfhNkQeDMht/w/sDUv4u2GS0N/W26 EVO059mzkLUHAjMFVPT9hgplCTkyyT1G5TfFWnZgoqcM1DW1X/ZN+uJanV8KFtGv4sSp 0ItjVH3Uli5NUgsvU65pE2pG3jlrPBmKbuOf069SqMxXjrD/97MKm/UaUIEgsfSykPL+ dPHgNkhl3Xzz5ssvV5+gTFfoH8SImTf20aWDVbq/BiGYZoNLTbmXyPxTfvgg7A6qNVdb TCkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cOUWmI+skmz7Jqw12uun2E0/e6ZBtKiUg5VeldWOn1k=; b=G4r4YyCbJHBbCS22xr+217wOb6I3m2BkwENAsUld4u5LRW6gjTj0ZLAykwBd+KU5J7 buCu/heHud+MwHZMbKIEql2K4+oZ0WElgQw5mRaF2YKa8ekEcs2XnREqjbVP/kdcW1n6 T3qnFVPRKXiaaaHKAOsABorO50KxeYBhWdud7U52k8aE9yNIBTfqtDaBYjO11fr5KM4f nLbNRxjiO0tnMqp+oh+o9HsRM6jf+JE0YV+bq1udis0f8RYBAOe2+bZXFJWbw/d12FaY k0kCDfNOL8AQCqbXK/5oF74OF3S/84r52/Sg2GDyzcf2GSQoTjt8NstYhAuLPQMLSj61 c3mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O5yTJrCb; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hb36si10432533ejc.540.2020.11.17.08.15.59; Tue, 17 Nov 2020 08:16:26 -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=@kernel.org header.s=default header.b=O5yTJrCb; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727214AbgKQQLi (ORCPT + 99 others); Tue, 17 Nov 2020 11:11:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:42686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbgKQQLh (ORCPT ); Tue, 17 Nov 2020 11:11:37 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3EDB8221F8; Tue, 17 Nov 2020 16:11:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605629495; bh=uCKK/9ZMdgrnPHpZJ9uCObGewrVvWqeq87P4hs3pHRk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O5yTJrCbPMA3SwK5168fWjmFANL1w5/3/9sJ/yG7wrBFg1nwboUihj/sia8mPnrts JeME/QWNw4/hxYrPoJz6Me1sZM70JjjRiS2Jn/jcz5eGgXF2s5G7G2kjnBxt3XWz/K unJK3FuD3hE5d3evpWrK7rw/VQANfz2e8fhBcjOg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?=E5=BC=A0=E4=B8=9C=E6=97=AD?= , Andrew Jones , Marc Zyngier Subject: [PATCH 5.9 191/255] KVM: arm64: Dont hide ID registers from userspace Date: Tue, 17 Nov 2020 14:05:31 +0100 Message-Id: <20201117122148.224730548@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122138.925150709@linuxfoundation.org> References: <20201117122138.925150709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Jones commit f81cb2c3ad41ac6d8cb2650e3d72d5f67db1aa28 upstream. ID registers are RAZ until they've been allocated a purpose, but that doesn't mean they should be removed from the KVM_GET_REG_LIST list. So far we only have one register, SYS_ID_AA64ZFR0_EL1, that is hidden from userspace when its function, SVE, is not present. Expose SYS_ID_AA64ZFR0_EL1 to userspace as RAZ when SVE is not implemented. Removing the userspace visibility checks is enough to reexpose it, as it will already return zero to userspace when SVE is not present. The register already behaves as RAZ for the guest when SVE is not present. Fixes: 73433762fcae ("KVM: arm64/sve: System register context switch and access support") Reported-by: 张东旭 Signed-off-by: Andrew Jones Signed-off-by: Marc Zyngier Cc: stable@vger.kernel.org#v5.2+ Link: https://lore.kernel.org/r/20201105091022.15373-2-drjones@redhat.com Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kvm/sys_regs.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1193,16 +1193,6 @@ static unsigned int sve_visibility(const return REG_HIDDEN_USER | REG_HIDDEN_GUEST; } -/* Visibility overrides for SVE-specific ID registers */ -static unsigned int sve_id_visibility(const struct kvm_vcpu *vcpu, - const struct sys_reg_desc *rd) -{ - if (vcpu_has_sve(vcpu)) - return 0; - - return REG_HIDDEN_USER; -} - /* Generate the emulated ID_AA64ZFR0_EL1 value exposed to the guest */ static u64 guest_id_aa64zfr0_el1(const struct kvm_vcpu *vcpu) { @@ -1229,9 +1219,6 @@ static int get_id_aa64zfr0_el1(struct kv { u64 val; - if (WARN_ON(!vcpu_has_sve(vcpu))) - return -ENOENT; - val = guest_id_aa64zfr0_el1(vcpu); return reg_to_user(uaddr, &val, reg->id); } @@ -1244,9 +1231,6 @@ static int set_id_aa64zfr0_el1(struct kv int err; u64 val; - if (WARN_ON(!vcpu_has_sve(vcpu))) - return -ENOENT; - err = reg_from_user(&val, uaddr, id); if (err) return err; @@ -1509,7 +1493,7 @@ static const struct sys_reg_desc sys_reg ID_SANITISED(ID_AA64PFR1_EL1), ID_UNALLOCATED(4,2), ID_UNALLOCATED(4,3), - { SYS_DESC(SYS_ID_AA64ZFR0_EL1), access_id_aa64zfr0_el1, .get_user = get_id_aa64zfr0_el1, .set_user = set_id_aa64zfr0_el1, .visibility = sve_id_visibility }, + { SYS_DESC(SYS_ID_AA64ZFR0_EL1), access_id_aa64zfr0_el1, .get_user = get_id_aa64zfr0_el1, .set_user = set_id_aa64zfr0_el1, }, ID_UNALLOCATED(4,5), ID_UNALLOCATED(4,6), ID_UNALLOCATED(4,7),