Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2032443pxp; Mon, 21 Mar 2022 09:52:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6qquK1+1FEliWAQ8+7ZAYGepEYTG8N5hSlEM6QbZBzcz1/T/5kbUkIwt8GvmgTUbXn81r X-Received: by 2002:a05:6402:6da:b0:3fd:cacb:f4b2 with SMTP id n26-20020a05640206da00b003fdcacbf4b2mr24047252edy.332.1647881525608; Mon, 21 Mar 2022 09:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647881525; cv=none; d=google.com; s=arc-20160816; b=NIcWKTkjcKZUEPuMwM8kSElZ0iSDKnRyp7RaS5cxO1SeNPN5JXe8QstA5EmIJomSy+ Uc8fiYXtyaWLsiKwO4WK6/mDrr1pO2m/txgXedG1fu2uhanCyfeYGw/9lhiFqnEV3vZE cbiaw4U4FW4zAn6VThtmnRF2BorVkw1Fz/uCtxuMLY7AQi+3z8GiC1KpH571xEpDf91B xuytaIkLa37E+38Udb4jUGfvtopenZR2d5WK5UAEDhQQyaIzs3QMEwyOI5VHUz3iwUTb Qtdd7zMvI5PMK1wJBy6ViQqb/IgvEqVD/ESJwfUbs6ajcEp6SwnMmVL7EH4TYOevUK6R LA2A== 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=y1MxSnO85TiQwNyTvd3Ux/dBXPckTR8eHNOe6hCdG4g=; b=pcFBmfut/qUBPCNeyBai5S4JvLtoOAhj0HI9J6L1qXhAd0xwjUerkyktTsnw2Nc6CT EE9RBmaI9BVIhJFX+IxPh0MJu++u2b35Wb2lFR622DEl/X5NGZqaPb1+YG11UPntJNgr q2c7eK7D2F1UJJzvcdzdGq5eLG87JHYL2Lx6zkG/CJPYRCLA6bVEbMKi9f1VY2HgHW9q ETpPNKFslSRp8hbQYvvvXUYN20rFSzClciXtnZkf2tsyffe5JoQERdB/EYacitumdzrj 3NrMaZ2PVm7cQa+p+/bYXJtPMsXMNTL9QTz12l2uSw1ehL68TQg37A+JQBsJM5NfGxYZ Ps2w== 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 k2-20020a50c082000000b00418c2b5bf79si11023814edf.603.2022.03.21.09.51.30; Mon, 21 Mar 2022 09:52:05 -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 S239913AbiCRRvj (ORCPT + 99 others); Fri, 18 Mar 2022 13:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239840AbiCRRvH (ORCPT ); Fri, 18 Mar 2022 13:51:07 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C02618CD24; Fri, 18 Mar 2022 10:49: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 2C6571570; Fri, 18 Mar 2022 10:49: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 80D913F7B4; Fri, 18 Mar 2022 10:49:42 -0700 (PDT) From: James Morse To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, james.morse@arm.com, catalin.marinas@arm.com Subject: [stable:PATCH v4.19.235 11/22] arm64: entry: Make the kpti trampoline's kpti sequence optional Date: Fri, 18 Mar 2022 17:48:31 +0000 Message-Id: <20220318174842.2321061-12-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220318174842.2321061-1-james.morse@arm.com> References: <20220318174842.2321061-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 03c45538a93f..50843161607e 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -970,9 +970,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 @@ -994,8 +995,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 @@ -1012,15 +1017,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 @@ -1031,7 +1036,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