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 32F0CC43334 for ; Fri, 1 Jul 2022 17:25:42 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=O+bkGBqNhGNlUnLcsTnR2Pr8torWSozMqR+np9kSpTM=; b=WdSvSeF/DM01oL 1PJyTy3AyecwpMEmzHP/LRJ2IN2HK0UEjkimZAjDYgsD8rcsw0I+XdVpQfHHk8+46hmgCEtGul+jN VZL+Ag5k2D6pYW31rWHdu6B9frRti1ylUSeOPxpj5WAAsu9iViiW7QESIXr3wLn8kmbfUT3V+aeFf zdxu3YyDFJTmXsKc0o/ZqNFzjLEFkLyZwoIRgn1/lubBXGq/jMTs5TYapw4zT/qjj3SgDeAOlFfw9 GVIrJ4MsygjFFsqCvtcmmLYfRRokYahaKz9xWJFaPi4OQXGpXF5FDo1mg0npJp8zs/fllydldOOuP Nal3joSdjewEGL/KgObA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7KNm-006D9P-K3; Fri, 01 Jul 2022 17:24:42 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7KNj-006D83-AY for linux-arm-kernel@lists.infradead.org; Fri, 01 Jul 2022 17:24:41 +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 D53FE60B17; Fri, 1 Jul 2022 17:24:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78BB2C3411E; Fri, 1 Jul 2022 17:24:32 +0000 (UTC) Date: Fri, 1 Jul 2022 18:24:28 +0100 From: Catalin Marinas To: Guanghui Feng Cc: baolin.wang@linux.alibaba.com, will@kernel.org, akpm@linux-foundation.org, david@redhat.com, jianyong.wu@arm.com, james.morse@arm.com, quic_qiancai@quicinc.com, christophe.leroy@csgroup.eu, jonathan@marek.ca, mark.rutland@arm.com, thunder.leizhen@huawei.com, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, rppt@kernel.org, geert+renesas@glider.be, ardb@kernel.org, linux-mm@kvack.org, yaohongbo@linux.alibaba.com, alikernel-developer@linux.alibaba.com Subject: Re: [PATCH v3] arm64: mm: fix linear mapping mem access performance degradation Message-ID: References: <1656586222-98555-1-git-send-email-guanghuifeng@linux.alibaba.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1656586222-98555-1-git-send-email-guanghuifeng@linux.alibaba.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220701_102439_444268_D0B4E278 X-CRM114-Status: GOOD ( 13.08 ) 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 On Thu, Jun 30, 2022 at 06:50:22PM +0800, Guanghui Feng wrote: > +static void init_pmd_remap(pud_t *pudp, unsigned long addr, unsigned long end, > + phys_addr_t phys, pgprot_t prot, > + phys_addr_t (*pgtable_alloc)(int), int flags) > +{ > + unsigned long next; > + pmd_t *pmdp; > + phys_addr_t map_offset; > + pmdval_t pmdval; > + > + pmdp = pmd_offset(pudp, addr); > + do { > + next = pmd_addr_end(addr, end); > + > + if (!pmd_none(*pmdp) && pmd_sect(*pmdp)) { > + phys_addr_t pte_phys = pgtable_alloc(PAGE_SHIFT); > + pmd_clear(pmdp); > + pmdval = PMD_TYPE_TABLE | PMD_TABLE_UXN; > + if (flags & NO_EXEC_MAPPINGS) > + pmdval |= PMD_TABLE_PXN; > + __pmd_populate(pmdp, pte_phys, pmdval); > + flush_tlb_kernel_range(addr, addr + PAGE_SIZE); This doesn't follow the architecture requirements for "break before make" when changing live page tables. While it may work, it risks triggering a TLB conflict abort. The correct sequence normally is: pmd_clear(); flush_tlb_kernel_range(); __pmd_populate(); However, do we have any guarantees that the kernel doesn't access the pmd range being unmapped temporarily? The page table itself might live in one of these sections, so set_pmd() etc. can get a translation fault. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel