Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp486961rdb; Thu, 8 Feb 2024 11:28:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IGajtQrVWBIjgzWURm63qlpSFzVu5z3WpajvZS8v5uiBVf/xiWS1eEzTCQzYwpXzoos9qzO X-Received: by 2002:a17:906:f203:b0:a3b:7216:3091 with SMTP id gt3-20020a170906f20300b00a3b72163091mr229008ejb.20.1707420491214; Thu, 08 Feb 2024 11:28:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707420491; cv=pass; d=google.com; s=arc-20160816; b=prDwRh1A/ZEEz+9maqUv9stMYyeKi4o7ZVgX8R01ONBebEdj6buNsgNMELbnSuPrTi jFfSIP9j8KMwf4a+bNms3Boz0LLJDw95oI/9ZojtIpbx8bIR39D4YZPTavmtmB/z0HH6 x4vsiF7mZA/qFYlxAloT15Rjl0LwgvTpJ0ugBTvyqiCNGLMYFVQjrFHO7hhPF5tf3V9B dY7RZ3uzOfVJL+uXWVhwCyhTexSKo+g/hTnfFUueGYkTVvPrIvSYIgdN6fGy4iblFh4Y x6TXx5ye43jPOmw/Q6AW4Uy23W56vZ4edvIIl50D9ehYcshGTSkW+HJs200aTfuEoDHK eFkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-filter; bh=u7Sr1GivyYQRssWu9Sxm5FwiQjNYTxwfTxEdxVnZrog=; fh=0yccG4DFdJldyBGz5IcwOfAsW4VvdxK8hAQGpEaXzeY=; b=wt9pF6j+JDuPwtX5wDgOC+Zsliy1DMH+Qr/87+OO7nQgrQQ5MOmzkEbGdR6xoCoEVb bGYOr5UABC2t04TGnAgwlwxloqplmELMkdRPOsbL7pRf8OxKoITKVxi+xw05PaBRRg77 we8BSKjOqFyRdNEq1leV7G5X93qEvA8AGFKm5A86QXXVBDHV22TnSgKMepCfV8A31rEV t9ga527MsVCvOKsRlookzv3VkV4seIB0Oe4lW0iNuWrfJnOQfyeZydG9KVyLIVJt3HQW GqjXi/CElEx0GQdUgjrip/MaCTmlwlafd3NsUQxS+/A/uN7O9cCaA1Mh2SULd/hCBJeP HY8Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=mVhRmfC8; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-58606-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58606-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com X-Forwarded-Encrypted: i=2; AJvYcCWF9Nam9cj3vrYIiF5/9NFBQ+ThARpb080Ugdff6DwULcUrXyp+M4FwOZ/QIgV7JjygXmuPGKtp6DKT5PP4LLWRDrtYVMIgD1PluNxLpw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id yr20-20020a170907335400b00a23619be213si319822ejb.159.2024.02.08.11.28.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 11:28:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58606-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=mVhRmfC8; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-58606-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58606-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 032B51F2947D for ; Thu, 8 Feb 2024 19:16:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5E8E374DD; Thu, 8 Feb 2024 19:16:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="mVhRmfC8" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F96D37167 for ; Thu, 8 Feb 2024 19:16:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707419779; cv=none; b=Eu4U0+XdJAJuF+DS2gyRfQ5a3nK/OahKKgmBEL4LM7QpfG8qJQ4QkrgqZqmU2jkzemuTvtxqohfkNZRicfXs2tFYcxehCYEBqwsAsObmt+97KzZH4BK52bHmh8+Tr66SjFAHbYVaWCLpOsmFndapDZkZM/OAMYbHXw6RhGbwI5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707419779; c=relaxed/simple; bh=b6c2t9B/pfloTiLl3QpaQz8LmLqZFIjOHYHcQTLOATY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ODmthx2uahpy8beSCzveYpOBlpTWTi00whZMHOrFqFuqpUjhye5LNfG8rRkZulh+yOOCYt4kGr7L74v2NdM81vOmM+SIvxDpFjXD01cC6sYznWdrsZI7PSHuIz/QI6V5MYAbgW3GXoXawWaJi01ZC421TUFAG8Go7yR0sUB/1Ao= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=mVhRmfC8; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from [100.64.216.206] (unknown [20.29.225.195]) by linux.microsoft.com (Postfix) with ESMTPSA id 03A0D207E718; Thu, 8 Feb 2024 11:16:10 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 03A0D207E718 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707419771; bh=u7Sr1GivyYQRssWu9Sxm5FwiQjNYTxwfTxEdxVnZrog=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=mVhRmfC8kQaVixsTdXy+xkNZpGrlA/MqXeC1o5PHI3bMWayHqbVhTVa+eNbHRSGKG LnHztq2MuuhiV41949Vmm2cz5jd2l7OiC2Zygyt545g873v1mN3H59AWkn3C47z4lY jeic5HaEFHEdLqFsoDO/GZe3uOKEnkkok1uiYnkY= Message-ID: Date: Thu, 8 Feb 2024 11:16:10 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH] KVM: arm64: Override Microsoft Azure Cobalt 100 MIDR value with ARM Neoverse N2 Content-Language: en-US To: Mark Rutland Cc: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Andre Przywara , Rob Herring , Fuad Tabba , Joey Gouly , Kristina Martsenko , "moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)" , open list , "open list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)" References: <20240206195819.1146693-1-eahariha@linux.microsoft.com> From: Easwar Hariharan In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/7/2024 1:49 AM, Mark Rutland wrote: > On Tue, Feb 06, 2024 at 07:58:16PM +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. > > NAK to rewriting the MIDR in the kernel; we do not lie to userspace about the > MIDR, and this is not a can of worms we're going to open. > > If you desire some microarchitectural performance optimizations in particular > projects, please submit patches to those projects to understand your MIDR > value. Understood. > > Further, if Azure Cobalt 100 is based on ARM Neoverse N2, you presumably suffer > from the same errata; can you comment on that at all? e.g. are there any > changes in this part that *might* lead to differences in errata and/or > workarounds? How do the MIDR_EL1.{Variant,Revision} values compare to that of > Neoverse N2? > Yes, Azure Cobalt 100 suffers from the same errata as Neoverse N2. We had changes in the implementation, but according to our hardware folks, the Neoverse N2 errata we are affected by so far aren't affected by the changes made for Azure Cobalt 100. > Mark. > >> 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; >> + return ((struct sys_reg_desc *)r)->val; >> +} >> + >> FUNCTION_INVARIANT(revidr_el1) >> FUNCTION_INVARIANT(aidr_el1) >> >> -- >> 2.34.1 >> >>