From patchwork Thu Sep 23 14:50:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dann frazier X-Patchwork-Id: 12513129 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=-18.2 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,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT 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 DF189C433F5 for ; Thu, 23 Sep 2021 14:52:39 +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 AC1E261107 for ; Thu, 23 Sep 2021 14:52:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AC1E261107 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=canonical.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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=/9EGy1zqAFjMImAkBe8Vh5SgFPTKshajeNeSUX0PGJ8=; b=ajwbFdfFT6MOWS FSswX6gygm2eKHfZ06u1z651urUG9km+2mWNtNxUK4v8PUrRla5yNljFbazRppSdC669L/Tofmedl dHUrVongmpH3JQFASocgHXcbhurUvfVPDU46ID29cP2vPLR6rWQFGjC3bIHF5EChEtNiw4SPKRQgh XqiJ9TDWF+RJDWMQ52W/tdEnn/rCJQx9c4ba8go4/TvQVgd4GDhinnkG0kmDE1U+4w5CnYBfn0IUR pwgS3mboyfhR357Ff2cNthzUdOtvERDSCaqHE9+tEZAXZuKyAIY2aBhxyYCPWpAaMWaV+0EwyViM5 FGdWyz3QKSTq4pxB2ZEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTQ3N-00Bv0G-It; Thu, 23 Sep 2021 14:50:25 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTQ3I-00Buyz-En for linux-arm-kernel@lists.infradead.org; Thu, 23 Sep 2021 14:50:21 +0000 Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id D7C523F32A for ; Thu, 23 Sep 2021 14:50:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1632408616; bh=tWj5teTFPC7+8tk7cStrWEDFLU/342wic9IYvmrR518=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=e4LS4BBZNW07Femm1yatDI/kuV3tYiL0kSTIFoUFm42++SxkK7B4wXOTSoZe2ym6O XAQcuPBUE2R5nCsltPEnj8WDp1JtCGi1bRVXAIXT0RxAsiH0qZTkTgaqYk1b0tTKCV 7b5z5z631buYXFOAgBY3crt7y1rVApofMOwgKCj/sLKw3wj63P2/a44nUZqfWUx0h+ IMpyjkM/Qj47s8pilJyK2ZSxoM5A1iIsAWdMpmQbsuyd5uiZRewKJbPtvARpUe0dvd AycMu/lOk+qvllGblmA/cHGxdh22GEL1Re1rzq2eijhHAi78LmqmPV+0VQe+F6oGnH vpxdsm3Glxx5Q== Received: by mail-io1-f70.google.com with SMTP id z26-20020a05660200da00b005b86e36a1f4so5877933ioe.15 for ; Thu, 23 Sep 2021 07:50:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tWj5teTFPC7+8tk7cStrWEDFLU/342wic9IYvmrR518=; b=NG2OS2b+zqxIk9H9Rt97SugnmrIJVhwynzlwpO1hCxERwpT7lU/r9E3A7wEETc723q V4YsUm+tAkPohE5Ld/biXpoQcBAZBrfGXjJwF9WpiN3z20+daFv7+UF6/lDjIhqH656V R2YC7f5rDwD0g6aIaw8omQZxNF1U3/Nvei3PsLBxjOg1HRs6ncpEmUZHydm/8vOEcLdc PCdv4X88G3Nxf7xuUQy8bsrqstz4ZFfPyP5dNkfE99bG9KzaEL0R/KqXns1C0LXvEyrk 5KGdpZhQ/hq3zKeoJdEoE5j5LQ2CQ2xJqvd+mm+tpoSI+T3EDoHA+zaFDYF1qIN2pSFt gP3A== X-Gm-Message-State: AOAM533peBPlerhJo8q2ow0d5hFBGTlMnA9VDo4MaSrTrq5EhK2yDX93 cNOfvRwqqQh1JlV8EmJ7g17wYo+wRlTlVU60VZdOuH9RP3r+FjVmu9FgHGlV6DAVgAvVtAh0szr nUB3q/78VWg1J5bsNtoy3YEJGt8EY3uDV2daTC5/jOwFeSNtb9INS X-Received: by 2002:a5e:c018:: with SMTP id u24mr4316242iol.129.1632408615675; Thu, 23 Sep 2021 07:50:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoRoobiRsVxcpTKM9QOx8DFHndApzhPnS24J8nX3wGwJbUIsAi7rXUTpvhuSM/p280BcMo8Q== X-Received: by 2002:a5e:c018:: with SMTP id u24mr4316221iol.129.1632408615443; Thu, 23 Sep 2021 07:50:15 -0700 (PDT) Received: from localhost (c-71-56-235-36.hsd1.co.comcast.net. [71.56.235.36]) by smtp.gmail.com with ESMTPSA id f12sm2619085ilu.24.2021.09.23.07.50.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Sep 2021 07:50:14 -0700 (PDT) From: dann frazier To: Catalin Marinas , Will Deacon Cc: Suzuki K Poulose , Mark Brown , linux-arm-kernel@lists.infradead.org, Marc Zyngier , Mark Rutland Subject: [PATCH v2] arm64: Restore forced disabling of KPTI on ThunderX Date: Thu, 23 Sep 2021 08:50:02 -0600 Message-Id: <20210923145002.3394558-1-dann.frazier@canonical.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210923_075020_677792_DD99E650 X-CRM114-Status: GOOD ( 17.37 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Mark Brown Acked-by: Marc Zyngier [ dannf: Added comment text ] Signed-off-by: dann frazier Reviewed-by: Suzuki K Poulose --- arch/arm64/kernel/cpufeature.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index f8a3067d10c6..6ec7036ef7e1 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -1526,9 +1526,13 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry, /* * 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; }