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 B122CC4828D for ; Wed, 7 Feb 2024 09:50: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: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7B7WBxr7BxZOg/5eAd2gNmqF8sw+9U6P3RCRXJIw4QA=; b=dBkuEuUzeEd8vI zud2beAq5aK6I83XGVRcQ0HLtNL+iX7tokaiDwHyV6qO28FtjP7F1+55em9VlSqZrS6GMa94ztZQY L22CDVdjLhgQ3waCgB+JSGlnLtlEAeXCTn4D0GTmpUOm2m9EfTIyHU/BT2Td89GRXe8fi4Cxo/N5d sfmBHT0QT1058Splg5BjXgPAgrS0PiPOLWygziO61G+SL4gw7XHC390+SaSZLhBlrwKNzvEObFOE8 cp6aFMEBXtU+nlFf9JLoVxEQlXNxN8utwSfo/YJQZ3DV/xQDW1HhMhCaN+jDGku09Kgg8nfjNcKSl Tb10mIhQebqODZXFrfrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXeZN-0000000AFko-19ub; Wed, 07 Feb 2024 09:50:17 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rXeZK-0000000AFjQ-0Zlz for linux-arm-kernel@lists.infradead.org; Wed, 07 Feb 2024 09:50:15 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1A0CB61788; Wed, 7 Feb 2024 09:50:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF0FCC433C7; Wed, 7 Feb 2024 09:50:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707299412; bh=Z7RlkR6pBXTxcfR2yNl0x4kWdlPW84U0WWRNxTe6kcQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Cw+RmZKYsDqxZqNaHIC2ZXIc+kIEFcWadvDoFHd+50/OKP0cOSu/DJLC2gUqzG2hY JY8awGsz2UzFQDE87QukobjDEyia+PAuvTIqnPZGgnzdupFyVLBOVt8sssbb9gV42p h9r4z4nx7HJWLK74m0LFIqlE5CBaBucZ6SGEXRZoB+fOMmBVxt7QVSI/9Bu9FKZRYh Jj39gqjdmcXLPILG43hIz/NXeAj/6SiaJ0SqCrfUW1GkK/KQzaEaMExPGO0vvSHAFQ t74o/4WYmAG7i3CAlUoR7lbeZIl2wN7o8EYKvsUIdoYwCrCmA2bnCRKj+1It5iylD/ 5/EsKYZOrLlsw== 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 1rXeZG-0014r2-87; Wed, 07 Feb 2024 09:50:10 +0000 Date: Wed, 07 Feb 2024 09:50:09 +0000 Message-ID: <86r0ho61ta.wl-maz@kernel.org> From: Marc Zyngier To: Easwar Hariharan Cc: Catalin Marinas , Will Deacon , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Andre Przywara , Rob Herring , Fuad Tabba , Joey Gouly , Kristina Martsenko , linux-arm-kernel@lists.infradead.org (moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)), linux-kernel@vger.kernel.org (open list), kvmarm@lists.linux.dev (open list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)) Subject: Re: [RFC PATCH] KVM: arm64: Override Microsoft Azure Cobalt 100 MIDR value with ARM Neoverse N2 In-Reply-To: <20240206195819.1146693-1-eahariha@linux.microsoft.com> References: <20240206195819.1146693-1-eahariha@linux.microsoft.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/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: eahariha@linux.microsoft.com, catalin.marinas@arm.com, will@kernel.org, oliver.upton@linux.dev, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, andre.przywara@arm.com, robh@kernel.org, tabba@google.com, joey.gouly@arm.com, kristina.martsenko@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev 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-20240207_015014_289507_082A9B73 X-CRM114-Status: GOOD ( 24.55 ) 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 Tue, 06 Feb 2024 19:58:16 +0000, Easwar Hariharan wrote: > > Several workload optimizations and errata depend on validating that the > optimization or errata are applicable to the particular CPU by checking > the MIDR_EL1 system register value. With the Microsoft implementer ID > for Azure Cobalt 100, the value doesn't match and ~20-25% performance > regression is seen in these workloads. Override the Azure Cobalt 100 > value and replace it with the default ARM Neoverse N2 value that Azure > Cobalt 100 is based on. Since you don't disclose *why* this particular value should have any impact on the behaviour of the kernel, the answer should be "Thanks, but no, thanks". Whatever the reason is for doing so, you should make it plain what you are working around. Blindly overriding ID registers is not an option, and you should simply add your MIDR value to whatever errata list that actually matches your implementation. > > Signed-off-by: Easwar Hariharan > --- > arch/arm64/include/asm/cputype.h | 3 ++- > arch/arm64/include/asm/el2_setup.h | 5 +++++ > arch/arm64/kvm/sys_regs.c | 9 ++++++++- > 3 files changed, 15 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h > index 7c7493cb571f..0450c6c32377 100644 > --- a/arch/arm64/include/asm/cputype.h > +++ b/arch/arm64/include/asm/cputype.h > @@ -262,7 +262,8 @@ is_midr_in_range_list(u32 midr, struct midr_range const *ranges) > */ > static inline u32 __attribute_const__ read_cpuid_id(void) > { > - return read_cpuid(MIDR_EL1); > + return (read_cpuid(MIDR_EL1) == 0x6D0FD490 ? 0x410FD490 : > + read_cpuid(MIDR_EL1)); > } > > static inline u64 __attribute_const__ read_cpuid_mpidr(void) > diff --git a/arch/arm64/include/asm/el2_setup.h b/arch/arm64/include/asm/el2_setup.h > index b7afaa026842..502a14e54a31 100644 > --- a/arch/arm64/include/asm/el2_setup.h > +++ b/arch/arm64/include/asm/el2_setup.h > @@ -138,6 +138,11 @@ > .macro __init_el2_nvhe_idregs > mrs x0, midr_el1 > mrs x1, mpidr_el1 > + ldr x2, =0x6D0FD490 > + cmp x0, x2 > + bne .Loverride_cobalt100_\@ > + ldr x0, =0x410FD490 > +.Loverride_cobalt100_\@: > msr vpidr_el2, x0 > msr vmpidr_el2, x1 > .endm > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > index 30253bd19917..8ea9c7fdabdb 100644 > --- a/arch/arm64/kvm/sys_regs.c > +++ b/arch/arm64/kvm/sys_regs.c > @@ -3574,7 +3574,14 @@ id_to_sys_reg_desc(struct kvm_vcpu *vcpu, u64 id, > return ((struct sys_reg_desc *)r)->val; \ > } > > -FUNCTION_INVARIANT(midr_el1) > +static u64 get_midr_el1(struct kvm_vcpu *v, const struct sys_reg_desc *r) > +{ > + ((struct sys_reg_desc *)r)->val = read_sysreg(midr_el1); > + if (((struct sys_reg_desc *)r)->val == 0x6D0FD490) > + ((struct sys_reg_desc *)r)->val == 0x410FD490; As pointed out to me by Joey, this line is really interesting, and shows that you didn't really test this patch. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel