Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3974986pxb; Tue, 17 Nov 2020 08:14:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUrAZ/dKfdOoBDa0IDBqy0kMvsJ0i+QlGOZNQwDKDR4lzbKZA50dkoyPNKsjkmYehE86X9 X-Received: by 2002:a17:906:f186:: with SMTP id gs6mr20760269ejb.171.1605629692006; Tue, 17 Nov 2020 08:14:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605629691; cv=none; d=google.com; s=arc-20160816; b=mZHvK/Q0L73e8k54BlgjFUzn+BShVb85Lq5DW3J90QLhnw+gtfKn5PWBwtL24Qca5J eO3Ee0EgryvBXJJGCW98sY1V92MZIuILSlBq2hqcj8ZzECuwvbXFb+XgL8K5MXrLSywm MoN53k0C4sJ11UTqXGSYKNUU7mE0r8Clpzc8fUp2yAL7MMf6XaaBeNLY6HH/2i9P6p1M CdYbk7op5wWZiMaGBwYOeNj3iBzwutM/p/PwUwooCBpsFKWCsDxFeM5i2bNeOGGBnMVQ 4ijeGF+gAmFym0s5iulNnR/P5yQloGh5miTP8i+UmueezGY4P0ZieGH48gA/tms9xGpz mv0w== 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=K2Vf0RfP/3Y99b8CQWVflTekDMLKo5GNuwsv1AnNNb8=; b=XCeievnG0yjITfXvmJtC8KNVA+pu3wnf+Vs+Ac6Eo+xu1jY+iB9+iQfUAoXqSBV3yH P+WOja4+UKtSunRkodapeT4aHWnPFr/Faa3ZQ7xvSKHddPmOdOqzxGqnsvY1e0ykc4qa 1NyML++d9htIPqR68WQzzkY+IlYYYZJSEPQTyN6A5sAe40CzespcFUTnGPQkrerEwxe+ zh5QEqkYqDcvyUMc28FBtmx8BEy6u4GVw4rs0+O8EiiGpjZVnsTNhempakZOs3KAEzql 66FS4WMixSerklA/lL3p4jc4W/g8bg9rA6E99dFrorifknPb1GSsVtYcxZ8ExtJHuwKY HNWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="wu5/ZNwD"; 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 w10si13931203ejn.255.2020.11.17.08.14.28; Tue, 17 Nov 2020 08:14:51 -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="wu5/ZNwD"; 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 S1727061AbgKQQL2 (ORCPT + 99 others); Tue, 17 Nov 2020 11:11:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:42524 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbgKQQL2 (ORCPT ); Tue, 17 Nov 2020 11:11:28 -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 6E7F62168B; Tue, 17 Nov 2020 16:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605629487; bh=2J3aQk2RMCcV/YNBP2sRQqNYi+R+20F8reknkyJhP6s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wu5/ZNwD6M7LNZxTe4UWWucvf7mY9oEMbe9UPHLfqGTOuOGWZJ1TzNfAUy1ESQAdM fut6Xr/lJbkPHY2KJr6KvxeQ2BEWoRRjjn4ZGZU0gYg7xGP3uySTRQXAMNcTGpM335 i/rLrkAMaOll1zxL951DVYgOrEBMmXboxV50EH/Q= 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.4 112/151] KVM: arm64: Dont hide ID registers from userspace Date: Tue, 17 Nov 2020 14:05:42 +0100 Message-Id: <20201117122126.880479175@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122121.381905960@linuxfoundation.org> References: <20201117122121.381905960@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 @@ -1132,16 +1132,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) { @@ -1168,9 +1158,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); } @@ -1183,9 +1170,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; @@ -1448,7 +1432,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),