Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp25257063rwd; Sun, 2 Jul 2023 13:38:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlFznFEKv8Wm30u7MYbxuJ6xw/VDgaLei7OjgCf/4i/P5IFo1by6u5qiwVrjkPqhrj4r933n X-Received: by 2002:a05:6a00:1249:b0:63b:5c82:e209 with SMTP id u9-20020a056a00124900b0063b5c82e209mr9163306pfi.10.1688330320132; Sun, 02 Jul 2023 13:38:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688330320; cv=none; d=google.com; s=arc-20160816; b=e4bm5oVUrkL8gECpSNLGNZn7BfGXouhnPanLw5noaHGFw8UL76BCduA2XAo8bLz+6S A3uNRepkkDop2BrHKAzQPwZ5FtuxCZf1jpjBRYIwS09WCD3HhrvkjNvWTQda3ERg0LFk 8Do8v7JYyKq2/pjarma5oYOOPhePxagoAcFJrX0GbIOCelEd2WyeTBA+SqzbKb7/cxXq dSoy+dphW4I57cB65px4XMb4LyTkfYJ2seQ7UXTPmwZZkGKSiFfGZNhLAAwyK4pYoExI /sObOiOlhDStar73bcFWSHv7FIy11PQ6YlW7UzC337+VbQdq8Q9R/jrT12Jl7EA8mwhS OUbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c8VIXC089ptj6yGJUaHATBaHeAXB5YfgB6Y/p+J/MXM=; fh=6CwKNvP2ypYbEiVG2MQUj+OZD5mEl12GNBDntJHSUDQ=; b=ybw/FjDQ+kVPM8nzZRaWyhLgC2tTh+d+zq09fBtA3LCgZt+E+0N+QQHuR6uylaBP1n BTBvM1q6Nd/EZ0lETnaG7rcgnEt0qPDc7kgsajYMHz7OTB8N9qFAPGEF69JD15d68nXS Yhiyy4pWyAwl4Z+W1dsS6qoC1GDUn66sdjsa8hCnaRq1w0dQIInjpBjfK7fbj+J4RVRR OGMgi79dQhA+HArD6L8b6W5U042aIAzhaWWBUmAWaz++G0tvl6kMhZ2QT0SBU1c5Uo0e 0M9/2FNaiZmqWV8nl7w6xwfWkZnXHO1v+WA8CSTQ9fs3/Dq/mwbKWTzvYfubhdLDe5FZ CVZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MqD3qbhH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 30-20020a63165e000000b0055399574474si16847914pgw.797.2023.07.02.13.38.27; Sun, 02 Jul 2023 13:38:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MqD3qbhH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232353AbjGBTzx (ORCPT + 99 others); Sun, 2 Jul 2023 15:55:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231951AbjGBTzl (ORCPT ); Sun, 2 Jul 2023 15:55:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7939346AC; Sun, 2 Jul 2023 12:53:29 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE5C660C87; Sun, 2 Jul 2023 19:51:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F05CAC433C8; Sun, 2 Jul 2023 19:51:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688327475; bh=SEP2CzktpoE0uCCFCAsWQ24FTZXxeagAN1OVOP/WSpI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MqD3qbhHR2fd1eXOJBApVbVnfR81FgC/f7sIRwp+T/mgBsBlHJyF2b4MBHciFRK/a uTP5KVZQgb+aVfK1uupaCiLWdLJAk88CM1NPf1K+UnGyghmyCeWrR9UdpJfypy3+8/ LjWmuw2txXfz3cBKgWzKiOg5rKDClq338GhCFBPALhOF4EW3IPtZaqransZr4kCtqa ypPi5D1PIm5WKXoy2CjUyH02GGilJxIS6+o2pVmJGb6oI0TXhPhZU3eDzqVFsCRs+z CfI2BayVJYTbGRID7+ENnJ7sMzzdSuwYqqXCr0ZYa9g+1XefJJj7KiDwzfN5jpfCOj +1/TNc2GBPJEQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kristina Martsenko , Catalin Marinas , Sasha Levin , will@kernel.org, broonie@kernel.org, james.morse@arm.com, mark.rutland@arm.com, amit.kachhap@arm.com, maz@kernel.org, anshuman.khandual@arm.com, joey.gouly@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 6.4 07/12] arm64: cpufeature: detect FEAT_HCX Date: Sun, 2 Jul 2023 15:50:52 -0400 Message-Id: <20230702195057.1787686-7-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230702195057.1787686-1-sashal@kernel.org> References: <20230702195057.1787686-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.4.1 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kristina Martsenko [ Upstream commit b0c756fe996ac930033882ca56410639e5cad1ec ] Detect if the system has the new HCRX_EL2 register added in ARMv8.7/9.2, so that subsequent patches can check for its presence. KVM currently relies on the register being present on all CPUs (or none), so the kernel will panic if that is not the case. Fortunately no such systems currently exist, but this can be revisited if they appear. Note that the kernel will not panic if CONFIG_KVM is disabled. Reviewed-by: Catalin Marinas Signed-off-by: Kristina Martsenko Link: https://lore.kernel.org/r/20230509142235.3284028-3-kristina.martsenko@arm.com Signed-off-by: Catalin Marinas Signed-off-by: Sasha Levin --- arch/arm64/kernel/cpufeature.c | 8 ++++++++ arch/arm64/tools/cpucaps | 1 + 2 files changed, 9 insertions(+) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 7d7128c651614..9898ad77b1dba 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -364,6 +364,7 @@ static const struct arm64_ftr_bits ftr_id_aa64mmfr0[] = { static const struct arm64_ftr_bits ftr_id_aa64mmfr1[] = { ARM64_FTR_BITS(FTR_HIDDEN, FTR_NONSTRICT, FTR_LOWER_SAFE, ID_AA64MMFR1_EL1_TIDCP1_SHIFT, 4, 0), ARM64_FTR_BITS(FTR_VISIBLE, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR1_EL1_AFP_SHIFT, 4, 0), + ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR1_EL1_HCX_SHIFT, 4, 0), ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR1_EL1_ETS_SHIFT, 4, 0), ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR1_EL1_TWED_SHIFT, 4, 0), ARM64_FTR_BITS(FTR_HIDDEN, FTR_STRICT, FTR_LOWER_SAFE, ID_AA64MMFR1_EL1_XNX_SHIFT, 4, 0), @@ -2309,6 +2310,13 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .type = ARM64_CPUCAP_SYSTEM_FEATURE, .matches = is_kvm_protected_mode, }, + { + .desc = "HCRX_EL2 register", + .capability = ARM64_HAS_HCX, + .type = ARM64_CPUCAP_STRICT_BOOT_CPU_FEATURE, + .matches = has_cpuid_feature, + ARM64_CPUID_FIELDS(ID_AA64MMFR1_EL1, HCX, IMP) + }, #endif { .desc = "Kernel page table isolation (KPTI)", diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps index 40ba95472594d..e1de10fa080e0 100644 --- a/arch/arm64/tools/cpucaps +++ b/arch/arm64/tools/cpucaps @@ -32,6 +32,7 @@ HAS_GENERIC_AUTH_IMP_DEF HAS_GIC_CPUIF_SYSREGS HAS_GIC_PRIO_MASKING HAS_GIC_PRIO_RELAXED_SYNC +HAS_HCX HAS_LDAPR HAS_LSE_ATOMICS HAS_NESTED_VIRT -- 2.39.2