Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp919514pxb; Thu, 31 Mar 2022 22:58:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgk9QL576kMAlC98tm/HTIkArHxBRnBM0AJ/gJ8EMEx1eVHcG4MCXg2FLNm4HfiKbOHKjh X-Received: by 2002:a17:906:9b93:b0:6da:6388:dc57 with SMTP id dd19-20020a1709069b9300b006da6388dc57mr7915888ejc.338.1648792723107; Thu, 31 Mar 2022 22:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648792723; cv=none; d=google.com; s=arc-20160816; b=Ca0ejH+XJw8GCEI0JV4cMH2sQKstTPqa3vZfATU5W5BIQwt9N0De5WIY+sJeMNPEjN az7LnnLcAnrAEZ4lZAIZuIPt0AO1XjEt4hrq7s/1mu9j4eJHPo3/J9T0ga2RVjIMiawk XFoLxNhY6IK8A0/9Kvpqr7moZ9zYzHGZYkKjYjltQqefoUHT/ccNZgLlF1Gk7ZFQTrrg dmKdCi3cL+VWNe1SEpbyZvl3TzqFMgN1R83s5CI/tXB2INLLwe8qo1ybtrK0bdqrOtCy NZDFi22T5q+qoe4wJWAPFRR2vnFabRiLZDEW0PX5ziEYAxJC5fdz6Amzx8sgxfUisCsX KH0A== 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; bh=X5I8t3Y+nb7Nqx1Xl70uLeWDQMUsl7UcbwLlH74FSrc=; b=ZdCbW2lsLZX2vVipm511PUfNz0V1nc/A7lOnqmrpJEvf5Sil2R/3nCvBFYJ/MvltaU ncWU0qbvUurSPGZuXZPL4L0MfKW5boXnJ2yLmGfLkhJc7b7ZiZ/mGNvXzCseh4asghX6 Ke4CYSkr2xqjdbRtcl5RmWnOXCt9eNiSRvEAJWW6Oyo0Qso0xPQ3HAh0+OlkeTtMAueC FIi/IUlRCtUHqAGbC4NR3GfrKA7foSzrE7n4OFNeTEP4okEJn7U9rvMrjHRXJkPko+uE cljWvl6cFqTsQbyqRd7ul1Qyvev16hOGbCa4aZAx808fmaoMdyD9S2BKh9RcZRVWypou Tv3Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a056402510a00b00418c2b5be19si1273124edd.251.2022.03.31.22.58.17; Thu, 31 Mar 2022 22:58:43 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232385AbiCaShZ (ORCPT + 99 others); Thu, 31 Mar 2022 14:37:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235284AbiCaSgc (ORCPT ); Thu, 31 Mar 2022 14:36:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 85D221F9FD7; Thu, 31 Mar 2022 11:34:43 -0700 (PDT) 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 4F6201596; Thu, 31 Mar 2022 11:34:43 -0700 (PDT) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.218]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A60D43F718; Thu, 31 Mar 2022 11:34:42 -0700 (PDT) From: James Morse To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: james.morse@arm.com, catalin.marinas@arm.com Subject: [stable:PATCH v4.14.274 16/27] arm64: entry: Make the kpti trampoline's kpti sequence optional Date: Thu, 31 Mar 2022 19:33:49 +0100 Message-Id: <20220331183400.73183-17-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220331183400.73183-1-james.morse@arm.com> References: <20220331183400.73183-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,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 commit c47e4d04ba0f1ea17353d85d45f611277507e07a upstream. Spectre-BHB needs to add sequences to the vectors. Having one global set of vectors is a problem for big/little systems where the sequence is costly on cpus that are not vulnerable. Making the vectors per-cpu in the style of KVM's bh_harden_hyp_vecs requires the vectors to be generated by macros. Make the kpti re-mapping of the kernel optional, so the macros can be used without kpti. Reviewed-by: Russell King (Oracle) Reviewed-by: Catalin Marinas Signed-off-by: James Morse --- arch/arm64/kernel/entry.S | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 20055f976146..a58da4779b06 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1022,9 +1022,10 @@ alternative_else_nop_endif sub \dst, \dst, PAGE_SIZE .endm - .macro tramp_ventry, vector_start, regsize + .macro tramp_ventry, vector_start, regsize, kpti .align 7 1: + .if \kpti == 1 .if \regsize == 64 msr tpidrro_el0, x30 // Restored in kernel_ventry .endif @@ -1046,8 +1047,12 @@ alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 #endif prfm plil1strm, [x30, #(1b - \vector_start)] msr vbar_el1, x30 + isb + .else + ldr x30, =vectors + .endif // \kpti == 1 + add x30, x30, #(1b - \vector_start + 4) - isb ret .org 1b + 128 // Did we overflow the ventry slot? .endm @@ -1064,15 +1069,15 @@ alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 eret .endm - .macro generate_tramp_vector + .macro generate_tramp_vector, kpti .Lvector_start\@: .space 0x400 .rept 4 - tramp_ventry .Lvector_start\@, 64 + tramp_ventry .Lvector_start\@, 64, \kpti .endr .rept 4 - tramp_ventry .Lvector_start\@, 32 + tramp_ventry .Lvector_start\@, 32, \kpti .endr .endm @@ -1083,7 +1088,7 @@ alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 .pushsection ".entry.tramp.text", "ax" .align 11 ENTRY(tramp_vectors) - generate_tramp_vector + generate_tramp_vector kpti=1 END(tramp_vectors) ENTRY(tramp_exit_native) -- 2.30.2