From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5082C433EF for ; Sat, 28 May 2022 11:38:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 097244B332; Sat, 28 May 2022 07:38:41 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eHvvI+qPBWPj; Sat, 28 May 2022 07:38:40 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BFB154B354; Sat, 28 May 2022 07:38:39 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id D0BDD4B335 for ; Sat, 28 May 2022 07:38:38 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Fk+-s5EAUjvq for ; Sat, 28 May 2022 07:38:37 -0400 (EDT) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 955A24B2B6 for ; Sat, 28 May 2022 07:38:37 -0400 (EDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0F2ED60E88; Sat, 28 May 2022 11:38:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24ACFC3411B; Sat, 28 May 2022 11:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653737916; bh=d39ibshBzkgRXzQXdSghaz5ZDck87DjC7xPM+/J1juE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cH5ET/kJKf8pzCP7k3GEzvI0ZHrigVNRpiybWI5UKAm87EYF2Xfs6L/kPyKRfzms2 js2PL2KBvuRJI+zNjgakKqv01AHk4iqYSKMJP/MesMcld3jyw/MVsFo7cytjqGjWsj 6v13+PYV+Mtal2bXE5RMW3ZaxwN+JLPnlz84NGj9v+PBEQtMOOqSLL4sKsYRG4I6oV fiSdYZ6y6OKI+X3gxuNmwEDwbrZqZlMUMU64cNP4TYbs67/uBQxLpyUgD85FO2z/vG 4iSvJsvRAA0jaHPTbU0UUQzmLxmcU1xfSgoDYLugZXnQYOitXHHM2+gIQqJiDN3ywx 998Kyz3kTJeuQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nuum9-00EEGh-Rr; Sat, 28 May 2022 12:38:33 +0100 From: Marc Zyngier To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 02/18] KVM: arm64: Always start with clearing SME flag on load Date: Sat, 28 May 2022 12:38:12 +0100 Message-Id: <20220528113829.1043361-3-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220528113829.1043361-1-maz@kernel.org> References: <20220528113829.1043361-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, oupton@google.com, will@kernel.org, tabba@google.com, qperret@google.com, broonie@kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: kernel-team@android.com, Will Deacon , Mark Brown X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On each vcpu load, we set the KVM_ARM64_HOST_SME_ENABLED flag if SVE is enabled for EL0 on the host. This is used to restore the correct state on vpcu put. However, it appears that nothing ever clears this flag. Once set, it will stick until the vcpu is destroyed, which has the potential to spuriously enable SME for userspace. As it turns out, this is due to the SME code being more or less copied from SVE, and inheriting the same shortcomings. We never saw the issue because nothing uses SME, and the amount of testing is probably still pretty low. Fixes: 861262ab8627 ("KVM: arm64: Handle SME host state when running guests") Signed-off-by: Marc Zyngier --- arch/arm64/kvm/fpsimd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index 3c2cfc3adc51..78b3f143a2d0 100644 --- a/arch/arm64/kvm/fpsimd.c +++ b/arch/arm64/kvm/fpsimd.c @@ -94,6 +94,7 @@ void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu) * operations. Do this for ZA as well for now for simplicity. */ if (system_supports_sme()) { + vcpu->arch.flags &= ~KVM_ARM64_HOST_SME_ENABLED; if (read_sysreg(cpacr_el1) & CPACR_EL1_SMEN_EL0EN) vcpu->arch.flags |= KVM_ARM64_HOST_SME_ENABLED; -- 2.34.1 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 36B08C433FE for ; Sat, 28 May 2022 11:40:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AD+HmZp1UX1gd2tL86cFQWqhjlOtMl3JKy+Wj6ql6Gc=; b=Oc33KzcTBqgdCN Cse5SXxRoi6NyTl6TcRaB2U2aOHFKmbvz3jlM23BiR5eXcZT2l3WU5jhfffBI92ZNf9CssmvWotxD s893Y7SefIG91WSJ+/36HfvXkLB05o6IW7ZUIJsi4nhw6R2hCbTb3FJ+7uKvtS6VrVJ3+7HwH/hf0 fFSeZbAQtk6TL606MpNYLOMATnpOtTytgOrhIYxeI7kjXXbW28CJ3COswEfBXdYf8p64a+cFg9W4L VqZ2i8sYNFDuayMx6kvlr1yNiNFp8VjB/+qDj5Y8SI0oVo7DEvRXQSYxkk6D6pa/5vjof9jCeKp5H gl6627635vf+9lwUwabQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuumJ-001zux-OE; Sat, 28 May 2022 11:38:43 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nuumE-001zsE-I3 for linux-arm-kernel@lists.infradead.org; Sat, 28 May 2022 11:38:39 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0F2ED60E88; Sat, 28 May 2022 11:38:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24ACFC3411B; Sat, 28 May 2022 11:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653737916; bh=d39ibshBzkgRXzQXdSghaz5ZDck87DjC7xPM+/J1juE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cH5ET/kJKf8pzCP7k3GEzvI0ZHrigVNRpiybWI5UKAm87EYF2Xfs6L/kPyKRfzms2 js2PL2KBvuRJI+zNjgakKqv01AHk4iqYSKMJP/MesMcld3jyw/MVsFo7cytjqGjWsj 6v13+PYV+Mtal2bXE5RMW3ZaxwN+JLPnlz84NGj9v+PBEQtMOOqSLL4sKsYRG4I6oV fiSdYZ6y6OKI+X3gxuNmwEDwbrZqZlMUMU64cNP4TYbs67/uBQxLpyUgD85FO2z/vG 4iSvJsvRAA0jaHPTbU0UUQzmLxmcU1xfSgoDYLugZXnQYOitXHHM2+gIQqJiDN3ywx 998Kyz3kTJeuQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nuum9-00EEGh-Rr; Sat, 28 May 2022 12:38:33 +0100 From: Marc Zyngier To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Alexandru Elisei , Oliver Upton , Will Deacon , Fuad Tabba , Quentin Perret , Mark Brown , kernel-team@android.com Subject: [PATCH 02/18] KVM: arm64: Always start with clearing SME flag on load Date: Sat, 28 May 2022 12:38:12 +0100 Message-Id: <20220528113829.1043361-3-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220528113829.1043361-1-maz@kernel.org> References: <20220528113829.1043361-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, oupton@google.com, will@kernel.org, tabba@google.com, qperret@google.com, broonie@kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220528_043838_677255_2CB6FF71 X-CRM114-Status: GOOD ( 16.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On each vcpu load, we set the KVM_ARM64_HOST_SME_ENABLED flag if SVE is enabled for EL0 on the host. This is used to restore the correct state on vpcu put. However, it appears that nothing ever clears this flag. Once set, it will stick until the vcpu is destroyed, which has the potential to spuriously enable SME for userspace. As it turns out, this is due to the SME code being more or less copied from SVE, and inheriting the same shortcomings. We never saw the issue because nothing uses SME, and the amount of testing is probably still pretty low. Fixes: 861262ab8627 ("KVM: arm64: Handle SME host state when running guests") Signed-off-by: Marc Zyngier --- arch/arm64/kvm/fpsimd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index 3c2cfc3adc51..78b3f143a2d0 100644 --- a/arch/arm64/kvm/fpsimd.c +++ b/arch/arm64/kvm/fpsimd.c @@ -94,6 +94,7 @@ void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu) * operations. Do this for ZA as well for now for simplicity. */ if (system_supports_sme()) { + vcpu->arch.flags &= ~KVM_ARM64_HOST_SME_ENABLED; if (read_sysreg(cpacr_el1) & CPACR_EL1_SMEN_EL0EN) vcpu->arch.flags |= KVM_ARM64_HOST_SME_ENABLED; -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEC1AC4321E for ; Sat, 28 May 2022 11:38:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234774AbiE1Lim (ORCPT ); Sat, 28 May 2022 07:38:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234713AbiE1Lik (ORCPT ); Sat, 28 May 2022 07:38:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01F4D167ED for ; Sat, 28 May 2022 04:38:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 91E2CB80EAE for ; Sat, 28 May 2022 11:38:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24ACFC3411B; Sat, 28 May 2022 11:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1653737916; bh=d39ibshBzkgRXzQXdSghaz5ZDck87DjC7xPM+/J1juE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cH5ET/kJKf8pzCP7k3GEzvI0ZHrigVNRpiybWI5UKAm87EYF2Xfs6L/kPyKRfzms2 js2PL2KBvuRJI+zNjgakKqv01AHk4iqYSKMJP/MesMcld3jyw/MVsFo7cytjqGjWsj 6v13+PYV+Mtal2bXE5RMW3ZaxwN+JLPnlz84NGj9v+PBEQtMOOqSLL4sKsYRG4I6oV fiSdYZ6y6OKI+X3gxuNmwEDwbrZqZlMUMU64cNP4TYbs67/uBQxLpyUgD85FO2z/vG 4iSvJsvRAA0jaHPTbU0UUQzmLxmcU1xfSgoDYLugZXnQYOitXHHM2+gIQqJiDN3ywx 998Kyz3kTJeuQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nuum9-00EEGh-Rr; Sat, 28 May 2022 12:38:33 +0100 From: Marc Zyngier To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Alexandru Elisei , Oliver Upton , Will Deacon , Fuad Tabba , Quentin Perret , Mark Brown , kernel-team@android.com Subject: [PATCH 02/18] KVM: arm64: Always start with clearing SME flag on load Date: Sat, 28 May 2022 12:38:12 +0100 Message-Id: <20220528113829.1043361-3-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220528113829.1043361-1-maz@kernel.org> References: <20220528113829.1043361-1-maz@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, oupton@google.com, will@kernel.org, tabba@google.com, qperret@google.com, broonie@kernel.org, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On each vcpu load, we set the KVM_ARM64_HOST_SME_ENABLED flag if SVE is enabled for EL0 on the host. This is used to restore the correct state on vpcu put. However, it appears that nothing ever clears this flag. Once set, it will stick until the vcpu is destroyed, which has the potential to spuriously enable SME for userspace. As it turns out, this is due to the SME code being more or less copied from SVE, and inheriting the same shortcomings. We never saw the issue because nothing uses SME, and the amount of testing is probably still pretty low. Fixes: 861262ab8627 ("KVM: arm64: Handle SME host state when running guests") Signed-off-by: Marc Zyngier --- arch/arm64/kvm/fpsimd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c index 3c2cfc3adc51..78b3f143a2d0 100644 --- a/arch/arm64/kvm/fpsimd.c +++ b/arch/arm64/kvm/fpsimd.c @@ -94,6 +94,7 @@ void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu) * operations. Do this for ZA as well for now for simplicity. */ if (system_supports_sme()) { + vcpu->arch.flags &= ~KVM_ARM64_HOST_SME_ENABLED; if (read_sysreg(cpacr_el1) & CPACR_EL1_SMEN_EL0EN) vcpu->arch.flags |= KVM_ARM64_HOST_SME_ENABLED; -- 2.34.1