From patchwork Wed May 28 17:07:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 31075 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 244E220068 for ; Wed, 28 May 2014 17:09:29 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id i57sf48004575yha.4 for ; Wed, 28 May 2014 10:09:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=SLpix7vobbO1wv+2pDsSQSt9XUW0MTwHMGsnD5wmhjo=; b=OIppwPp89UdP9eXoeQkSabwJ49InUGKO0a3CAfwsq7ALJ4yJapzCvWn0ZVfPIzQX3o eWMjrp/DM8xwg0zsiB/L9bhT4cl7chSmybDRTPghMCWqtFPQXF419Ztl73tU1juATD3J s26/r/kwKfhxRzuZHkfJOVsHpzsSdCyE0Gr4e9wHhpEivgZ/5+8CZH7TP+8oK3l4obnF a+ratmXY8YfAk4gJxZ9NeGZsIeGDfSOsHbJE5zaK9QlI0V2w6BO3SmqPeRgIq3yDvN73 YXsRcK+d56TXtjIVU7XmvC1UoEfnwAndqLIWoxFGy0SbmOjHjYt4AlfxV3u/N7AGcsxj AYOg== X-Gm-Message-State: ALoCoQl7xRa0ghXIY0nQSAA+fth9dnppw5aeAVcJ4S+wrptzHoWLaTrjoH8JpMI0kEIMJqXklt6l X-Received: by 10.236.98.33 with SMTP id u21mr14472239yhf.39.1401296969347; Wed, 28 May 2014 10:09:29 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.72 with SMTP id k66ls205946qgd.96.gmail; Wed, 28 May 2014 10:09:29 -0700 (PDT) X-Received: by 10.52.147.200 with SMTP id tm8mr1090366vdb.54.1401296969208; Wed, 28 May 2014 10:09:29 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id sv4si11092873vdc.72.2014.05.28.10.09.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 May 2014 10:09:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id jw12so12700284veb.6 for ; Wed, 28 May 2014 10:09:29 -0700 (PDT) X-Received: by 10.58.34.72 with SMTP id x8mr981649vei.61.1401296969099; Wed, 28 May 2014 10:09:29 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp220328vcb; Wed, 28 May 2014 10:09:27 -0700 (PDT) X-Received: by 10.140.20.144 with SMTP id 16mr1271574qgj.114.1401296967735; Wed, 28 May 2014 10:09:27 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id j5si22356828qco.22.2014.05.28.10.09.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 May 2014 10:09:27 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WphKR-0007nk-7D; Wed, 28 May 2014 17:07:51 +0000 Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WphKP-0007m5-CS for linux-arm-kernel@lists.infradead.org; Wed, 28 May 2014 17:07:50 +0000 Received: from edgewater-inn.cambridge.arm.com (edgewater-inn.cambridge.arm.com [10.1.203.25]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id s4SH7Mwo003824; Wed, 28 May 2014 18:07:22 +0100 (BST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 0FE3A1AE33E5; Wed, 28 May 2014 18:07:27 +0100 (BST) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: mm: fix pmd_write CoW brokenness Date: Wed, 28 May 2014 18:07:16 +0100 Message-Id: <1401296836-16837-1-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 1.9.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140528_100749_777577_A455D9E6 X-CRM114-Status: GOOD ( 11.99 ) X-Spam-Score: -5.7 (-----) X-Spam-Report: SpamAssassin version 3.3.2 on bombadil.infradead.org summary: Content analysis details: (-5.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.96.50 listed in list.dnswl.org] -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record Cc: Catalin Marinas , Will Deacon , Steve Capper X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: will.deacon@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Commit 9c7e535fcc17 ("arm64: mm: Route pmd thp functions through pte equivalents") changed the pmd manipulator and accessor functions to convert the target pmd to a pte, process it with the pte functions, then convert it back. Along the way, we gained support for PTE_WRITE, however this is completely ignored by set_pmd_at, and so we fail to set the PMD_SECT_RDONLY for PMDs, resulting in all sorts of lovely failures (like CoW not working). Partially reverting the offending commit (by making use of PMD_SECT_RDONLY explicitly for pmd_{write,wrprotect,mkwrite} functions) leads to further issues because pmd_write can then return potentially incorrect values for page table entries marked as RDONLY, leading to BUG_ON(pmd_write(entry)) tripping under some THP workloads. This patch fixes the issue by routing set_pmd_at through set_pte_at, which correctly takes the PTE_WRITE flag into account. Given that THP mappings are always anonymous, the additional cache-flushing code in __sync_icache_dcache won't impose any significant overhead as the flush will be skipped. Cc: Steve Capper Cc: Catalin Marinas Signed-off-by: Will Deacon Tested-by: Marc Zyngier --- Whilst this is a fairly scary change at this point in the cycle, I can't get through an LTP run without it. Furthermore, spurious CoW failures for tasks that happen to get transparent hugepages are a pretty significant regression. arch/arm64/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 90c811f05a2e..20785f9da95c 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -266,7 +266,7 @@ static inline pmd_t pte_pmd(pte_t pte) #define pmd_page(pmd) pfn_to_page(__phys_to_pfn(pmd_val(pmd) & PHYS_MASK)) -#define set_pmd_at(mm, addr, pmdp, pmd) set_pmd(pmdp, pmd) +#define set_pmd_at(mm, addr, pmdp, pmd) set_pte_at(mm, addr, pmdp, pmd_pte(pmd)) static inline int has_transparent_hugepage(void) {