Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1302072pxb; Wed, 6 Apr 2022 14:17:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT4vlTecU3boavFxHDDFCPoi7GFOi4aKvkm4aZuSDE90XBi92sBif/KwUji7F9O0r+HZxO X-Received: by 2002:a05:6402:70f:b0:41d:1b2:2e2 with SMTP id w15-20020a056402070f00b0041d01b202e2mr843202edx.128.1649279858430; Wed, 06 Apr 2022 14:17:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649279858; cv=none; d=google.com; s=arc-20160816; b=wI+zya7z18QO7nsfRD+gVIIbn9QWsdriQTL2QNYKVozk5QDa9K/ha0KqjXbFS2qUyd a5kPfjPjUPdq7qNezC0ZUV/AeZjyKhnKqRm/IuK11hFvyoDfiglqy/DLfC5Wr59cHgBs 4tBPKjl7WDr++Xu5BkdnywH9f5GT6A84IkJ3u9wqIMKcX/YDvnidgEZ+urCtBYK4ZQ/F 4Alaq7AT9G4c9ZrmD/MLJ/oZGDrB8AzXAOwSGur99AjBZsxS1gD2AD8cbp3UWgfxkEJE XfgacJOJAT7XjPxIDISqDRhQwZKlmrKeEC0Gb9uT4VaHnDmRxgRMLRpe3ekZxatKIBtd rOYQ== 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=b7Dkbzn8+2teFus/pR+9ntUZSTSUWlhAXxbVtzmdyPQ=; b=Ghn8YDWjHaazfdlguRZmdewP9ZtFRFwcXewoGr/PJ28LuKJQGAmxL8kM9oQKej9QoY bOqtAUvLgbHWWPaUbijLr7wqu6gd/t1Eo0ha28R/aFpnqaqhqn5Nl/+krDomImsN2eKK WEamiegrmRH0TTG1fH4AUGAe7+Pd3U6qvI8exLNRr7Hn9sU4n/nWyHYQUTGg73mj3s4D fn+GJYuFXz49CSvUh5dYKTPhKVlPrRwzcDkTF4CiU7zwmtDU+K3bfwAtgndZEHFpaf1+ gcOG9hehCQ0YGAQem8Tr/uZSh2BMqAya9Klm1mWj+xx3xl2zItP0cpJf76SJlfj3avht 2OBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="iHf/ZqLh"; 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 q20-20020a170906b29400b006df76385bdesi11597480ejz.126.2022.04.06.14.17.12; Wed, 06 Apr 2022 14:17:38 -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="iHf/ZqLh"; 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 S229948AbiDFUUc (ORCPT + 99 others); Wed, 6 Apr 2022 16:20:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbiDFUUA (ORCPT ); Wed, 6 Apr 2022 16:20:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F1D1274E41; Wed, 6 Apr 2022 11:27:56 -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 ams.source.kernel.org (Postfix) with ESMTPS id BC2E3B8253D; Wed, 6 Apr 2022 18:27:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 39390C385A1; Wed, 6 Apr 2022 18:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649269673; bh=Xq7EH7iSEgU+tAkN5ctw2qcn2E6EM6pyEbMVP9TNox0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iHf/ZqLhL8h4UKUTC/Q/QNWzDRa6/xxe8rD5k9QoaD/uHj+9GnCyQZiUeNjXC0amU 0rnZa41qd3QE1cGrGeshgh+EmVXM/aaxEfWfR/TmnEsaPPgganKIKUmre+esAs9ZuH O1LXsCB9pmX2Sxf5H1SYl+UYszNkWv1yvpgMZZ2I= 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 27/43] arm64: entry: Free up another register on kptis tramp_exit path Date: Wed, 6 Apr 2022 20:26:36 +0200 Message-Id: <20220406182437.470448070@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 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 @@ -244,14 +244,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: @@ -259,6 +261,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 @@ -947,10 +951,12 @@ __ni_sys_trace: .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