From mboxrd@z Thu Jan 1 00:00:00 1970 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 DC115C433EF for ; Thu, 6 Jan 2022 19:28:28 +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: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:In-Reply-To:References: List-Owner; bh=E+S8CdSOG5+HJQPjHRkXE1gpRP92hQTXdDNbUYf8lsg=; b=FHl6VNxYRj78cP Z80RydVZiRzuMdIw7MsupoQ6En+JdlaZ7DFoalmhtHxnq8/yo235JPcBlqgzaVwTjhKE6t4ZvUli+ SF9Z3GCEiNVxJNZyQtelzH781XbVQccFepOt9FlYVxkWmwQ1bFHIQAmofSghcVwnufKPRCgA8Zh++ QWt6xEHPXDU4NiCWk3LGdDjU+RXdIEFong6m6BC7zCiSEiAfSaht0lV3r1XO7n6qqm1vGmOkPctoA O9juOnBNDaZ82a8UdYgLgoOCipMblHS9+Hr7WchjzxZjqEjiq3IRzEa0aCPnw9RuQJ9YvzyB32zX1 89UCynkZSJ3ChozW1V3Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5YPc-001E0e-ON; Thu, 06 Jan 2022 19:27:00 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5YPZ-001Dzx-D7 for linux-arm-kernel@lists.infradead.org; Thu, 06 Jan 2022 19:26:58 +0000 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 3F79661ADD; Thu, 6 Jan 2022 19:26:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0629C36AE3; Thu, 6 Jan 2022 19:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1641497215; bh=f6Wh/c4V915ioIyttPu5p/TjHyAkT2UHgZ5HZL61L4k=; h=From:To:Cc:Subject:Date:From; b=lWuqg+vaUXXr9CGIS5vb0pmgetzAd6rKOYOhslf6ZbcdY1ITptIiHOW+YQcANVHto V98NmHZdL5Edxin6SWPe04wYPY7AdlC29qR04Y7oLSdQDvSLpkpIGHFPmhyKZILEBA 8cIDVqpdXXidWw7bokiHRu/wk/ZsbNTRe4YvwpVf4NANkIUlLvSxaLhZzmrPCQeIgM zDV4NXvoPznanDFEnTYS4oRc1pt+i+33p7cHaiW+utMxR58zrwXv3gC1Sr1Djoe9Pb SpZTM6ug1e58GuSWloKrc2JUW2Z3lruaGw95Dd2FQHdNzmQuxMhc3OkTS6RHGeV5N9 MS+M7X32EAKEQ== From: Ard Biesheuvel To: linux@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, arnd@arndb.de, linus.walleij@linaro.org, keescook@chromium.org, Ard Biesheuvel , Marek Szyprowski , Geert Uytterhoeven , Jon Hunter Subject: [RFT PATCH] ARM: suspend: switch to swapper_pg_dir before using the vmap'ed stack Date: Thu, 6 Jan 2022 20:26:45 +0100 Message-Id: <20220106192645.3913934-1-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1576; h=from:subject; bh=f6Wh/c4V915ioIyttPu5p/TjHyAkT2UHgZ5HZL61L4k=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBh10J07ghKNd17gIUMM9ClAOVUmg38SraohMUQpit2 dcS5WDiJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYddCdAAKCRDDTyI5ktmPJOdHC/ 9U7JDkDwAadozQfPjjB4T0xWV1pIxjghRT7kWRsVbU7MTB2ZF7+Ct0yxo410EoyNX+sJyAhhF2h5tp cnS4HyqEzoFJaYs+eaJhAkHzJif9Jt9A6yuae7kmviRCjrrPmXxgJGehucf8nmMvlRa026TQb7NrMo NaVrzcM7Po9Pi3weJiqarXRefBsbgv0appa7Bd3AnKRCto5dJbl+3yPxH+eqsnoMxpmgBc+NsA79wK VcTCiLs1AU3DSUcX7KSMMoIhPrJVjkFLKwOfEAdYGYKDsCuaB+P/72FzwyDGdNzPYR9ANKpOXkllLL JW61eaeLPqIBwZ7pMaO/rRUannIRTRb+IAANDBAFDcyCkzADjTfOPSUzRlwdbpfU/nL4YmrQ9ezjwl W29i3VsNJEoYBnX9WP7TPDANuGTcBjlNaj+4GjMpqDSOHaMwpvnBkiftdOKJ6YbDMYJiJ4sFuZZHjb FchzDXTczCdbJYAjLPOoidNTt1tt+PQKEcWgyqHh08hWU= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_112657_528354_D346AB2E X-CRM114-Status: GOOD ( 12.63 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The resume from suspend code switches to the ID map so it can enable the MMU. On !LPAE configurations, the ID map carries its own copy of the kernel VA range, but this is not kept in sync with swapper_pg_dir, and so it may lack the mapping of the kernel mode stack if CONFIG_VMAP_STACK is enabled. So let's switch to swapper_pg_dir right after re-enabling the MMU on such configurations. This avoids a crash on resume observed on various platforms [0]. [0] https://lore.kernel.org/linux-arm-kernel/20211122092816.2865873-8-ardb@kernel.org/ Cc: Marek Szyprowski Cc: Geert Uytterhoeven Cc: Jon Hunter Signed-off-by: Ard Biesheuvel --- Please test with the Kconfig patch [9177/1] reverted. arch/arm/kernel/sleep.S | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm/kernel/sleep.S b/arch/arm/kernel/sleep.S index b062b3738bc6..6217ef90feb0 100644 --- a/arch/arm/kernel/sleep.S +++ b/arch/arm/kernel/sleep.S @@ -119,6 +119,13 @@ ENTRY(cpu_resume_mmu) ENDPROC(cpu_resume_mmu) .popsection cpu_resume_after_mmu: +#if defined(CONFIG_VMAP_STACK) && !defined(CONFIG_ARM_LPAE) + @ Before using the vmap'ed stack, we have to switch to swapper_pg_dir + @ as the ID map does not cover the vmalloc region. + mrc p15, 0, ip, c2, c0, 1 @ read TTBR1 + mcr p15, 0, ip, c2, c0, 0 @ set TTBR0 + isb +#endif bl cpu_init @ restore the und/abt/irq banked regs mov r0, #0 @ return zero on success ldmfd sp!, {r4 - r11, pc} -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel