Received: by 2002:ac2:48a3:0:0:0:0:0 with SMTP id u3csp571108lfg; Fri, 11 Mar 2022 13:39:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxo1Unka3AeiXYQOJnkGIv4/lp5uCBhilpCsP75mSmTNiVufHb+5DGZHTivwIlcWRBtynD8 X-Received: by 2002:a17:902:b185:b0:14f:2d94:184 with SMTP id s5-20020a170902b18500b0014f2d940184mr12266779plr.56.1647034786174; Fri, 11 Mar 2022 13:39:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647034786; cv=none; d=google.com; s=arc-20160816; b=MlyPM85cK6CMDIcZMq4AzPNQ8zLsl69vbcx6abfZ6POJxcVykZKS0uNErma1e9aku2 1uaEjNPxE4IlUjkCB37EHHlZtrlTPeAPSBN4vVyK9TmKc01xOwyIoQsrQMHd59r4sYIC zGXt82j0bmJ4BETkokK8Jm1yzxQenxRNI6BPq24ssDHw9iOHICr5nS11lk/dV+Gs12/P uLI/r2wTJu94cFL/qYd8tmBFsna1mDb96YAvZTfs904z3NxL5qdykMSqvA86sMa8h+ad FOC2lKlFMv8qGkLtXSE1Sn47vT2AW1OKdMBQ6XOGxPCoefR8TJ3CZogJ8pX3mht0y98e rVPw== 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=Gc4SbcMs3UHBfTu9hJUME3YJUJx6c2gbWArBHEcmVkI=; b=RXBUkKvjWVYFbj1O8jN1nnh1oYHBU2xANbfavRP0cqwlyFBANw6lpWBlIv/3/3RgsB IFMVbC8+4FNKAateleUBi+RWIV0fbCxrTil3IvqD5xwmmwMOuwF12S9uO1itbTokMxF1 neQZRUhHMFZ8d3zgyJhHbhWnmKTNrixvb+xNd+dX+9VF9DHdpN1EghbzRJVJ8QnPCAg1 ScjvvWkuHhXo+iYhx7Hh5ub67eq6DfkCioaifFCAsvDYnjxgHowtzcAg/F9YSdEfNDD8 OiNUWD4kbR6MFTQHTzEaS4XTEHTNRaNr5HBNQ7e4tnfWlE7GIQ/JfjBwKquEgLUVhDUX ixBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ISg0iN4W; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id z6-20020a17090a170600b001bd14e030b1si6110559pjd.137.2022.03.11.13.39.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 13:39:46 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ISg0iN4W; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 6CC63240D3B; Fri, 11 Mar 2022 13:06:51 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242912AbiCJOM5 (ORCPT + 99 others); Thu, 10 Mar 2022 09:12:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242851AbiCJOMg (ORCPT ); Thu, 10 Mar 2022 09:12:36 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8331214A6E3; Thu, 10 Mar 2022 06:10:49 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 376AFB82679; Thu, 10 Mar 2022 14:10:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 500B9C340E8; Thu, 10 Mar 2022 14:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646921446; bh=Mml45n5zWOY5XUlvrM0ABUbDBgc/vQ9ckQ54OR4R62A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ISg0iN4WvVOEcYFoH7DEgE1WmwY02wbU12QaBtYpywrjWWCPj9vRJjRycsRmKKnZN V93Uzu7Y0UXMBFdZAVswlLyrgPoZEMtFYXx6He/n8KPTWI93m5jy2uUJPtR9vGHB7n FuQZwAkF2uJNb/XRHSI6nDdGV2N6i0g0KSZjvBG4= 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 Subject: [PATCH 5.16 20/53] arm64: entry: Make the trampoline cleanup optional Date: Thu, 10 Mar 2022 15:09:25 +0100 Message-Id: <20220310140812.415530069@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220310140811.832630727@linuxfoundation.org> References: <20220310140811.832630727@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=-2.4 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 d739da1694a0eaef0358a42b76904b611539b77b upstream. Subsequent patches will add additional sets of vectors that use the same tricks as the kpti vectors to reach the full-fat vectors. The full-fat vectors contain some cleanup for kpti that is patched in by alternatives when kpti is in use. Once there are additional vectors, the cleanup will be needed in more cases. But on big/little systems, the cleanup would be harmful if no trampoline vector were in use. Instead of forcing CPUs that don't need a trampoline vector to use one, make the trampoline cleanup optional. Entry at the top of the vectors will skip the cleanup. The trampoline vectors can then skip the first instruction, triggering the cleanup to run. Reviewed-by: Russell King (Oracle) Reviewed-by: Catalin Marinas Signed-off-by: James Morse Signed-off-by: Greg Kroah-Hartman --- arch/arm64/kernel/entry.S | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -40,14 +40,18 @@ .Lventry_start\@: #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 .if \el == 0 -alternative_if ARM64_UNMAP_KERNEL_AT_EL0 + /* + * This must be the first instruction of the EL0 vector entries. It is + * skipped by the trampoline vectors, to trigger the cleanup. + */ + b .Lskip_tramp_vectors_cleanup\@ .if \regsize == 64 mrs x30, tpidrro_el0 msr tpidrro_el0, xzr .else mov x30, xzr .endif -alternative_else_nop_endif +.Lskip_tramp_vectors_cleanup\@: .endif #endif @@ -661,7 +665,7 @@ alternative_if_not ARM64_WORKAROUND_CAVI prfm plil1strm, [x30, #(1b - tramp_vectors)] alternative_else_nop_endif msr vbar_el1, x30 - add x30, x30, #(1b - tramp_vectors) + add x30, x30, #(1b - tramp_vectors + 4) isb ret .org 1b + 128 // Did we overflow the ventry slot?