From patchwork Wed Jun 22 15:49:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Zhongjin X-Patchwork-Id: 12891115 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 E2618C433EF for ; Wed, 22 Jun 2022 16:14:43 +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=oxdkY5NGaTAMJ9 jsMv9C6zzExn4EckAkBzvC1kRE5LUuwWEKEcp7cpWh1z0o8jdc7JMzl0iHe+VpX3HGl63EbSL08up FSKL5mjojY6lnRQrske3GQXkBdPhKRoTo6mb3X6cJjFYa74Hh4qdBGdKpY/VQttFgPvXSzJ01FtK4 3rHX4s6PNrYA1oygcFCf7PnjDhDXKYoIJKrM3Os+WKKBvK4ozy67P8OEvqbErCRGBL59Ad2RoCZaw zNpcbI77GDcrCIDLU4CWr3WwiXckDVz27y7K5TUA3ixlrub61n7R/ktsIHHywgG0wvYX61tFseG1R eP7BgzehEuUwh6HNnKFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o42yo-00BQDB-KK; Wed, 22 Jun 2022 16:13:24 +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 1o42ff-00BI4C-6Y for linux-arm-kernel@bombadil.infradead.org; Wed, 22 Jun 2022 15:53:35 +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=aQFZjtDtRnEdZOyDGRZkLhbuyL DUGLWgiN/u7rW+HzvpjDOxeWknpufoaSs/2Y4aaoj9YBnLvVwskKUsJTnCfohSqG101d7UobHE24y SOjv2THhnD0NYjbVxVcNzk5UT3WSgX0jMsM7mufiSJ36KC7wanFh/9CsBg3q7BiChm7tthKVI+k02 9t/OYPku4C5fpBc9/zKTmXDA0BX9HZU96fSVRuijIus7mdZCXjyZ6yPoOD1BLZmDJvU1l7IU9ABHn pDkHtekm2KVnZVwRvG+GML5FsG15lMNk2g/b/0e7kv0wa2Q+XhQqJhsqESRz8mwQvSdkFv0LK+2Ms 2ePdfQUA==; Received: from szxga08-in.huawei.com ([45.249.212.255]) by casper.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o42fa-0077UP-27 for linux-arm-kernel@lists.infradead.org; Wed, 22 Jun 2022 15:53:33 +0000 Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4LSnsX3NGgz1KC7D; Wed, 22 Jun 2022 23:50:40 +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; Wed, 22 Jun 2022 23:52:47 +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; Wed, 22 Jun 2022 23:52:47 +0800 From: Chen Zhongjin To: , , , , , CC: , , , , , , , , , , , , , Subject: [PATCH v5 30/33] arm64: entry: Align stack size for alternative Date: Wed, 22 Jun 2022 23:49:17 +0800 Message-ID: <20220622154920.95075-31-chenzhongjin@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220622154920.95075-1-chenzhongjin@huawei.com> References: <20220622154920.95075-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-20220622_165330_642116_F03BC6F1 X-CRM114-Status: UNSURE ( 6.76 ) 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]