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 X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 023C2C433E1 for ; Tue, 25 Aug 2020 08:54:45 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BCA062074D for ; Tue, 25 Aug 2020 08:54:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="So+HQ0Jd"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="UGw4fE3b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BCA062074D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=9IOakoiyAa9ANYY/I7BgZqtOhcLdBvJ+kugFA7b3sJ8=; b=So+HQ0JdQNk7GIxIUet0QVlV3 8jEUUzpy8f9b8J3VAv07f0D4bv9dhTssvCOCbRKDHNNOHnSDLpu2ZA96PwR2Ij8j5C42hwqdKnKtm au/n9eH4ZlItk5GaLadjpV/jTwfsnEZTiWhiPJSwpOs8ZeRf3O7+0qYRW2e/Cac0MvsWgHL3+ebDL Q7AsuScZBPkaA3uMfWgFtROyl71WuoPlPgrmN0bH4J5pdzXZNJ9OclIIq9QJSUm/nUdZ+jwt+91MX N5gsOJbm+YIeLxDvgihwdT7Kxw+bvI7GOYE9gRbKDxh8LBjOlg9RP9PFrAesoqP4zhrY4/3/l+qxt tYlnL+13Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kAUhl-0001Q9-HA; Tue, 25 Aug 2020 08:53:21 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kAUhj-0001Pg-P8 for linux-arm-kernel@lists.infradead.org; Tue, 25 Aug 2020 08:53:20 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (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 D67C42065F; Tue, 25 Aug 2020 08:53:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598345599; bh=qVtzvPt8utxsO0tcKG1A7vsPaEcIuMmBWjFifpCIBCk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=UGw4fE3bO3bG0OD/6ngOZpNCwnpSNW1lWwt9CdFx/4xLXnKBbUzoGdelwmUa2k+4h NbPndi7P0kyFKZ7ULQeKTuUEjXWxQzwemugWpvhd7DlH0Q5zNdxgLtb01zm1FMVzaK aCiGznnDpvglZIab7NdenzVoQnWT7dLWdDRNjdbM= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kAUhg-006TYE-R5; Tue, 25 Aug 2020 09:53:16 +0100 MIME-Version: 1.0 Date: Tue, 25 Aug 2020 09:53:16 +0100 From: Marc Zyngier To: Catalin Marinas , Vincenzo Frascino Subject: Re: [PATCH v8 03/28] arm64: mte: CPU feature detection and initial sysreg configuration In-Reply-To: <20200824182758.27267-4-catalin.marinas@arm.com> References: <20200824182758.27267-1-catalin.marinas@arm.com> <20200824182758.27267-4-catalin.marinas@arm.com> User-Agent: Roundcube Webmail/1.4.8 Message-ID: <61bba3c1948651a5221b87f2dfa2872f@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: catalin.marinas@arm.com, vincenzo.frascino@arm.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, will@kernel.org, Dave.Martin@arm.com, szabolcs.nagy@arm.com, kevin.brodsky@arm.com, andreyknvl@google.com, pcc@google.com, akpm@linux-foundation.org, Suzuki.Poulose@arm.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-20200825_045319_982025_ED7521F7 X-CRM114-Status: GOOD ( 26.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Suzuki K Poulose , Szabolcs Nagy , Andrey Konovalov , Kevin Brodsky , Peter Collingbourne , linux-mm@kvack.org, Andrew Morton , Will Deacon , Dave P Martin , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-08-24 19:27, Catalin Marinas wrote: > From: Vincenzo Frascino > > Add the cpufeature and hwcap entries to detect the presence of MTE. Any > secondary CPU not supporting the feature, if detected on the boot CPU, > will be parked. > > Add the minimum SCTLR_EL1 and HCR_EL2 bits for enabling MTE. The Normal > Tagged memory type is configured in MAIR_EL1 before the MMU is enabled > in order to avoid disrupting other CPUs in the CnP domain. > > Signed-off-by: Vincenzo Frascino > Co-developed-by: Catalin Marinas > Signed-off-by: Catalin Marinas > Cc: Will Deacon > Cc: Marc Zyngier > Cc: Suzuki K Poulose > --- > > Notes: > v8: > - Move the SCTLR_EL1, MAIR_EL1, GCR_EL1 and TFSR*_EL1 > initialisation to > __cpu_setup before the MMU is enabled. While early MAIR_EL1 is > desirable to avoid conflicting with other CPUs in a CnP domain > the > TFSR_EL1 and GCR_EL1 will only come in handy later when support > for > in-kernel MTE is added. > > v7: > - Hide the MTE ID register field for guests until MTE gains support > for KVM. > > arch/arm64/include/asm/cpucaps.h | 3 ++- > arch/arm64/include/asm/cpufeature.h | 6 ++++++ > arch/arm64/include/asm/hwcap.h | 2 +- > arch/arm64/include/asm/kvm_arm.h | 2 +- > arch/arm64/include/asm/sysreg.h | 1 + > arch/arm64/include/uapi/asm/hwcap.h | 2 +- > arch/arm64/kernel/cpufeature.c | 17 +++++++++++++++++ > arch/arm64/kernel/cpuinfo.c | 2 +- > arch/arm64/kvm/sys_regs.c | 2 ++ > arch/arm64/mm/proc.S | 24 ++++++++++++++++++++++++ > 10 files changed, 56 insertions(+), 5 deletions(-) > > diff --git a/arch/arm64/include/asm/cpucaps.h > b/arch/arm64/include/asm/cpucaps.h > index 07b643a70710..1937653b05a3 100644 > --- a/arch/arm64/include/asm/cpucaps.h > +++ b/arch/arm64/include/asm/cpucaps.h > @@ -64,7 +64,8 @@ > #define ARM64_BTI 54 > #define ARM64_HAS_ARMv8_4_TTL 55 > #define ARM64_HAS_TLB_RANGE 56 > +#define ARM64_MTE 57 > > -#define ARM64_NCAPS 57 > +#define ARM64_NCAPS 58 > > #endif /* __ASM_CPUCAPS_H */ > diff --git a/arch/arm64/include/asm/cpufeature.h > b/arch/arm64/include/asm/cpufeature.h > index 89b4f0142c28..680b5b36ddd5 100644 > --- a/arch/arm64/include/asm/cpufeature.h > +++ b/arch/arm64/include/asm/cpufeature.h > @@ -681,6 +681,12 @@ static __always_inline bool > system_uses_irq_prio_masking(void) > cpus_have_const_cap(ARM64_HAS_IRQ_PRIO_MASKING); > } > > +static inline bool system_supports_mte(void) > +{ > + return IS_ENABLED(CONFIG_ARM64_MTE) && > + cpus_have_const_cap(ARM64_MTE); > +} > + > static inline bool system_has_prio_mask_debugging(void) > { > return IS_ENABLED(CONFIG_ARM64_DEBUG_PRIORITY_MASKING) && > diff --git a/arch/arm64/include/asm/hwcap.h > b/arch/arm64/include/asm/hwcap.h > index 22f73fe09030..0d4a6741b6a5 100644 > --- a/arch/arm64/include/asm/hwcap.h > +++ b/arch/arm64/include/asm/hwcap.h > @@ -95,7 +95,7 @@ > #define KERNEL_HWCAP_DGH __khwcap2_feature(DGH) > #define KERNEL_HWCAP_RNG __khwcap2_feature(RNG) > #define KERNEL_HWCAP_BTI __khwcap2_feature(BTI) > -/* reserved for KERNEL_HWCAP_MTE __khwcap2_feature(MTE) */ > +#define KERNEL_HWCAP_MTE __khwcap2_feature(MTE) > > /* > * This yields a mask that user programs can use to figure out what > diff --git a/arch/arm64/include/asm/kvm_arm.h > b/arch/arm64/include/asm/kvm_arm.h > index 8a1cbfd544d6..6c3b2fc922bb 100644 > --- a/arch/arm64/include/asm/kvm_arm.h > +++ b/arch/arm64/include/asm/kvm_arm.h > @@ -78,7 +78,7 @@ > HCR_AMO | HCR_SWIO | HCR_TIDCP | HCR_RW | HCR_TLOR | \ > HCR_FMO | HCR_IMO) > #define HCR_VIRT_EXCP_MASK (HCR_VSE | HCR_VI | HCR_VF) > -#define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK) > +#define HCR_HOST_NVHE_FLAGS (HCR_RW | HCR_API | HCR_APK | HCR_ATA) > #define HCR_HOST_VHE_FLAGS (HCR_RW | HCR_TGE | HCR_E2H) Why is HCR_ATA only set for nVHE? HCR_EL2.ATA seems to apply to both, doesn't it? > > /* TCR_EL2 Registers bits */ [...] > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 077293b5115f..59b91f58efec 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -1131,6 +1131,8 @@ static u64 read_id_reg(const struct kvm_vcpu > *vcpu, > if (!vcpu_has_sve(vcpu)) > val &= ~(0xfUL << ID_AA64PFR0_SVE_SHIFT); > val &= ~(0xfUL << ID_AA64PFR0_AMU_SHIFT); > + } else if (id == SYS_ID_AA64PFR1_EL1) { > + val &= ~(0xfUL << ID_AA64PFR1_MTE_SHIFT); Hiding the capability is fine, but where is the handling of trapping instructions done? They should result in an UNDEF being injected. Thanks, M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel