Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2277554pxp; Mon, 21 Mar 2022 15:40:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoFZ4NlkaH7OhLdAri+8YtZ9M+695XFg4edz5p/rO022Wf46qSRarPl6edRDTA9ZgKTAlw X-Received: by 2002:a17:90a:2d0:b0:1bc:4fc0:6fb7 with SMTP id d16-20020a17090a02d000b001bc4fc06fb7mr1489523pjd.196.1647902452069; Mon, 21 Mar 2022 15:40:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647902452; cv=none; d=google.com; s=arc-20160816; b=zHrLSOYGwvNnPP9StAJoyhrjB+/wg+uXyamV2TbIJIVVhEHLDdDxahdVPpJDeNmtu9 s40C5RkZ6WxwhtSE24TE70JSOZIk4UX/KJ/rzYhvMYb5eKSNq4+pdpnZpi5C6oUGjCEu gmjOjtj9nGO6eOHfMQSO6tNKgKbS2JTclnUvjuTVhHtG5GeSh6dem6XEBG7vkIr5AALg kITYfvSADBZumIf0NW2eNTHCe/bLPWmpmPU8pTcD0Mqkw4vA+fW4FVY7EYuVAK6FBOXG J4k/qnY5YWGK9hfHPKu8zJ7GG/4WxV5rYxiqZlULud5r31wf2JBq9R2gBkwZyIOpRvVE b4yw== 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=hYlqVLhmjXJceKDKBiBkKYWF6UqMExRnfov9peTk3uQ=; b=Zi6aeN/n4wmt1kYwAE4JMjKrGfek9ws8QMZJ4d7vBJ4rTySX58GW4TwAg3NYf21+BQ 3oYPhLfCsE/4PCJaHmJVeniT5YgZVmQcKQNhFsBknoZFJd5aSnC7TVqzwcqbc16WlHdf 55wg1+7vPkUTrXSJdhEgNHzMt3yltj5fu24+f42Yu9L+FcWnad+6LxEr8jUDMfI137rL GF7Dpz830YsDvNInxise/+NRVYtRXRkb3gMwZ+Elw/gWtsHB74j8DX4PiaKvh8F+0s01 +cTawAPjOax80iHhyi2z/fdx4cVSoGAbAZtCTgsgzwjYAm1gtjWeZweRUropUcFAyu/8 ih7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QGg8CD2Y; 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 f3-20020a170902e98300b00153b2d165a7si11518747plb.431.2022.03.21.15.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:40:52 -0700 (PDT) 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=QGg8CD2Y; 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 8E37D334D05; Mon, 21 Mar 2022 14:51:38 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237500AbiCUOBM (ORCPT + 99 others); Mon, 21 Mar 2022 10:01:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348707AbiCUN6L (ORCPT ); Mon, 21 Mar 2022 09:58:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE94179420; Mon, 21 Mar 2022 06:56:14 -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 3EC36612A0; Mon, 21 Mar 2022 13:55:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4BFACC340E8; Mon, 21 Mar 2022 13:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647870951; bh=iqOckIo6jhfcvNG2gMBYFRi7xPN+WjyixetCij8eTRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QGg8CD2YprMP16ZkequPUhyBvHFYSGBhgtG57kPMRzDLLflxc+yM3rcgVboFcTa7I t3Gdkhot+aTZaqvfxnIDkzQrHVH8k1Q3QjGSMagYg6BkJFPTtSJU7pUfV1Gmjr4WfM PitQRwoNhmf0f+nT/HqUU6x7i5re+tVVJdK9vUss= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , "Russell King (Oracle)" , Catalin Marinas , James Morse Subject: [PATCH 4.19 28/57] arm64: entry: Free up another register on kptis tramp_exit path Date: Mon, 21 Mar 2022 14:52:09 +0100 Message-Id: <20220321133222.807964635@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133221.984120927@linuxfoundation.org> References: <20220321133221.984120927@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=-3.1 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 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 @@ -348,18 +348,20 @@ 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 /* * ARCH_HAS_MEMBARRIER_SYNC_CORE rely on eret context synchronization * when returning from IPI handler, and when returning to user-space. */ .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: @@ -367,6 +369,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 @@ -996,10 +1000,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