Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1278188pxb; Wed, 6 Apr 2022 13:29:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrMowVgqDQfrRkobJvcTPiqwZ8nbfiYPVrjVww/rRKdmkOLf3I/mFImUa7itR53ODbC0K3 X-Received: by 2002:a17:906:6158:b0:6ce:61d6:f243 with SMTP id p24-20020a170906615800b006ce61d6f243mr9945859ejl.268.1649276973066; Wed, 06 Apr 2022 13:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649276973; cv=none; d=google.com; s=arc-20160816; b=0XNHtqsTeqUU0FF/3KnH4dOcMoIZdZYwFNIYi4qXTzsPNk2kcU64p3wMjBws+qdS3u po4OUzMsaBtXuOFyE2X4Vz+m1EKK+9/g75IY7uypEx8G6N2LMO2i4mKipvEj/2X3Ussi fk0BwzWoQhEumJhyW1Zu1mAWvRhASmZtoYr0lCoZU/LqnFUknN5NvLbfE9oKFvv/Xf7L nPl2pxb6ETTzBqkkVbbnZmWcnsIaRhMhNpj2dvtZQTWEwpTSpjmqbiISnP5xEUHfQssn MdUReClnlYsYXASXXiOcxU2tijhrFjwbKsavHRbLKHGLDkA+UNWztFwUU/7VUWePXM8e fmXQ== 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=oVk7AoXdRnDO75VOA40Ueq9iltaQty1QxEmtEIt3bu4=; b=T1xRMH5ZMNPatZgVxG9+rfRrm7N79RBdjMbG3pGqwG7cTkgBF0LUX1WuEJ4jpAIn6x sLt9nwY2KzuDYhdZyoxh4RZjkNlSJ34U5ucfie+OEgkSizPzaplaDcyCbCPqfg4tTB/3 JE0FVC58pr/RvCv8RJW+8wyndvQC0kmpH5GdMp5tBjlOxEr/K0bDKB+zCH4Jrg6dhtmn 22apo4VWFSKNWvet1rPQHt9xQcTPshL5YOYkxtpkh52HMLDniRFvOAQ7VaF/eqWpUz7x w9kaw7HTwFg4Zfie5QG1uX17s88yrbsyxoDa4QrIKBHzpjHk/IsZKMWEGdj3minHShn2 hHHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=znpkq99d; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020a17090668c400b006df76385d92si12048018ejr.562.2022.04.06.13.29.08; Wed, 06 Apr 2022 13:29:33 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=znpkq99d; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233675AbiDFUEl (ORCPT + 99 others); Wed, 6 Apr 2022 16:04:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235593AbiDFUDx (ORCPT ); Wed, 6 Apr 2022 16:03:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB6F21FF205; Wed, 6 Apr 2022 11:27:51 -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 84FE761B89; Wed, 6 Apr 2022 18:27:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 935F9C385A5; Wed, 6 Apr 2022 18:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649269670; bh=TEO1ws/joQIZlBlf0QTXMmwaDURYuXSVRVRTRhqI9DI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=znpkq99dOhVAghgYw7ANzbsqI0s7urmGc5oUtuPlinSgyI1lOmOzeYMFgyVzz8vAT j386/XoQOF0n07g7YoDsHAVVaadXguQd03WQfB1ML7ECaM0Jh5BG2swc6S/eGbydWp /7VhCSfpLAvlmhz8o6QEsE7YfdnD3UFeSxuxrN1k= 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 4.9 26/43] arm64: entry: Make the trampoline cleanup optional Date: Wed, 6 Apr 2022 20:26:35 +0200 Message-Id: <20220406182437.441263260@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220406182436.675069715@linuxfoundation.org> References: <20220406182436.675069715@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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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 @@ -76,16 +76,20 @@ .align 7 .Lventry_start\@: #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -alternative_if ARM64_UNMAP_KERNEL_AT_EL0 .if \el == 0 + /* + * 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 +.Lskip_tramp_vectors_cleanup\@: .endif -alternative_else_nop_endif #endif sub sp, sp, #S_FRAME_SIZE @@ -934,7 +938,7 @@ __ni_sys_trace: #endif prfm plil1strm, [x30, #(1b - tramp_vectors)] 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?