Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1645442pxp; Thu, 17 Mar 2022 13:29:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy4NKWKwg9vyFqnHu8st+W7ZPbMMlTdPkRCJndxDip1PeZuRse0+rhvwxoqe0wc5/qG02U X-Received: by 2002:a17:902:d482:b0:151:ef7f:f5aa with SMTP id c2-20020a170902d48200b00151ef7ff5aamr6762468plg.58.1647548992854; Thu, 17 Mar 2022 13:29:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647548992; cv=none; d=google.com; s=arc-20160816; b=Hh3N9aVm7z9DOaTHPnmu93j5jbBl9optX50ZUJq4IzxGtVk/EYhpal+W79qYO/f8mQ u08CkN36nkteN9IciMGDpywZwgppgC2JU3x8PKbZWCHyCAzXW9CG39sQvkwg8lJpMN78 lFE9MtcbJJMLGmFuDeZkNrhh4NNUl1+0jfl56ags4eNPUNQ6qBahNPXtDR60Cy8ooyip v2xhd6YwS0Fds1KJ4oHGTmpHr1NuSFICWI7jn3cVmhjXKIGMX/z/bf+F+3xkMydOig7P X7sCn8LXYC4aUFWbeUE54BEcphkQBLVdkDn8kf/4NilVF9/2rkwrIwseoircyWMBDNSs CYBA== 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=97K1yIZtqX4eGSkN3sAdVU/vwtD4h9uBi5FdQvOhgQc=; b=GC1X36TCqHu8clc1oisq7hHwNWq1iR60FHWYQNHNWIiDfOZ45hhhp5Ia+Sc9if9mnE JUV+Y8FygVEzCEPsgvJJczJ0EGviv38ojRdBwucNrzM0GJnKbKJdH0nEnkcmsmo/XZM+ aPck14JEts86IFGGEV3FRxWQQgFyEvO2alBfFefXVNRqOP0PQDaevLzHhb0PkdSq1Uf/ XyhFEDafWpv4+4sLuwQD3yH2sbx89Rh8H/yK5olYGq+80I0kHCQ3GyzsUOklj3Y852P8 pFBDSBpuBzYNf0r30qS2q0Bo9v+xLRqeCGbnlkI1/C/Pz4x2HmF0+2vy+RFKHPjrFNsM oMfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JCtQkfOE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id d23-20020a170902aa9700b00153b2d16529si74593plr.305.2022.03.17.13.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 13:29:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JCtQkfOE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C71042C9631; Thu, 17 Mar 2022 13:05:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233711AbiCQMsP (ORCPT + 99 others); Thu, 17 Mar 2022 08:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233727AbiCQMsM (ORCPT ); Thu, 17 Mar 2022 08:48:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C1B81EDA1A; Thu, 17 Mar 2022 05:46:52 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E5A2061269; Thu, 17 Mar 2022 12:46:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2AFCC340E9; Thu, 17 Mar 2022 12:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647521211; bh=ZYoeLk2VGqV5aDuoUZ7Qkws+VaD1RTQxYw0aoSUUnTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JCtQkfOEAX3gIYTR2ywiEybxt/dzYrbPqPUCYnR0Ld3drMY1zVRuwu6LjlmGzmAe9 amxTycaZpy9hDGbuPg5cHw7Gx52DQRw1n4AwzlqmShMw4SLDaUMP0ZOJuEZU8nZlyS 1oAsBJnTm7f71HkehBJy16KToyYxVs7JH3L1pqcc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Russell King (Oracle)" , Catalin Marinas , James Morse , Sasha Levin Subject: [PATCH 5.4 14/43] arm64: entry: Make the kpti trampolines kpti sequence optional Date: Thu, 17 Mar 2022 13:45:25 +0100 Message-Id: <20220317124528.072378680@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220317124527.672236844@linuxfoundation.org> References: <20220317124527.672236844@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: James Morse 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 Signed-off-by: Sasha Levin --- arch/arm64/kernel/entry.S | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index a2ec7ef24402..bb456f596c43 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1063,9 +1063,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 @@ -1088,9 +1089,14 @@ alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 alternative_if_not ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM prfm plil1strm, [x30, #(1b - \vector_start)] alternative_else_nop_endif + msr vbar_el1, x30 - add x30, x30, #(1b - \vector_start + 4) isb + .else + ldr x30, =vectors + .endif // \kpti == 1 + + add x30, x30, #(1b - \vector_start + 4) ret .org 1b + 128 // Did we overflow the ventry slot? .endm @@ -1108,15 +1114,15 @@ alternative_else_nop_endif sb .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 @@ -1127,7 +1133,7 @@ alternative_else_nop_endif .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.34.1