Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1902513pxb; Sat, 2 Apr 2022 07:39:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRs0R1fRIWj3HtOtRj7qW7UgIvg9vxPf1GyEJVhoq1QaUpjAvsUrbKJBh1oeeCvfMRQGRB X-Received: by 2002:a17:90b:1018:b0:1c9:fc37:fa31 with SMTP id gm24-20020a17090b101800b001c9fc37fa31mr17280692pjb.62.1648910364542; Sat, 02 Apr 2022 07:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648910364; cv=none; d=google.com; s=arc-20160816; b=pqJvYDzlFvQyppMWnO07CqUi3iCujH8xj1y2sxNHtOKAR9KUGK6jpP4+GVyIhusFMc HN0QCRuykQKjNf2onJ00jsTAxXDl6Vvn6O/kBpoBDTRw2lf7tr4FhtGInPhTGORPyzVB Mn3CHRwjgs8BQCBMXLpK5n7WLpNymEy1jFqrS4+jjfWmZNpPSX0jMM+Tl++WKj3E9KTL 18YNj066h0rFFs6l/Nyuk+LAheVq99akcEXfwmrdkBtDYmbOumf+tQCYfTwd1ftC8eJJ gNtgVLKNWJWPSGW3mQouXa0KLZhSxvOWtXmNDTotY6MsDTIsikXhhwqHGRiX2f270R7H /mNQ== 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=WExHH2Q02/qDHY9CSyg+T4SCd9teYF0r7t5gkPcT4B4=; b=G/Pl/5/TBgwTr7/mI8870KJl5PItP44hMndkLcO+CVhaR/qzkNLQjNBDfjCi1jw7kc SMIOQNLtlRuNksX6MQbqKQ7uHr4Z0ap6HLnBFaoa/ounyx7MKa45Sxq863I5w0Bq6hu0 WHOnROxytQ+IySdUJLx+2a52+zcXsRoKvHbK0muN9dlMZHSOHhXWBaMkztz2Vu8ELnvb EC9UJkoVtSbssZEdp4XCW/rVZPNKPgX64ZcmCPxbW/JyLpdDLfGaR/ksc/ImpFuFNx2T mB8OorYb+2FRkOzfKHerAQHyvZOuukHzzs0Nul6hVEWkj5OVb4G4rVf5uSF43VdC1z5o pawA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V8TVu3hW; 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 z4-20020a170902834400b00153b2d1641bsi4996282pln.35.2022.04.02.07.39.10; Sat, 02 Apr 2022 07:39:24 -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=V8TVu3hW; 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 S245653AbiDAGli (ORCPT + 99 others); Fri, 1 Apr 2022 02:41:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343529AbiDAGkn (ORCPT ); Fri, 1 Apr 2022 02:40:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F0A7264F67; Thu, 31 Mar 2022 23:37:48 -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 53C0861123; Fri, 1 Apr 2022 06:37:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64E68C34111; Fri, 1 Apr 2022 06:37:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648795067; bh=UJ2BhyEPnpPLpJeygpXcRFYS+LIDfZWh9UnBzn7ffoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8TVu3hWz18jPhJc3Ge4S+hFPuv8UJR3EwGyQZAV+Hol8HNb/zJusCxD/YwkGqid2 vRfJdwt63nEH6DwT8kPPZK9OOaFifaPaQJPvUSxgJn9CWm/JnlH+Sn+SLfnBIsOQ5D lckitphH+szIaQCQXriO7GvcqItWlYb/enhdmNpI= 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.14 11/27] arm64: entry: Free up another register on kptis tramp_exit path Date: Fri, 1 Apr 2022 08:36:21 +0200 Message-Id: <20220401063624.553108289@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220401063624.232282121@linuxfoundation.org> References: <20220401063624.232282121@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 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 | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -356,14 +356,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, #S_FRAME_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, #S_FRAME_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: @@ -371,6 +373,8 @@ alternative_insn eret, nop, ARM64_UNMAP_ br x30 #endif .else + ldr lr, [sp, #S_LR] + add sp, sp, #S_FRAME_SIZE // restore sp eret .endif .endm @@ -1048,10 +1052,12 @@ alternative_insn isb, nop, ARM64_WORKARO .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, #S_FRAME_SIZE // restore sp eret .endm