Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp196099rdh; Wed, 7 Feb 2024 01:51:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWCjZ8ruqG2GN7A38D/7WpA4yVkfJo6KuFMmFCYeUP8bmACaheUscejHNlIVU/g1FTxUHVrEn7jEhiWwnMP8+a2sIVtQ9C1Y1PpD3oI8g== X-Google-Smtp-Source: AGHT+IGlJU1FNcQpMqgSXiX5h5Ag520UdBwk8nDzqAA3Ohmwm18345umYbM3V02tTRInE5ni409G X-Received: by 2002:a05:6358:d09b:b0:178:92dc:8a32 with SMTP id jc27-20020a056358d09b00b0017892dc8a32mr2480621rwb.20.1707299485339; Wed, 07 Feb 2024 01:51:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707299485; cv=pass; d=google.com; s=arc-20160816; b=JVkirbSRHNWQT3cSya3MbhAjpQdF6iwVAnuDf3bEGSWw47TY1PjHgLaeAHvNeBzJQd r5SOri7x2C8O+2NENNOlhqoUAPIzKgTyfLTGgGs99Gn8/ibzwLUr0eQtY3gehVciCo5c EeOPQIl5m/GDPvni0H2YntOH/FOD4UavI4sqO357MTc0MCMD07chqtwckfzIUXiE7reJ SGkNb92taX5E/+LIcsrXXsvu90wOJdXSuRdaZFIu6FuUc1aooQoYaut1hSqjWeY/SGZg pwT9ipXvLyFs/2VtGfi73O78ZFjyUClQmdELWKXF0dePb3AFAetsnChQggHLuqgLe2eF Os2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=/WKyfF8V5VuCkMWjFlB3DJJj87SuIjUS7UN1yfrxzHk=; fh=AXpqJNCi41KOVmNuBr97srooi4Dasby5zP+hE+tMZgM=; b=nRRaKlbe8fmCpKWofRE9Hi6Q8nQQcp3M4rnUYcBpSr8SBGgpnY9DjAh1YmJbPUIY2F kqeoKX8IIR3fKJAnDvK+GPrkJzSL4Z/NAsl3dC7Ce5KnpJTUnAo5mgQZ7WR3Hzd/70Xn b3gHtJ2BdEwJTD8Ky580QoWwMjaBNn72GcLmLzFM4cfIEx1U4Wv9HeJyPGgcci9PA1Ip UQTy0uocHxzjzwoQtraKP4Qu0+t5vfn6ee4Mv7rZ3tkkpt2356NfbYFPGzVgJZYit+/M 0KpWYc7Vz5nnGn09ZO/Ai7wib3aRdR98xpSHGUHDENKrw/THOu6ERrU/paHRpm8+Fs5p OZcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Cw+RmZKY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-56249-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56249-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCUvZaYyTvGs/hDcf9cIa5nLbfNplau1yJ0ChDGODE+B880QCXpyZQ1Mg2n1FzxM3V814ro7tc5gOceKUpyssWZF5RG7IzOAQ6ckOXwADg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g26-20020a63375a000000b005dbf27229f5si1161943pgn.889.2024.02.07.01.51.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 01:51:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56249-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Cw+RmZKY; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-56249-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56249-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2580C289569 for ; Wed, 7 Feb 2024 09:50:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C76A23761; Wed, 7 Feb 2024 09:50:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Cw+RmZKY" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5394122F17; Wed, 7 Feb 2024 09:50:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707299413; cv=none; b=UhSd+zhf6hSccZboKzyZHu9xZ6Ib3yLqYWj/fc3rBPvKfHseE0eayGMt2AzK+5HQRX8XEnU+NhvK5Itwlgm4mnxsckwx+e3xDuHSNCaCFTOulfNdfjeHyZA2p9+vCnx/Alr0CtziwxExGdkEjYST5SuW69swRBq18PnmvkaV8ow= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707299413; c=relaxed/simple; bh=Z7RlkR6pBXTxcfR2yNl0x4kWdlPW84U0WWRNxTe6kcQ=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=acun2f4YGz2nhRbVJbTo4g8VYcZkeS9UF5R0JemNOJUQ30YSaUhe/ZQOMDcLxoesP6Bodc+g2Kq0PEa8H5IwynGJTYrsKieOvNH0NOhOWCzI7zJi0RBBtnM8w5LFcPaCrcMLs09/LS2IxJORUjGFIrT3R0eHuzpxiAk3bk7WNRc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Cw+RmZKY; arc=none smtp.client-ip=10.30.226.201 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: 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 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.