From patchwork Tue Nov 19 17:35:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Capper X-Patchwork-Id: 21629 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8A6DE23A4E for ; Tue, 19 Nov 2013 17:35:42 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id tp5sf3998313ieb.5 for ; Tue, 19 Nov 2013 09:35:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=NlHZBMQbZXPtdARnHMrP2dIFKBHIyzLjMCvi+qfLfwU=; b=Z5XgO48wP9XY0vj8V0mmUbrSMdK5d7LYDSctrcuZMf4XCpCdZSl2QXGYPGm2vRFyMl dSmwIcP2tiFCdYJe8Y7DUXbbF1iEzHDuNAybkzs7dH9mRnbRv8LvQyVlJupDXRBUlU5b SL6KO5A/p2SSD6r3hXOh/bN2KFQ860betiyDY/FzXyZo/hSpViNLE0hnMm9NLcAur5qE PzO5XHEnU64hDbFebwhfUho7On26nAjsjo3YzO0fUC5fvc/wI8DsVOK8Cftt762/1tBe EDPdTEQMr9zxQq4o7dqoXXeib+coExEuo3qOQlOYV8LTl9RveTMJr36b6eT1Z6fLuyjA FCGA== X-Gm-Message-State: ALoCoQkgC3YNaBbAi0uXodMrYHTm/D8oT6kqgj84a4rHkQRq7qzRHsSCeM8K4BsrKmyTkdHdt3xI X-Received: by 10.182.129.227 with SMTP id nz3mr10477989obb.25.1384882542149; Tue, 19 Nov 2013 09:35:42 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.99.10 with SMTP id em10ls3235749qeb.82.gmail; Tue, 19 Nov 2013 09:35:42 -0800 (PST) X-Received: by 10.52.168.106 with SMTP id zv10mr16071947vdb.21.1384882542052; Tue, 19 Nov 2013 09:35:42 -0800 (PST) Received: from mail-vb0-f54.google.com (mail-vb0-f54.google.com [209.85.212.54]) by mx.google.com with ESMTPS id dk5si8245508vcb.146.2013.11.19.09.35.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Nov 2013 09:35:41 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.54; Received: by mail-vb0-f54.google.com with SMTP id p6so2738124vbe.27 for ; Tue, 19 Nov 2013 09:35:41 -0800 (PST) X-Received: by 10.52.165.131 with SMTP id yy3mr2337484vdb.25.1384882541835; Tue, 19 Nov 2013 09:35:41 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp295022vcz; Tue, 19 Nov 2013 09:35:41 -0800 (PST) X-Received: by 10.180.20.102 with SMTP id m6mr21944836wie.22.1384882540534; Tue, 19 Nov 2013 09:35:40 -0800 (PST) Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) by mx.google.com with ESMTPS id lp11si5623715wic.29.2013.11.19.09.35.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Nov 2013 09:35:40 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.51 is neither permitted nor denied by best guess record for domain of steve.capper@linaro.org) client-ip=74.125.82.51; Received: by mail-wg0-f51.google.com with SMTP id m15so7852499wgh.6 for ; Tue, 19 Nov 2013 09:35:40 -0800 (PST) X-Received: by 10.180.39.238 with SMTP id s14mr22290254wik.60.1384882540104; Tue, 19 Nov 2013 09:35:40 -0800 (PST) Received: from marmot.wormnet.eu (marmot.wormnet.eu. [188.246.204.87]) by mx.google.com with ESMTPSA id s2sm7529862wiy.7.2013.11.19.09.35.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Nov 2013 09:35:39 -0800 (PST) From: Steve Capper To: linux-arm-kernel@lists.infradead.org Cc: linux@arm.linux.org.uk, will.deacon@arm.com, catalin.marinas@arm.com, christoffer.dall@linaro.org, patches@linaro.org, Steve Capper Subject: [PATCH 1/3] ARM: mm: Rewire LPAE set_huge_pte_at Date: Tue, 19 Nov 2013 17:35:27 +0000 Message-Id: <1384882529-28104-2-git-send-email-steve.capper@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1384882529-28104-1-git-send-email-steve.capper@linaro.org> References: <1384882529-28104-1-git-send-email-steve.capper@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: steve.capper@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.54 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , For LPAE, set_huge_pte_at calls set_pte_at which then calls set_pte_ext, which in turn is wired up to call cpu_v7_set_pte_ext, which is defined in proc-v7-3level.S. For huge pages, given newprot a pgprot_t value for a shared writable VMA, and ptep a pointer to a pte belonging to this VMA; the following behaviour is assumed by core code: hugetlb_change_protection(vma, address, end, newprot); ... huge_pte_write(huge_ptep_get(ptep)); /* should be true! */ Unfortunately, cpu_v7_set_pte_ext will change the bit layout of the resultant pte, and will set the read only bit if the dirty bit is not also enabled. If one were to allocate a read only shared huge page, then fault it in, and then mprotect it to be writeable. A subsequent write to that huge page will result in a spurious call to hugetlb_cow, which causes corruption. This call is optimised away prior to: 37a2140 mm, hugetlb: do not use a page in page cache for cow optimization If one runs the libhugetlbfs test suite on v3.12-rc1 upwards, then the mprotect test will cause the afformentioned corruption and before the set of tests completes, the system will be left in an unresponsive state. (calls to fork fail with -ENOMEM). This patch re-implements set_huge_pte_at to dereference the pte value explicitly. hugetlb_cow is no longer called spuriously, and the unit tests complete succesfully. Signed-off-by: Steve Capper --- arch/arm/include/asm/hugetlb-3level.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm/include/asm/hugetlb-3level.h b/arch/arm/include/asm/hugetlb-3level.h index d4014fb..211e9a8 100644 --- a/arch/arm/include/asm/hugetlb-3level.h +++ b/arch/arm/include/asm/hugetlb-3level.h @@ -40,7 +40,12 @@ static inline pte_t huge_ptep_get(pte_t *ptep) static inline void set_huge_pte_at(struct mm_struct *mm, unsigned long addr, pte_t *ptep, pte_t pte) { - set_pte_at(mm, addr, ptep, pte); + VM_BUG_ON(addr >= TASK_SIZE); + + if (pte_present_user(pte)) + __sync_icache_dcache(pte); + + *ptep = pte; } static inline void huge_ptep_clear_flush(struct vm_area_struct *vma,