Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4149290pxb; Mon, 27 Sep 2021 10:23:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUnNfZnZ+pwuhYP1zxGvvucOpqbA6Ky+pu4WTbQkl4U5ba3Ico+yETB/JYzqw6BNFg15HI X-Received: by 2002:aa7:c744:: with SMTP id c4mr1391715eds.0.1632763412912; Mon, 27 Sep 2021 10:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632763412; cv=none; d=google.com; s=arc-20160816; b=wfUzuTNa+BJ1vNIK5LeHEh0/0WJ2hVeAP1Fb2L379OP/kM0xkeq7l4lQO8HDliMDjo 7KCFzUkZuEbsNWEqQGWsOPnmjqQ+J9nXN61mNpp08wvmpkgaeN1RKygUjYDpFbwVk0x8 tE+vkoVInarblpOG7s+vWzFoyI5za+M13nEd6e/bgZjeU7X8ok5uyo3r93RqGLAukt1K apQbLPu5aRFhO8PL2A2tUFf16m9ELd3mkR6XqmCj27ej5lp3ofl9aI6y8b6dMFXKlFOS i40hQYIpSdbx4HdZ8lHlP1yTmIYZObJKiqvOI2aB9bMZUaa6HLOTaGbUavan/XDnBL1j L29g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rWhL201FGJ3JYsWw9cZgX9wnO3hJP+r9YiWyJn+KSbU=; b=JOHth0MSNBo7Qxrhtz4TgYlYxVKN2vQ9W9niGesdi8hRa+Ovu1fed8dbwRmc5zphOa o0OVY3J8RpQDWjy4MtPyRkNMKuk8InZlkuB+XZsOB6m7Jj2/QHg25SqH0DHWpVFcm9xn qNcQT5vLP5dP5/xWnAgAbDwGBlONpXWT3RLvzAVRyUh3xWQrlNwnn8B8OBFSU0A5so1U 7dez409Co6397dWgq54y5sH6Dg2GaZ0LNaR+VWqYt2muP43/e9tdmPxC4V8Z9gwQoaUo dz8shYgGUiDd3xM3uHjFrUchD05jAF6/OyJSO0qBRVP9hFzi7/WMHkgI+IGs1ajfA1ul s2pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gXUWf7m1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j24si19173127ejo.673.2021.09.27.10.23.05; Mon, 27 Sep 2021 10:23:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gXUWf7m1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236937AbhI0RWp (ORCPT + 99 others); Mon, 27 Sep 2021 13:22:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:34152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236839AbhI0RTj (ORCPT ); Mon, 27 Sep 2021 13:19:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C5B261351; Mon, 27 Sep 2021 17:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632762769; bh=+GhK0bDX6LvkCyLXmdoqKui7v2KvZh5h9Ot+wuqJovQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gXUWf7m19fJb7TyNPmaKokH4pn+7gF8NTmSo5qUgGAyoZsHFl7Z8rFfF3LkRZFeCJ BKmab+psULBkTVL+J71qR5GJsdTzs0MCp28PoA1Zj67/cH6bb2xqwTBpp8shHnizsa kXQXfD/puA7KM3xhJHSBlatG9iG8TlHmD7qUEKc8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, dann frazier , Suzuki K Poulose , Mark Brown , Marc Zyngier , Catalin Marinas Subject: [PATCH 5.14 044/162] arm64: Restore forced disabling of KPTI on ThunderX Date: Mon, 27 Sep 2021 19:01:30 +0200 Message-Id: <20210927170235.029974872@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210927170233.453060397@linuxfoundation.org> References: <20210927170233.453060397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: dann frazier commit 22b70e6f2da0a4c8b1421b00cfc3016bc9d4d9d4 upstream. A noted side-effect of commit 0c6c2d3615ef ("arm64: Generate cpucaps.h") is that cpucaps are now sorted, changing the enumeration order. This assumed no dependencies between cpucaps, which turned out not to be true in one case. UNMAP_KERNEL_AT_EL0 currently needs to be processed after WORKAROUND_CAVIUM_27456. ThunderX systems are incompatible with KPTI, so unmap_kernel_at_el0() bails if WORKAROUND_CAVIUM_27456 is set. But because of the sorting, WORKAROUND_CAVIUM_27456 will not yet have been considered when unmap_kernel_at_el0() checks for it, so the kernel tries to run w/ KPTI - and quickly falls over. Because all ThunderX implementations have homogeneous CPUs, we can remove this dependency by just checking the current CPU for the erratum. Fixes: 0c6c2d3615ef ("arm64: Generate cpucaps.h") Cc: # 5.13.x Signed-off-by: dann frazier Suggested-by: Suzuki K Poulose Reviewed-by: Suzuki K Poulose Reviewed-by: Mark Brown Acked-by: Marc Zyngier Link: https://lore.kernel.org/r/20210923145002.3394558-1-dann.frazier@canonical.com Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/cpufeature.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1500,9 +1500,13 @@ static bool unmap_kernel_at_el0(const st /* * For reasons that aren't entirely clear, enabling KPTI on Cavium * ThunderX leads to apparent I-cache corruption of kernel text, which - * ends as well as you might imagine. Don't even try. + * ends as well as you might imagine. Don't even try. We cannot rely + * on the cpus_have_*cap() helpers here to detect the CPU erratum + * because cpucap detection order may change. However, since we know + * affected CPUs are always in a homogeneous configuration, it is + * safe to rely on this_cpu_has_cap() here. */ - if (cpus_have_const_cap(ARM64_WORKAROUND_CAVIUM_27456)) { + if (this_cpu_has_cap(ARM64_WORKAROUND_CAVIUM_27456)) { str = "ARM64_WORKAROUND_CAVIUM_27456"; __kpti_forced = -1; }