Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1211626pxb; Wed, 6 Apr 2022 11:26:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwI7r1NA27gCsdZYsO0p6ZAx0i1RTxHAwv2RCc/1eovZ2S+8rl7kfkGjpJNPeuodgBp4bkb X-Received: by 2002:a17:903:186:b0:154:3606:7a73 with SMTP id z6-20020a170903018600b0015436067a73mr10000238plg.89.1649269578017; Wed, 06 Apr 2022 11:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649269578; cv=none; d=google.com; s=arc-20160816; b=PGn1FCxI4WcJnF3N7IxaG/YpadA67692zFFDZrkQRwfDrIqyUF+tbWlZXQ6k5a/jUW rSuyVPTw6xdh6jko7SRkpqCFKXdsecMliirVjiIG/AibGRoQyb6l2SitIthnw11rDDZR j06cZ2nSqrGjsCAxffL8tn/wscKpTRusLBQW04dKQHLOu1F36PLqARpnHaA2rkHg9K6k mRo2j4JhPhp698djrmubVgvvC2/Y5ugV+e9yW0KaJZH6yzsyvfk4pph+AfoEOywhFk+n tIECCDSQJihXg8m85nN/n5V02BG0Wqkwvmr/hzAegPjVlL1HiJNFtwibWnt7yhUFPTXB feYQ== 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=D5Q3WT+eq3XfnUhDGRNPJBU14vWyetFIR+kr+LwYBHU=; b=pMeVA6KfsDBb2rkJ5BbP0t6Oi/bpaHTEwZ1FL3jPVYJvECJtRHeTGyZ2AeLVgq3ew2 WHxwLYuxvAtUU5baQDyr8SFLFHTC+z9jFsF/5w49hPmeqTYiD4PmZbuCcFjgnDafnA9n tTJ02lcbmSz0kSxZ5y4utJ5Zm4LB7Y17MJpvGgLl8FWuwOaIJwkQtQw40TwGZuKhB3oi hKRnyJgaT+xPhH6jVYWLo/nQBphA+m4+p44ouRplXVe3PwoTrZReWDeeXkB27xQCfPH4 BQ4OH1qF2wM7ji98CzrkR4raYGZFIHj4Y8yQN4ibl63NxhLARonviB6c4YSBcML6bP+Y sjkA== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n1-20020a170902d2c100b00153b2d16531si4879963plc.313.2022.04.06.11.26.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 11:26:18 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5CF771D08FB; Wed, 6 Apr 2022 11:09:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240186AbiDFSLO (ORCPT + 99 others); Wed, 6 Apr 2022 14:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239957AbiDFSIN (ORCPT ); Wed, 6 Apr 2022 14:08:13 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9080C19A578; Wed, 6 Apr 2022 09:46:32 -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 7191B23A; Wed, 6 Apr 2022 09:46:32 -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 C44EA3F73B; Wed, 6 Apr 2022 09:46:31 -0700 (PDT) From: James Morse To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: James Morse , Catalin Marinas Subject: [stable:PATCH v4.9.309 34/43] arm64: entry: Add non-kpti __bp_harden_el1_vectors for mitigations Date: Wed, 6 Apr 2022 17:45:37 +0100 Message-Id: <20220406164546.1888528-34-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220406164546.1888528-1-james.morse@arm.com> References: <0220406164217.1888053-1-james.morse@arm.com> <20220406164546.1888528-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 b9a757216a80..b732480007a4 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -924,10 +924,11 @@ __ni_sys_trace: .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 @@ -1010,6 +1011,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