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 68F50EC8732 for ; Thu, 7 Sep 2023 14:34:04 +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=0Hh2Cm34A9cpGp2s0mMsnBoI6xcnKNwjGuVZ0Ch8lgw=; b=45goz+SO7zaA1V +OYo1m6dh+s866kaaEPM+gwfPQ6nRmtWzrUI6KRVGMapODbbxrtrS0HParPwOkIMdJPax3kD2c9WX LKSYxetB/SmlcnlXrbeZRmSdSkSPAt16auMqU/iUiv5OqktBtHMSRmi8ciUhOwb8yVjWWbI3I9pXF jOKNUr/56WrNTOdXJXN79xNQ0TBXGgK32GlLOfps3HfRPrfXa4KEYVtj9SkgxUPURop9AS5SD8psj 09Yy/bwPG4/uLSJB/RDEm9tZ1Kg7EnmVxgy9cmjM0S7Io8v6nRCEO2ij4W3ui2M0bvNfeKFHE64c1 KinGPnsaVvBj0NJTQSBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qeG4i-00CCgc-0U; Thu, 07 Sep 2023 14:33:40 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qeG4f-00CCfu-1J for linux-arm-kernel@lists.infradead.org; Thu, 07 Sep 2023 14:33:38 +0000 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-26f6b2c8e80so810096a91.1 for ; Thu, 07 Sep 2023 07:33:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694097216; x=1694702016; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YfgRO7mX/DO7BbGnDGP3r6jlXziqVhwRyC4fHRuMwY4=; b=rrwHrEqLN/4aVkMs6GQJt2aRol47nYo+6TlTOUx9QCCM8xdVpAxCWQD3WeiWEaHozf a0A9ow/bDqvK2itvGbxD624O8PShF/Hj3nXxiDdxVsTZbRQ1hWKtJlB7Vy+KWEg5NFSj M+x4Ajj3o2l9pRvgm34hmN25NeEBKmbVLMqHK7JtrtJn5uKa2JA18pDlAnlvSI1GxRM6 ysJwPVrBaPJ/g1RUe2K3Aa99UbAFs9pFmKlBgsGaqcvgiLdM8xlcWQVa0xTl75DAQNyo Zeef0YOI76xMR8IOMNyAA4P5g5Gq2UBqROXt76hIP3f08dR2bQ58NGBp08J8XSFozjsK ys8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1694097216; x=1694702016; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YfgRO7mX/DO7BbGnDGP3r6jlXziqVhwRyC4fHRuMwY4=; b=iPo4QcZaiGxgjnI5zATUjNwAjv4XmGN8Ox+SGRwNrSsqCAla12pW4HgJSW+FSDy/0N dO7YY1gkyrILab8hwMpwti0Yta8a9vFQLQn0FQ30GSEZyr+s/1oKby+PxJm6sYBHW5QE c4v5MpRnz+zvSy0+rIj014Qx41k2Use33JyVDqwojs19IqPXvkxT9Uhm7FwZLJ1XlCd+ VENkutiF4Ulnqfj9S+zrLCUadwcbRSq6fZwbVTVmWwHy2kvYja1FWhghRpTXLHhvaBY7 vsDE31foVyvxBxDuJdRnaXYqHQGS7V7398NCEbnV7DTbSeXghB9xyBuVfc3QDaeMXYms fSow== X-Gm-Message-State: AOJu0YyXI48dHJY8zdlpMSg3UsyVs7qSWd8mYzj82r0gnhBGIbOobMtL XJhAvEDU+lIp2Kskj6/OZXw= X-Google-Smtp-Source: AGHT+IFwqY6yWGRP5js7HsuyPsHlBJuvnZ8ps3dcUjD/I6KrKw5MNk0R91NZPddOPQvoezIZef4ZhA== X-Received: by 2002:a17:90b:1a8b:b0:25b:c454:a366 with SMTP id ng11-20020a17090b1a8b00b0025bc454a366mr19193226pjb.5.1694097216276; Thu, 07 Sep 2023 07:33:36 -0700 (PDT) Received: from local.. ([104.193.10.236]) by smtp.gmail.com with ESMTPSA id z6-20020a17090a1fc600b00256799877ffsm1641733pjz.47.2023.09.07.07.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 07:33:35 -0700 (PDT) From: Zhizhou Zhang To: linux@armlinux.org.uk, rmk+kernel@armlinux.org.uk, rppt@kernel.org, linus.walleij@linaro.org, akpm@linux-foundation.org, vishal.moola@gmail.com, arnd@arndb.de, wangkefeng.wang@huawei.com, willy@infradead.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Zhizhou Zhang Subject: [PATCH] ARM: mm: fix stack corruption when CONFIG_ARM_PV_FIXUP=y Date: Thu, 7 Sep 2023 22:33:02 +0800 Message-Id: <20230907143302.4940-1-zhizhou.zh@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230907_073337_447560_E4DA8C7A X-CRM114-Status: GOOD ( 14.24 ) 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 From: Zhizhou Zhang flush_cache_all() save registers to stack at function entry. If it's called after cache disabled, the data is written to memory directly. So the following clean cache operation corrupted registers saved by flush_cache_all(), including lr register. calling flush_cache_all() before turn off cache fixed the problem. Signed-off-by: Zhizhou Zhang --- arch/arm/mm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 674ed71573a8..03fb0fe926f3 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -1675,6 +1675,7 @@ static void __init early_paging_init(const struct machine_desc *mdesc) /* Run the patch stub to update the constants */ fixup_pv_table(&__pv_table_begin, (&__pv_table_end - &__pv_table_begin) << 2); + flush_cache_all(); /* * We changing not only the virtual to physical mapping, but also @@ -1690,7 +1691,6 @@ static void __init early_paging_init(const struct machine_desc *mdesc) asm("mrc p15, 0, %0, c2, c0, 2" : "=r" (ttbcr)); asm volatile("mcr p15, 0, %0, c2, c0, 2" : : "r" (ttbcr & ~(3 << 8 | 3 << 10))); - flush_cache_all(); /* * Fixup the page tables - this must be in the idmap region as -- 2.34.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel