From patchwork Fri Jul 3 15:36:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 11642113 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86A1314E3 for ; Fri, 3 Jul 2020 15:40:46 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29C1220899 for ; Fri, 3 Jul 2020 15:40:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="aWAxvii0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29C1220899 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PGCDE5ef8pHYVelxYswBugTZvEGPPwF+Fx8EgHSDB3s=; b=aWAxvii084IhOGSMspK3T2Tlg lWI7/YO/9UHmf5df/Crs66Ugiw66MKEI/WqDmUr+MftPwkcWuQ7ju/zBYs2CFl5llS3vIoGo0dPAY Z3lk7bRlt6rnar/mUFtALfizZprtYq+SALazOBlTvCuN0igYK3dL3gjHtc5nQcG50dAUg6ikxLAax HjiqHYQo7+93Jb1gZnmoJyHxHsEf2BpISPDOGXbQVzf6T0mc2PH8GwufQDOnubHEnDaDvB0I7A8CW JMxcHntV8DDRawgTFE9smvhSltTJiMbPGWmP0+p+j902IOvvkGXTp88LKlYNF3FhJmTe4lcCJn8N9 UAO2Pf4Yw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrNlm-0001Y1-1y; Fri, 03 Jul 2020 15:38:30 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrNky-0001AO-6G for linux-arm-kernel@lists.infradead.org; Fri, 03 Jul 2020 15:37:41 +0000 Received: from localhost.localdomain (unknown [95.146.230.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8A13B217BA; Fri, 3 Jul 2020 15:37:37 +0000 (UTC) From: Catalin Marinas To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 07/26] mm: Preserve the PG_arch_* flags in __split_huge_page_tail() Date: Fri, 3 Jul 2020 16:36:59 +0100 Message-Id: <20200703153718.16973-8-catalin.marinas@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200703153718.16973-1-catalin.marinas@arm.com> References: <20200703153718.16973-1-catalin.marinas@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200703_113740_431519_7C4A8C85 X-CRM114-Status: GOOD ( 13.15 ) X-Spam-Score: -5.0 (-----) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-5.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [198.145.29.99 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Szabolcs Nagy , Andrey Konovalov , Kevin Brodsky , Peter Collingbourne , linux-mm@kvack.org, Andrew Morton , Vincenzo Frascino , Will Deacon , Dave P Martin Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When a huge page is split into normal pages, part of the head page flags are transferred to the tail pages. However, the PG_arch_* flags are not part of the preserved set. PG_arch_1 is currently used by the arch code to handle cache maintenance for user space (either for I-D cache coherency or for D-cache aliases consistent with the kernel mapping). Since splitting a huge page does not change the physical or virtual address of a mapping, additional cache maintenance for the tail pages is unnecessary. Preserving the PG_arch_1 flag from the head page in the tail pages would not break the current use-cases. PG_arch_2 is currently used for arm64 MTE support to mark pages that have valid tags. The absence of such flag causes the arm64 set_pte_at() to clear the tags in order to avoid stale tags exposed to user or the swapping out hooks to ignore the tags. Not preserving PG_arch_2 on huge page splitting leads to tag corruption in the tail pages. To avoid the above and for consistency between the two PG_arch_* flags, preserve both PG_arch_1 and PG_arch_2 in __split_huge_page_tail(). Signed-off-by: Catalin Marinas Cc: Andrew Morton --- Notes: New in v6. mm/huge_memory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 78c84bee7e29..22b3236a6dd8 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2364,6 +2364,10 @@ static void __split_huge_page_tail(struct page *head, int tail, (1L << PG_workingset) | (1L << PG_locked) | (1L << PG_unevictable) | + (1L << PG_arch_1) | +#ifdef CONFIG_64BIT + (1L << PG_arch_2) | +#endif (1L << PG_dirty))); /* ->mapping in first tail page is compound_mapcount */