Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3263603rdb; Tue, 6 Feb 2024 11:58:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXJyvfmVDbLlbNSQUAPoxfBzW09tyToK3GjmTWOkwjJg2fVdtB80kfV56wmObPXutsrUMbBOL9VzKO4eDII6+H8EWVMH1kK7BnpEoLeWw== X-Google-Smtp-Source: AGHT+IH4e4coh8JIUTAkSiSzXbXY6ZcVL39MVTFyh3a4qYHKILwg+obYGonCdlM52TnkHISIRVic X-Received: by 2002:a05:622a:19a1:b0:42c:2ed5:ef99 with SMTP id u33-20020a05622a19a100b0042c2ed5ef99mr7704365qtc.1.1707249523169; Tue, 06 Feb 2024 11:58:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707249523; cv=pass; d=google.com; s=arc-20160816; b=oscFgPz8M6muDv9j6R5TmV5sMdJkCA2jI7LogEsGhRabSFTjglMTigu4n7ETkqvBtk YGDd5NAEf/g5fDj97yx2SVOg9ycSNVhuS7/yXBmbhNrPSu6I3ihURCcX6v3g6w7NTYcX THMYERBGHVV5GDSyWBtH/bSVFZXhHaMJNjusUvy+n6F9bskrA+8r2QeSdkp5tyxwgKlz j6rNrbS5Q4cg+942Z2jETXiapoBk4dzDOwFjn0Mk3RPV/TMrI90JFUQjlxZvxUR7cfXD U0z7E7n7efTM9dBsQt2h80NY2Neu2rAbrJAU2UpKrg/lk8+b7+gfyd7kj4emIbR1dCKB RwFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:to:from :dkim-signature:dkim-filter; bh=YiGmA9Lr1a/CDIgqHElD8PPnAN1LFYjN75PS7RDnPho=; fh=x/tbCgPZ4Y7sk10UQQqxs+45CjoCAl3W1iFL4nxj6t8=; b=NBVFeRBw6edXpTdBrkMM3Ogw9zty+Sh996L2CRLsBh3tCFYY14xrUK3RdPL8fiiehR eQf5H5fcYxYScp6NUksikzIcuPzpXYWoXGjQ5iYRqk86lNgoomrNkR2jOu0S6kGWqqf8 hdhPsTZHavPEQ8eXGTyogpf8z9uY4rVskq4KfVbv1H8C/VA7uLubkHSW/Blsl+uCdprR vxgSCGUTEJoZOGNxw9ZMyCKlo0Kju/N4rdWJ5wDk/A28SsCG6Kwc6Zl+guiqj1OdV6zX SIQclCZ93c6bKtFEF5M2sLZB3LAtsffEi5P/7XQpkTsLVFX6r/DcccYZCvV0HigQu9m1 DlqQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=QVf5neav; 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-55576-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55576-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=1; AJvYcCWLdAJXw2L61ejudGXQHXNDg9In4Uxe0bgIMZypK8pxJw2o5cqvUMPsOkUNYuEWgMpnzTBWLaAClrYYR+MFMBdFMfWxWUc++Nb6D1A3/A== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d14-20020ac85ace000000b0042c2e4f5c68si3160128qtd.631.2024.02.06.11.58.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 11:58:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55576-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=QVf5neav; 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-55576-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55576-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E8F431C21D49 for ; Tue, 6 Feb 2024 19:58:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CB553179BE; Tue, 6 Feb 2024 19:58:36 +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="QVf5neav" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9266617745 for ; Tue, 6 Feb 2024 19:58:34 +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=1707249516; cv=none; b=uMcooQiSAQ1dO8HfLcGFMTyzU1jEQwwPpG02iwC76dF6e5NFt+ZHSR8PHdOgC5Psif6HEHvl/8Sk01TGnjFdBnUnN/R9KZEqgIcu/oHXPdI6IFEByl12GoS3pP6qWqLMesVlJTYILyGfn8xWivAxsWwRiIElILgsEsmX/ZhDZ4c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707249516; c=relaxed/simple; bh=CSs8R3eAqFpZbozTGGxVMdRi1LPhZmwG0SUML7+4tx4=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=fraxAcukGdWpuc6EbHUVr6rMaSXEbZXtJaUOgKv6cFUAX+NH6UnLL7d8gkvYs6K7ebC1s7NcwP0RDJ3PAYInNXGSG2M2sMfKpiLK7vPkwjLlJTvQRnfFwpqpnmPC+CKoPOih2L754ZE+p/m7igQh8G+LA0dTCn/BEjfnTqtWS1o= 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=QVf5neav; 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 rrs24-12-35.corp.microsoft.com (unknown [131.107.8.19]) by linux.microsoft.com (Postfix) with ESMTPSA id E764F20B2000; Tue, 6 Feb 2024 11:58:33 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E764F20B2000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1707249514; bh=YiGmA9Lr1a/CDIgqHElD8PPnAN1LFYjN75PS7RDnPho=; h=From:To:Subject:Date:From; b=QVf5neav0galuOadt6P17o8D+jpDq8FW0dD+dOrJecGZiNAcOz3KgLTnX01F6RU9G Kgt5DG9JP3uEkIGH1aTeUYBiD23JfuLOCzEo5q+slprE1w1TSUoWfrvMQVnGpRPk9Q XZXfHj/Uf9P1AOnahuIRFutrj/ftsu+Qlsgbah5Y= From: Easwar Hariharan To: 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 , 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: [RFC PATCH] KVM: arm64: Override Microsoft Azure Cobalt 100 MIDR value with ARM Neoverse N2 Date: Tue, 6 Feb 2024 19:58:16 +0000 Message-Id: <20240206195819.1146693-1-eahariha@linux.microsoft.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. 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