From patchwork Tue Nov 11 11:31:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Pengyang X-Patchwork-Id: 40566 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 53702241C9 for ; Tue, 11 Nov 2014 11:33:11 +0000 (UTC) Received: by mail-wi0-f197.google.com with SMTP id ex7sf569711wid.0 for ; Tue, 11 Nov 2014 03:33:10 -0800 (PST) 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:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=bbB+IzENsdfjzlgXAfSaTXTOX1+bkNp9UzAWB2j0gu8=; b=HKPIJck786Ev4m4twWfBTTQqkoyxHmhVybWCMCx23s1By5O9McnEZePlGWmbnrdvmg FwxmfjR6AV8XIccKz2TLQnW+70rKyv9tWY6pUJ3UcEacEI1nwnVdOo16WV61GU4BZsVX izOnSdREVRsB48TMhDO2KOFRMQ38roa7fJHHJZQNo2dayWTFnKHV3rofcAs+O5q3Hrdk 9P8MALUjZ7g9RmNxbx6tyX5tqiiYZZBs1GTcChCdy5dsnFNiM18mfg3OEnmEVteDIhal ih/NgJ3eKDecqPWFF9oGvIW3UYrZ9JrOz8GZ+cXDKSP9AOmbIR82sddhIPRSI9+48lsD i9kw== X-Gm-Message-State: ALoCoQnsMpMsNkVr4PSVXFLJyInIsOaKUCDc8zZLuqI1zKocOcYuAIk2ZCljrXxf+w3/APQB8Tnx X-Received: by 10.180.89.7 with SMTP id bk7mr5058642wib.6.1415705590497; Tue, 11 Nov 2014 03:33:10 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.130 with SMTP id d2ls627247laf.32.gmail; Tue, 11 Nov 2014 03:33:10 -0800 (PST) X-Received: by 10.112.199.100 with SMTP id jj4mr15165318lbc.71.1415705590266; Tue, 11 Nov 2014 03:33:10 -0800 (PST) Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com. [209.85.217.176]) by mx.google.com with ESMTPS id ra3si31215260lbb.24.2014.11.11.03.33.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 03:33:10 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176; Received: by mail-lb0-f176.google.com with SMTP id 10so7524808lbg.35 for ; Tue, 11 Nov 2014 03:33:10 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr35639758lbc.34.1415705590136; Tue, 11 Nov 2014 03:33:10 -0800 (PST) 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.112.184.201 with SMTP id ew9csp239544lbc; Tue, 11 Nov 2014 03:33:09 -0800 (PST) X-Received: by 10.66.119.70 with SMTP id ks6mr39531568pab.74.1415705587908; Tue, 11 Nov 2014 03:33:07 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ms8si6258344pdb.144.2014.11.11.03.33.07 for ; Tue, 11 Nov 2014 03:33:07 -0800 (PST) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751896AbaKKLdD (ORCPT + 1 other); Tue, 11 Nov 2014 06:33:03 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:2610 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753120AbaKKLdA (ORCPT ); Tue, 11 Nov 2014 06:33:00 -0500 Received: from 172.24.2.119 (EHLO szxeml406-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CEG64699; Tue, 11 Nov 2014 19:32:55 +0800 (CST) Received: from linux-2wy1.site (10.107.197.185) by szxeml406-hub.china.huawei.com (10.82.67.93) with Microsoft SMTP Server id 14.3.158.1; Tue, 11 Nov 2014 19:32:48 +0800 From: Hou Pengyang To: , CC: Subject: [PATCH 12/12] ARM: 8109/1: mm: Modify pte_write and pmd_write Date: Tue, 11 Nov 2014 11:31:39 +0000 Message-ID: <1415705499-197612-13-git-send-email-houpengyang@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1415705499-197612-1-git-send-email-houpengyang@huawei.com> References: <1415705499-197612-1-git-send-email-houpengyang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.197.185] X-CFilter-Loop: Reflected Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.176 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Steven Capper commit ded9477984690d026e46dd75e8157392cea3f13f upstream. For LPAE, we have the following means for encoding writable or dirty ptes: L_PTE_DIRTY L_PTE_RDONLY !pte_dirty && !pte_write 0 1 !pte_dirty && pte_write 0 1 pte_dirty && !pte_write 1 1 pte_dirty && pte_write 1 0 So we can't distinguish between writeable clean ptes and read only ptes. This can cause problems with ptes being incorrectly flagged as read only when they are writeable but not dirty. This patch renumbers L_PTE_RDONLY from AP[2] to a software bit #58, and adds additional logic to set AP[2] whenever the pte is read only or not dirty. That way we can distinguish between clean writeable ptes and read only ptes. HugeTLB pages will use this new logic automatically. We need to add some logic to Transparent HugePages to ensure that they correctly interpret the revised pgprot permissions (L_PTE_RDONLY has moved and no longer matches PMD_SECT_AP2). In the process of revising THP, the names of the PMD software bits have been prefixed with L_ to make them easier to distinguish from their hardware bit counterparts. Signed-off-by: Steve Capper Reviewed-by: Will Deacon Signed-off-by: Russell King [hpy: Backported to 3.10 - adjust the context - ignore change related to pmd, because 3.10 does not support HugePage ] Signed-off-by: Hou Pengyang --- arch/arm/include/asm/pgtable-3level-hwdef.h | 1 + arch/arm/include/asm/pgtable-3level.h | 6 +++--- arch/arm/mm/proc-v7-3level.S | 9 +++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h index 18f5cef..add785b 100644 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h @@ -68,6 +68,7 @@ #define PTE_TYPE_PAGE (_AT(pteval_t, 3) << 0) #define PTE_BUFFERABLE (_AT(pteval_t, 1) << 2) /* AttrIndx[0] */ #define PTE_CACHEABLE (_AT(pteval_t, 1) << 3) /* AttrIndx[1] */ +#define PTE_AP2 (_AT(pteval_t, 1) << 7) /* AP[2] */ #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */ #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */ #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */ diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h index 6d7c532..bb01732 100644 --- a/arch/arm/include/asm/pgtable-3level.h +++ b/arch/arm/include/asm/pgtable-3level.h @@ -71,13 +71,13 @@ #define L_PTE_PRESENT (_AT(pteval_t, 3) << 0) /* Present */ #define L_PTE_FILE (_AT(pteval_t, 1) << 2) /* only when !PRESENT */ #define L_PTE_USER (_AT(pteval_t, 1) << 6) /* AP[1] */ -#define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */ #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */ #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */ #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */ -#define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */ -#define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */ +#define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) +#define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) #define L_PTE_NONE (_AT(pteval_t, 1) << 57) /* PROT_NONE */ +#define L_PTE_RDONLY (_AT(pteval_t, 1) << 58) /* READ ONLY */ /* * To be used in assembly code with the upper page attributes. diff --git a/arch/arm/mm/proc-v7-3level.S b/arch/arm/mm/proc-v7-3level.S index 6f3b047..110e738 100644 --- a/arch/arm/mm/proc-v7-3level.S +++ b/arch/arm/mm/proc-v7-3level.S @@ -78,8 +78,13 @@ ENTRY(cpu_v7_set_pte_ext) tst rh, #1 << (57 - 32) @ L_PTE_NONE bicne rl, #L_PTE_VALID bne 1f - tst rh, #1 << (55 - 32) @ L_PTE_DIRTY - orreq rl, #L_PTE_RDONLY + + eor ip, rh, #1 << (55 - 32) @ toggle L_PTE_DIRTY in temp reg to + @ test for !L_PTE_DIRTY || L_PTE_RDONLY + tst ip, #1 << (55 - 32) | 1 << (58 - 32) + orrne rl, #PTE_AP2 + biceq rl, #PTE_AP2 + 1: strd r2, r3, [r0] ALT_SMP(W(nop)) ALT_UP (mcr p15, 0, r0, c7, c10, 1) @ flush_pte