Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1291113pxb; Fri, 1 Apr 2022 09:20:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxP2Fvl8wL71It53KzBCeUYvJdU4hVgxb9DhIPdDidyFu6SRebAx1WXb5kz2u+D+PMfvCYg X-Received: by 2002:a17:903:4052:b0:155:fc0b:48fb with SMTP id n18-20020a170903405200b00155fc0b48fbmr10812663pla.27.1648830046783; Fri, 01 Apr 2022 09:20:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648830046; cv=none; d=google.com; s=arc-20160816; b=YvtjFis9KwyyGquYsKn7C+3JnVghjtwtVnqFNRMWXSgycYO5WB0y3hqFRI4wWypaWi NTlPeZGUCI14kckxARXmHqzkCXCxKbxcC5esrT2Bs2FH3v5pWhFWf2eyfBA9MJEwqmIF /WxzjayKmOnulGcfvxIFt34EVIUTqapev8jMZa1AEoMWvqXE99Tq9Ll7WzLw7aO2MZFr OUDYz12n4uobZPJa4fJsOygtpKnAElBEY91zWgdj/Zdm8HC6VUh6axeiVWPxc9mJsvS/ qAahtCtpoqU4YwtOGwnwh0/IpIzTFLiocRdCpgwTASYRXaPu0aIrzA1gq+lZz7ryqSXX fMaA== 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=lumkpW6145K2BNw+KhR0FvmVHtEdXoCTcbx0/ZeJBqI=; b=ZQ5W+z+280mvLwjAdrr6NnEW2+NrN4McA+pgugH3Rr3+SZxtPqxJaTcoO63cZS5FSn OfEtFeR0/emY8owSKd0HzrOP5U3pleedxM5NmhvNOOZU+bu71oWSoxAemV/91p2S0n7u T+lprcydLvFq4BajC5A9gArrOkZbJ1CjRTgt0oA30PuwU+6MXPz6aw6WP2s9qfMYma7z 2Jtm7J8N1BD8MVcyHF5Wh1UmEJPqQxOSZ6ir7D+lEeHa1upplg+QA6vtJJ603RDk8V8r e6SEMpOfhFrLmSk3koPSiDL2iX2aveNKZD0aQpd/EJsUo7tH1eIXZds9LTNY3lh18EAs W1Mg== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hk8-20020a17090b224800b001c6d68d4536si3048331pjb.41.2022.04.01.09.20.32; Fri, 01 Apr 2022 09:20:46 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235266AbiCaSgw (ORCPT + 99 others); Thu, 31 Mar 2022 14:36:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235083AbiCaSga (ORCPT ); Thu, 31 Mar 2022 14:36:30 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0EAC21F0C83; Thu, 31 Mar 2022 11:34:39 -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 E6B4913D5; Thu, 31 Mar 2022 11:34:38 -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 491873F718; Thu, 31 Mar 2022 11:34:38 -0700 (PDT) From: James Morse To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: james.morse@arm.com, catalin.marinas@arm.com Subject: [stable:PATCH v4.14.274 11/27] arm64: entry: Free up another register on kpti's tramp_exit path Date: Thu, 31 Mar 2022 19:33:44 +0100 Message-Id: <20220331183400.73183-12-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220331183400.73183-1-james.morse@arm.com> References: <20220331183400.73183-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,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 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 --- arch/arm64/kernel/entry.S | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 1211e0da5476..b3014ed0ea8a 100644 --- 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_KERNEL_AT_EL0 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_WORKAROUND_QCOM_FALKOR_E1003 .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 -- 2.30.2