Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1209173pxb; Fri, 1 Apr 2022 07:26:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjo56rYPLsMvR/TYFu95xr/4exGyBW+4Ccy7AcWaNLZhghrQiGjWDWBALO+6PUJrWu+W3X X-Received: by 2002:a17:902:dac6:b0:154:740a:909f with SMTP id q6-20020a170902dac600b00154740a909fmr11015088plx.76.1648823207155; Fri, 01 Apr 2022 07:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648823207; cv=none; d=google.com; s=arc-20160816; b=Hk/eOv0NDepx6M+U0cZUd/8ZPEHdxDYXKdqSaANeD1woZ5sSzM/N0uIqr5N2TjfHUZ zsZWfE6h8Sq+yJurZ63zuxd3hd2RzqjznCGQvKwl3UKXl4KPSTuXwPgBaHvGqjuawnEv cTY7tqYM5GFzN2q/SbCN9RPQq8UURNgn8nObCty58sqEK4psb/o7VWSiP0SL5pBTWibz NtyWn8aU34hCAlGGbSfNhbCHeV8HIoSJpfsvPFY4wDAML3+EYxDvtQW4daGwsuQp+bxS tlT1nuYq1VWq24xyi9y52g5j/dIN5Emjtkr0gcvfELI/7fcYXCAjCnNYfHjPURSA8/G6 5D5w== 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=XOUS0X28O+9L5yj2mPjg7qVZGZjEWqv0o+AC6M48dPU=; b=BgwpQ2kwqQuC+cTbsRCtiMIf9v1ywD+sg3bpRr1Zo0NpAcfEJhlo/abWluGlR87p// y5G33YL0dbIev2Nub+/OUuA2RkKcbA6rpyHkM3VmfA1QeVHj0Uwme+HCsz2ELHFA8boo hHDWoUd/CoXuKY0iOKGk0D29Lm66ggWq98WzdSgyzE8QgltbwnzotLNE6MJN+XYjRUgr /xsZqpCPJXq1NSCSWQPl12f24qerKEV5IL8DHvOpb9VsLg3ctfmBi6YnWZhsNx2lXmDl 5HAhLwaRAVltLAjyGijoZKsaU89ZZEENXG1nbGeC2Hg9zsUaRAKoanMFxTPzzQYIwiq6 zJpA== 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 t18-20020a63a612000000b003829aca2624si2522211pge.460.2022.04.01.07.26.33; Fri, 01 Apr 2022 07:26:47 -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 S236105AbiCaSha (ORCPT + 99 others); Thu, 31 Mar 2022 14:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235228AbiCaSgd (ORCPT ); Thu, 31 Mar 2022 14:36:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 423C62325FC; Thu, 31 Mar 2022 11:34:45 -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 1325013D5; Thu, 31 Mar 2022 11:34:45 -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 69B2D3F718; Thu, 31 Mar 2022 11:34:44 -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 18/27] arm64: entry: Add non-kpti __bp_harden_el1_vectors for mitigations Date: Thu, 31 Mar 2022 19:33:51 +0100 Message-Id: <20220331183400.73183-19-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 aff65393fa1401e034656e349abd655cfe272de0 upstream. kpti is an optional feature, for systems not using kpti a set of vectors for the spectre-bhb mitigations is needed. Add another set of vectors, __bp_harden_el1_vectors, that will be used if a mitigation is needed and kpti is not in use. The EL1 ventries are repeated verbatim as there is no additional work needed for entry from EL1. Reviewed-by: Russell King (Oracle) Reviewed-by: Catalin Marinas Signed-off-by: James Morse --- arch/arm64/kernel/entry.S | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index f50539bdf5be..bf6f4513c81f 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1025,10 +1025,11 @@ alternative_else_nop_endif .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 + + .if \kpti == 1 /* * Defend against branch aliasing attacks by pushing a dummy * entry onto the return stack and using a RET instruction to @@ -1111,6 +1112,37 @@ __entry_tramp_data_start: #endif /* CONFIG_RANDOMIZE_BASE */ #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ +/* + * Exception vectors for spectre mitigations on entry from EL1 when + * kpti is not in use. + */ + .macro generate_el1_vector +.Lvector_start\@: + kernel_ventry 1, sync_invalid // Synchronous EL1t + kernel_ventry 1, irq_invalid // IRQ EL1t + kernel_ventry 1, fiq_invalid // FIQ EL1t + kernel_ventry 1, error_invalid // Error EL1t + + kernel_ventry 1, sync // Synchronous EL1h + kernel_ventry 1, irq // IRQ EL1h + kernel_ventry 1, fiq_invalid // FIQ EL1h + kernel_ventry 1, error_invalid // Error EL1h + + .rept 4 + tramp_ventry .Lvector_start\@, 64, kpti=0 + .endr + .rept 4 + tramp_ventry .Lvector_start\@, 32, kpti=0 + .endr + .endm + + .pushsection ".entry.text", "ax" + .align 11 +ENTRY(__bp_harden_el1_vectors) + generate_el1_vector +END(__bp_harden_el1_vectors) + .popsection + /* * Special system call wrappers. */ -- 2.30.2