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 6B080C7115B for ; Wed, 18 Jun 2025 17:40:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=mwJV4ciblRcjs2M0CBSNRIvWazcZCNwnnCgAOgHsOog=; b=fqbC1nh5ksUrmROs0ZkEGNB5vC 3kO+wYHvhFqW8rnFDLwK1994gEf5leTGk0S22FzHCbKOHnZut+mWI+OkQ6+WEdfU//QLvOKzb/Q1U qmmaXtq3VyM8fHxoyTSSg1TuTAOBmCqMNlF3vYfvsKo/SoOFIGXZtwtG4nm7qYxVLd78ofv/BEg2X CYkQk5fGvptijzpa0sj+XHKLJ/YtJhbTpHuTSJynp7iFqoJ9QF61Ff29Gz6j2NKw2pCn1KNKHhMKo TptO8Py3Rige2/3NdE3D6xFvA7K+eAtzDmjyAXssNuOsr7afn1XJaEjulg9HM2oDYRBLBBDvmxcFK wp+BYm8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uRwlu-0000000Assd-2FRG; Wed, 18 Jun 2025 17:40:26 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uRvsW-0000000AkaH-2jHX for linux-arm-kernel@lists.infradead.org; Wed, 18 Jun 2025 16:43:15 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CBA7D5C58B0; Wed, 18 Jun 2025 16:40:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BBBBC4CEE7; Wed, 18 Jun 2025 16:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750264991; bh=Y2gd51D/BVFx6eKV+gJtQH2NJBTOAm9v65zoDB4v+hw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XdL1rTTvXn2f2C5znx1nHKrTEI6L05kv4a7bQuckbbMajfmxn9IYpHw6mkrdPEoph X0Y/ZOYGOBM1V6Cxyf+m4RdBWa8QmLDiBO6lKzC4EWIKi7fa/MjOxsb+yjl+cjaLEQ 7GjxTqk8n7gv3hLlySnaEe7iX4baZDsRgVD5yRpG9iaK8N82fJ+gf+BkOUXm2zydB+ rPEcL9TEuRt/kSuEPp0reRmnipBEjTn34ikcy4IMRbba6D0g09hkDefIuyAZrknhWW BhCbnVxVCKRSbKFZv6DQm6GJd5xmiJNwSTq3KbHFLj7RYNXY92E3nwBLPy4ykDODm4 cw9DTzZzVtAzg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1uRvsR-007ywr-NA; Wed, 18 Jun 2025 17:43:08 +0100 Date: Wed, 18 Jun 2025 17:43:07 +0100 Message-ID: <86ldppc86c.wl-maz@kernel.org> From: Marc Zyngier To: Yeoreum Yun Cc: catalin.marinas@arm.com, pcc@google.com, will@kernel.org, broonie@kernel.org, anshuman.khandual@arm.com, joey.gouly@arm.com, yury.khrustalev@arm.com, oliver.upton@linux.dev, frederic@kernel.org, akpm@linux-foundation.org, surenb@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH v9 03/10] arm64/kvm: expose FEAT_MTE_TAGGED_FAR feature to guest In-Reply-To: <20250618084513.1761345-4-yeoreum.yun@arm.com> References: <20250618084513.1761345-1-yeoreum.yun@arm.com> <20250618084513.1761345-4-yeoreum.yun@arm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: yeoreum.yun@arm.com, catalin.marinas@arm.com, pcc@google.com, will@kernel.org, broonie@kernel.org, anshuman.khandual@arm.com, joey.gouly@arm.com, yury.khrustalev@arm.com, oliver.upton@linux.dev, frederic@kernel.org, akpm@linux-foundation.org, surenb@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org 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-20250618_094313_154581_1D52799B X-CRM114-Status: GOOD ( 19.05 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In general, please use a patch title format that matches the one used for the subsystem. For KVM, that'd be "KVM: arm64: Expose ..."/ On Wed, 18 Jun 2025 09:45:06 +0100, Yeoreum Yun wrote: > > expose FEAT_MTE_TAGGED_FAR feature to guest. > > Signed-off-by: Yeoreum Yun > --- > arch/arm64/kvm/sys_regs.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 76c2f0da821f..c8c92cb9da01 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -1586,7 +1586,7 @@ static u64 __kvm_read_sanitised_id_reg(const struct kvm_vcpu *vcpu, > const struct sys_reg_desc *r) > { > u32 id = reg_to_encoding(r); > - u64 val; > + u64 val, mask; > > if (sysreg_visible_as_raz(vcpu, r)) > return 0; > @@ -1617,8 +1617,12 @@ static u64 __kvm_read_sanitised_id_reg(const struct kvm_vcpu *vcpu, > val &= ~ARM64_FEATURE_MASK(ID_AA64PFR1_EL1_MPAM_frac); > break; > case SYS_ID_AA64PFR2_EL1: > - /* We only expose FPMR */ > - val &= ID_AA64PFR2_EL1_FPMR; > + mask = ID_AA64PFR2_EL1_FPMR; > + > + if (kvm_has_mte(vcpu->kvm)) > + mask |= ID_AA64PFR2_EL1_MTEFAR; > + > + val &= mask; I don't think there is a need for an extra variable, and you could follow the pattern established in this file by writing this as: val &= (ID_AA64PFR2_EL1_FPMR | (kvm_has_mte(vcpu->kvm) ? ID_AA64PFR2_EL1_MTEFAR : 0)); Not a big deal though. Thanks, M. -- Without deviation from the norm, progress is not possible.