From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1441BC433F5 for ; Thu, 23 Sep 2021 09:43:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA8646121F for ; Thu, 23 Sep 2021 09:43:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org CA8646121F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=RKMyczcejXeeVZEJWPSVMWoCimj4MRkfPBpnmkqNRrA=; b=BHe4Akl8aOgCDvaExcBGYewG8R 1A4uIOM1hC6NIYGq9KSx2kmSWM4alkgOf+/hBw7WDsvqzZtPQ0pB13dZpHimag9dAJe/lNYNUQT04 PyhNPBorjRztB2ANJgbgSeVa1qcSScpgc+wvU10LSggxkYXNiLjALrD9e0ool4vaByMR9b0A/xabS GDdFUUUs0z9Ruk72jOWeid8ruWNxlmaVwZwGP7CUk+2q4qvpV8TDgXcayDLIS/QobfQQhOXuQYr2X Hx3zZpaFW8cfkXp/0GM7FvSE5Uxad8TH7Qm2vNj4VR637hJdc6vWoQBgT2sX2lss30SjBLs0WR00Y SM5rJ32w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTLE3-00AoeR-47; Thu, 23 Sep 2021 09:41:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTLDz-00Aodl-Sv for linux-arm-kernel@lists.infradead.org; Thu, 23 Sep 2021 09:41:05 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id DA0CB106F; Thu, 23 Sep 2021 02:41:02 -0700 (PDT) Received: from [10.57.95.68] (unknown [10.57.95.68]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BCE413F59C; Thu, 23 Sep 2021 02:41:01 -0700 (PDT) Subject: Re: [PATCH] arm64: Restore forced disabling of KPTI on ThunderX To: dann frazier , Catalin Marinas , Will Deacon Cc: Mark Brown , linux-arm-kernel@lists.infradead.org, Marc Zyngier , Mark Rutland References: <20210922135924.3109291-1-dann.frazier@canonical.com> From: Suzuki K Poulose Message-ID: Date: Thu, 23 Sep 2021 10:41:00 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210922135924.3109291-1-dann.frazier@canonical.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210923_024104_034431_D4385312 X-CRM114-Status: GOOD ( 25.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 22/09/2021 14:59, dann frazier wrote: > 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") > Suggested-by: Suzuki K Poulose > Cc: stable@vger.kernel.org # 5.13+ > Signed-off-by: dann frazier > --- > arch/arm64/kernel/cpufeature.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c > index f8a3067d10c6..7275b49034f3 100644 > --- a/arch/arm64/kernel/cpufeature.c > +++ b/arch/arm64/kernel/cpufeature.c > @@ -1528,7 +1528,7 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, > * ThunderX leads to apparent I-cache corruption of kernel text, which > * ends as well as you might imagine. Don't even try. > */ > - if (cpus_have_const_cap(ARM64_WORKAROUND_CAVIUM_27456)) { > + if (this_cpu_has_cap(ARM64_WORKAROUND_CAVIUM_27456)) { Please could you also update the comment right above this line to explain, why we do this and why this is fine (just like you have in the description) ? Something like : * Since we cannot rely on the order of the cpucaps * we cannot rely on the cpus_have_*cap() helpers to * detect the erratum on the system. However, since * affected CPUs are always in a homoegeneous configuration * we could rely on this_cpu_has_cap() */ So that looking at the code, it is easier to comprehend what we figured out in the mailing list (and the description) With that: Reviewed-by: Suzuki K Poulose Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel