From patchwork Thu Jun 23 01:49:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Zhongjin X-Patchwork-Id: 12891674 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A858BC43334 for ; Thu, 23 Jun 2022 01:59:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3B/f3J+dZKgrecrmHabMLqmm1CCpMWZndSsk/Z55d34=; b=FTRLpY1nAvEQzb 0SjqEqo3xDwyMJ5veogSo0r1uogCGxmXrwxqqN29/xRYbv/Kd+2KZM6Ptei4eV409ps3zgw/evaiy D/QyC7FEsu+Tc0umIzZVsPvcA5CT7TpOUCca3Z5tZYiNeFmYetFrWn2ywSfK4mVoCJewqvNh43QD8 iUj78DyKr5g6bZdkrddS0RpgD19hhWl2QVnipF7IVyfSdw4vT9cpAcqoFVDtyvZU+RII6OwT3PcCq kuE8faBWk6CWpDedM8FdT9q3mTvF3K90ybGWe6C9Lf5WywzRhGjB3gTDwy8u+Zq8HzDmcqTsK0jYF Llc7kb1KXVME9yKplEaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4C62-00Cmiu-0y; Thu, 23 Jun 2022 01:57:26 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4C0q-00CkBi-V8 for linux-arm-kernel@bombadil.infradead.org; Thu, 23 Jun 2022 01:52:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=1J1tmWrkS8CWQq7xJjCc/Twhjoj2QsFUR2qwnajCUP4=; b=dTON4vbCVEGL+irZTYDRT9u+aa ayoPACr0TbTExV7qy7esOm0IuGMfHzEwG62VlJstoJeu3WUJUyhIHV0jECfSBqrV2acASRN3sXTw7 LLNrjBiTRg76MD1l6DO81MToyO5uPxYKLHwrNuCriuYGMviHm1OZMw9BtdFkPEcUnzSg9JxynC214 4T2NaxIWeXqLTgVLEVCGQZcGNC+TCZ9G0aEe20l0KwVsdN5FEo//yurhkx7d+LJvFsTwdxX/zEjfl mXx/HGqW+ovhKhSBTnYFM4Zw00Z6U9f+mAkh2xExt3P1s36Yuj1m3jmvHMo5LXB20vYx4SLxGGq/s csYmLuXg==; Received: from szxga01-in.huawei.com ([45.249.212.187]) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o4C0m-007V4j-4W for linux-arm-kernel@lists.infradead.org; Thu, 23 Jun 2022 01:52:02 +0000 Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LT39q3wKWzkWk9; Thu, 23 Jun 2022 09:50:39 +0800 (CST) Received: from dggpemm500013.china.huawei.com (7.185.36.172) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 23 Jun 2022 09:51:52 +0800 Received: from ubuntu1804.huawei.com (10.67.175.36) by dggpemm500013.china.huawei.com (7.185.36.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 23 Jun 2022 09:51:51 +0800 From: Chen Zhongjin To: , , , , , CC: , , , , , , , , , , , , , , Subject: [PATCH v6 30/33] arm64: entry: Align stack size for alternative Date: Thu, 23 Jun 2022 09:49:14 +0800 Message-ID: <20220623014917.199563-31-chenzhongjin@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220623014917.199563-1-chenzhongjin@huawei.com> References: <20220623014917.199563-1-chenzhongjin@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.175.36] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500013.china.huawei.com (7.185.36.172) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220623_025200_465628_E68D31E3 X-CRM114-Status: UNSURE ( 6.90 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In kernel_exit there is a alternative branch for KPTI which causes stack size conflict for two instruction boundaries. To fix that, make both branch move the sp and then revert it in tramp_exit branch. Signed-off-by: Chen Zhongjin --- arch/arm64/kernel/entry.S | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index d49bfbe81a0d..677e3be471bb 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -430,7 +430,11 @@ 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 +alternative_else + nop + add sp, sp, #PT_REGS_SIZE // restore sp + nop +alternative_endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 bne 4f msr far_el1, x29 @@ -729,6 +733,7 @@ alternative_else_nop_endif .macro tramp_exit, regsize = 64 UNWIND_HINT_EMPTY + sub sp, sp, #PT_REGS_SIZE // revert sp tramp_data_read_var x30, this_cpu_vector get_this_cpu_offset x29 ldr x30, [x30, x29]