[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ed6c25dc-d5c7-4f15-8fdc-f2adf209e638@linux.microsoft.com>
Date: Thu, 8 Feb 2024 11:16:10 -0800
From: Easwar Hariharan <eahariha@...ux.microsoft.com>
To: Mark Rutland <mark.rutland@....com>
Cc: Catalin Marinas <catalin.marinas@....com>, Will Deacon <will@...nel.org>,
Marc Zyngier <maz@...nel.org>, Oliver Upton <oliver.upton@...ux.dev>,
James Morse <james.morse@....com>, Suzuki K Poulose
<suzuki.poulose@....com>, Zenghui Yu <yuzenghui@...wei.com>,
Andre Przywara <andre.przywara@....com>, Rob Herring <robh@...nel.org>,
Fuad Tabba <tabba@...gle.com>, Joey Gouly <joey.gouly@....com>,
Kristina Martsenko <kristina.martsenko@....com>,
"moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)"
<linux-arm-kernel@...ts.infradead.org>,
open list <linux-kernel@...r.kernel.org>,
"open list:KERNEL VIRTUAL MACHINE FOR ARM64 (KVM/arm64)"
<kvmarm@...ts.linux.dev>
Subject: Re: [RFC PATCH] KVM: arm64: Override Microsoft Azure Cobalt 100 MIDR
value with ARM Neoverse N2
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 <eahariha@...ux.microsoft.com>
>> ---
>> 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
>>
>>
Powered by blists - more mailing lists