Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp568248pxp; Fri, 11 Mar 2022 09:46:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRLOCkdNeyAJf0j8L3VPYEaR4Cg+LysUBGtfB87X9yOJKV2drlI5g1noCesq86p6M1WQe8 X-Received: by 2002:a63:de55:0:b0:374:2526:3596 with SMTP id y21-20020a63de55000000b0037425263596mr9474165pgi.592.1647020789728; Fri, 11 Mar 2022 09:46:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647020789; cv=none; d=google.com; s=arc-20160816; b=P3ogxkiIUegXjgWaK4rLHSs1Bc4DhdrZ3r7ufn3AuUXPM+V9SY8HmHsKthybnLghUB 6kZiSyBNaYfBjQIQqCD2GR07qOovfQ9EPVier+OoIBvzEd4kbiqEh/heD4WzkzGa/fBi 9439cqq5b1m7tRR/DjB9nFAOlDRj7I84DWZLIVZ+1RFo3VNykIapEth68OOL+cV+W0z/ bj4MvSooxOWmPKyd7r6XhpeAMlZh92HYkgt+gHTv5rC2GrjH3GXDCvBYI3sx2ZEINxS6 HGb45xqASsVi4t7DKovaF1I9kuHXfzWjvT85a5u2ULV6pNwSxCS0DhylWOgGylLXAAWL 9o4Q== 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=AY+eIdD5JSdVRIwJwhOLG9kg1gUdpuoVkVh19YZ8Mkc=; b=qGlHTDjClRnhR1QjNGjKI0CB798iiFtnZ1A7mtIkEa4O23odjLKjpetHpS6djVmkJh bpcuEV1MnrOMRH6TlFZJb3kgD052ZTJ0wDcCjlH0n1FtzgyecmwlIrStgaoD/l9JSebe z44sRUWNITZVbrvRJnkyopcnu5vQePDhV5eqqm2g36iUIwDs9PXarDBLPVpgmxSnaufY 4/cW8jGxpvDI7EL90jBT4QRxy177DuldXXAfAPz/uXJvGzYkGKZuPW8u2iRqvM3CDj62 XOvcO0D/9Q8vv/ZNGQhbVQ7lMTSDF8iP/WTT4PtV2NfrTCY6cAuuR7JAU5utG4vzp3pM W9JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2wiSzsLS; 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 bh11-20020a056a02020b00b00375705fcc39si9579553pgb.683.2022.03.11.09.46.13; Fri, 11 Mar 2022 09:46:29 -0800 (PST) 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=2wiSzsLS; 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 S242951AbiCJONC (ORCPT + 99 others); Thu, 10 Mar 2022 09:13:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242748AbiCJOMg (ORCPT ); Thu, 10 Mar 2022 09:12:36 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 508D5151697; Thu, 10 Mar 2022 06:10:51 -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 dfw.source.kernel.org (Postfix) with ESMTPS id E282961B7D; Thu, 10 Mar 2022 14:10:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE3D4C340F3; Thu, 10 Mar 2022 14:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646921450; bh=25Hk37nJ7k4GM1ojM6Tgufom7M/GqJr5xVZym4GE6GU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2wiSzsLS2ePmzuNGy1x7y5Q9HO736ZvpM0ul6bctLgJf8RUOLj8opU3ewhdRNttsz 9m3VDA527JE/UeTOxBsWMBqSHVQN/U6PNKyQHYji9G/nwUMts0nhCsi7DuSDwC82FL lR5KOonlMWADdBNmBVYB9jInwBHuMEq+eml9e/DY= 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 21/53] arm64: entry: Free up another register on kptis tramp_exit path Date: Thu, 10 Mar 2022 15:09:26 +0100 Message-Id: <20220310140812.443539538@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=-7.6 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 03aff3a77a58b5b52a77e00537a42090ad57b80b upstream. Kpti stashes x30 in far_el1 while it uses x30 for all its work. Making the vectors a per-cpu data structure will require a second register. Allow tramp_exit two registers before it unmaps the kernel, by leaving x30 on the stack, and stashing x29 in far_el1. 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 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -419,14 +419,16 @@ alternative_else_nop_endif ldp x24, x25, [sp, #16 * 12] ldp x26, x27, [sp, #16 * 13] ldp x28, x29, [sp, #16 * 14] - ldr lr, [sp, #S_LR] - add sp, sp, #PT_REGS_SIZE // restore sp .if \el == 0 -alternative_insn eret, nop, ARM64_UNMAP_KERNEL_AT_EL0 +alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0 + ldr lr, [sp, #S_LR] + add sp, sp, #PT_REGS_SIZE // restore sp + eret +alternative_else_nop_endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 bne 4f - msr far_el1, x30 + msr far_el1, x29 tramp_alias x30, tramp_exit_native br x30 4: @@ -434,6 +436,9 @@ alternative_insn eret, nop, ARM64_UNMAP_ br x30 #endif .else + ldr lr, [sp, #S_LR] + add sp, sp, #PT_REGS_SIZE // restore sp + /* Ensure any device/NC reads complete */ alternative_insn nop, "dmb sy", ARM64_WORKAROUND_1508412 @@ -674,10 +679,12 @@ alternative_else_nop_endif .macro tramp_exit, regsize = 64 adr x30, tramp_vectors msr vbar_el1, x30 - tramp_unmap_kernel x30 + ldr lr, [sp, #S_LR] + tramp_unmap_kernel x29 .if \regsize == 64 - mrs x30, far_el1 + mrs x29, far_el1 .endif + add sp, sp, #PT_REGS_SIZE // restore sp eret sb .endm