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 3E1C6EE0212 for ; Thu, 14 Sep 2023 00:05:11 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yuxoULWAVI4OSTcxAQnCXP6b61z0Y/raxMyZU5xbuRA=; b=1316h+U8tcORwx iQ2sqUTbcakIpoibwtU/R3sssawUTlgzkm4wrP8ZyuqffiNCpP+nEvQLM15f3OonVC3fQOLgwUjo3 cWqNXIpXYgYJHT1qdQgfJ5czH34WP4biscDyFLamI3uWh6SBXmLDB00sdXsNZNxTSNDEQgTapAqEz o89Drzz5QrPTMtvjkt0dLIZNcYjjbIasM47/Y1k/SKtHF+UCSdLUbQp/K1HLLTiqQmHN7601JQyIj lbx8heMFFtzcGDQecJLXWDN1vzOd4IzhFnFKDCYcOaZ4LCDU62TJ75wEgfXYIKUVqFL4/W8tpnKUf dNqzoQMB8KN4H8n19MdA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgZqb-006vi8-0g; Thu, 14 Sep 2023 00:04:41 +0000 Received: from out-213.mta1.migadu.com ([95.215.58.213]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qgZqW-006vhM-2Q for linux-arm-kernel@lists.infradead.org; Thu, 14 Sep 2023 00:04:39 +0000 Date: Thu, 14 Sep 2023 00:04:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1694649873; 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: in-reply-to:in-reply-to:references:references; bh=kfv4Zhx1bwbtVJ2Jm5wO4ve633QMh2KTeWELK3A6p6w=; b=EkjUA9C2vZhCis33BkatvJsmHMcE1KLe7dGi3Nt1OT2o9Tupl61AJHhh6y2YeC3C31PwGF 4284oBDu7yFUrVmO/1zQO7/2K+kvNbOOR66xDE7O7pt0oDzqr3jpZFCB28ZER9VodQDeut GANLbUAdtod/774vv0kRmU7VY7Y3vd4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Mark Brown Cc: Marc Zyngier , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH] KVM: arm64: Only default to enabling SVE when present Message-ID: References: <20230913-kvm-arm64-fp-init-v1-1-8ce9ba1cc4c4@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230913-kvm-arm64-fp-init-v1-1-8ce9ba1cc4c4@kernel.org> X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230913_170437_224750_A6DC70DB X-CRM114-Status: GOOD ( 25.70 ) 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 Hi Mark, On Wed, Sep 13, 2023 at 07:34:16PM +0100, Mark Brown wrote: > For unclear reasons our handling of SVE and SME when setting the default > value of CPTR_EL2 for VHE mode is inconsistent. For normal VHE we > unconditionally set CPTR_EL2.ZEN to 0b01 but only set the equivalent > field CPTR_EL2.SMEN to 0b01 if SME is present, for hVHE we will always > set the field 0b11 if SVE is not supported. Given the similarities > between the two extensions it would generally be expected that the code > handling SVE and SME would be very similar. > > Since CPTR_ELx.ZEN is RES0 when SVE is not implemented it is probably not > harmful to try to set the bits but it is better practice to not set > unimplemented bits so resolve the inconsistency in favour of checking if > SVE is present too. It is entirely possible that implementers 'disable' a feature by hiding it from the ID register, leaving the control bits completely functional. These systems are at odds with the architecture, though we probably shouldn't engage in _deliberately_ hostile programming patterns in the kernel :) > FPSIMD is also in theory optional though there's probably much more work to > handle the case where it is not implemented properly and that is not > something we see in practical systems. > > Signed-off-by: Mark Brown > --- > arch/arm64/include/asm/kvm_emulate.h | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h > index 3d6725ff0bf6..4cf53b4aa226 100644 > --- a/arch/arm64/include/asm/kvm_emulate.h > +++ b/arch/arm64/include/asm/kvm_emulate.h > @@ -584,15 +584,17 @@ static __always_inline u64 kvm_get_reset_cptr_el2(struct kvm_vcpu *vcpu) > u64 val; > > if (has_vhe()) { > - val = (CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN | > - CPACR_EL1_ZEN_EL1EN); > + val = (CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN); > + if (cpus_have_final_cap(ARM64_SVE)) > + val |= CPACR_EL1_ZEN_EL1EN; > if (cpus_have_final_cap(ARM64_SME)) > val |= CPACR_EL1_SMEN_EL1EN; > } else if (has_hvhe()) { > val = (CPACR_EL1_FPEN_EL0EN | CPACR_EL1_FPEN_EL1EN); > > - if (!vcpu_has_sve(vcpu) || > - (vcpu->arch.fp_state != FP_STATE_GUEST_OWNED)) > + if (cpus_have_final_cap(ARM64_SVE) && > + (!vcpu_has_sve(vcpu) || > + (vcpu->arch.fp_state != FP_STATE_GUEST_OWNED))) vcpu_has_sve() already tests system_supports_sve(), so I don't believe this hunk is necessary. -- Thanks, Oliver _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel