Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752577AbcCIFg7 (ORCPT ); Wed, 9 Mar 2016 00:36:59 -0500 Received: from mail-bl2on0067.outbound.protection.outlook.com ([65.55.169.67]:47264 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751712AbcCIFgw (ORCPT ); Wed, 9 Mar 2016 00:36:52 -0500 X-Greylist: delayed 1055 seconds by postgrey-1.27 at vger.kernel.org; Wed, 09 Mar 2016 00:36:52 EST Authentication-Results: lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=none action=none header.from=caviumnetworks.com; From: Ganapatrao Kulkarni To: , , , CC: , Subject: [PATCH] arm64: Fix the ptep_set_wrprotect() to set PTE_DIRTY if (PTE_DBM && !PTE_RDONLY) Date: Wed, 9 Mar 2016 10:32:48 +0530 Message-ID: <1457499768-31176-1-git-send-email-gkulkarni@caviumnetworks.com> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: MAXPR01CA0009.INDPRD01.PROD.OUTLOOK.COM (25.164.147.16) To BLUPR0701MB1684.namprd07.prod.outlook.com (25.163.84.30) X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1684;2:RG78xiGF8rQUkJns6OMY4FjYwxrxKzHyOTiKNBLm9aVcmTIVac9WHd3qIuwCF1ZGToJC3RvGB9uC6Iu8eUlqs6Hp0gXuK8YA3Kk75ghLIjehB5gz0u6KxUJfHgHSku7NjrFHrNDMPgo48e05IKXUzg==;3:9YGAOw7rdwjuH1S6PjyMv/0tqPDUZ9e8ssF5s20MvXejkcYfIOwWVSmzx+/9TNA2CTZaksbzewLOTHd3tDKmn/vAzqqPZUeX64BcizFxde9fKQaP0BiAh6kDQCQnhnWh;25:9+V06j2dBJ2K5IlhnUtJtEA9Rwkh5vpdDvh6ZipZ75vJ1wEfBygFAOverLBD0lf6OQPGqjxY90ubLlqCQ7xTn7jOAIXg74SszS99kL5zeuVl2CxfXc0jSi7VUsRpAC/AQFZA2Nw5wXfeiULPNCXt1y7rh2hr2pWZLNED/fZg0WF6BLYHP3rHnIuVbspViRjSXESaONB0sXe7UuRyLoU/Hae7AKKfrT4vg3dXvWRq6M7U71i9y8V4NirgTtygv4gsx3AyugoyYviFfi7t0RvuMSMOcbTEMo8MSohnlxL53gF7HXfhwNnCAc6jx1qZXuH6tDAoiQqjIUQGwkSChPYhdA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0701MB1684; X-MS-Office365-Filtering-Correlation-Id: 33fab0cd-42df-447b-8d40-08d347d823b5 X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1684;20:6Q5QeF5WrSDRBQk6K1SneMTk8gnulFRJ8Kuyj8auivnXNNRxKt2C3xLLI6Ns2SvuFb12W/PsKdRqB/umddNFVkV7bTVaTrsWpOD1W2EIN9j+0FbHiKNHyCnDyT8QLNNZtAM4R6iiZIjti1iulmR4gWj4GXktvvbbmLr2PSiXzh4Ira7thoF/BfMd2V3zVVyS5ocKOFowQ9hLOW8ZJX/qp/u54rRmqhxTYOVy5lbhS+LookyousXnwpUhgf5FQ4acMtfqI29tPGWGv9GBVbi31LWzU5s+925vvxn/5Y8F3E4M7Pko9aSdgEQUKyD3RwDBbZMeTIPaQdObHtoSTM4h7pF0NpZBSwdURsAcjkw2MnrGvJUsmP/G2Alm6OqXy/NDEA2R1nGjgFjSwBauOCUcoIaCisaag5oHe4xafpmIqf2b1sDJP68LLoP3Q5+anEMgQP1C9USoTatBttqsYito0fyszrdLOU0p8zJhMt0AlgonD3AoUd1Bqcv++ii9uW+0gqTCnPT3vaM3+ACUfeaDobBrMRjr/gIQvOc7UaUEdeG5DugSXjNEF5Mo9Yt8KQuDMSzRsKITNpEz3ZSpaPwkzsig7p5mbmqIlBj+xLcpeus= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001);SRVR:BLUPR0701MB1684;BCL:0;PCL:0;RULEID:;SRVR:BLUPR0701MB1684; X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1684;4:z+pFln91S/BETAINxs3o//rwdEdF+1oatdHxPo/qqSae3r8o+DWqUkRdF/m/tPJAjYTjXcw1PYLs8lj10vv8VBc/S2/T6r7MEMbNAGr1IvlXnVTo8ccz2ucB/Kc9hrTMs3T1fdV0C7cZYNb+msJAPaFvUVN8PfbqBwe1C8oMUUK8OHCydFpO3xnK+91NlIvEajyTQyxLcX4x2t6KDixX/uxIiqX3mFf3XqIZvcKOsBmxXwY9L6XEqKTwjw5Hi039KlnlbXZoniT/DRXGgPbZq791S/d+HbequBOWt/ZSd9uSs3ct5eOzshu06ujT4eDG48YM5aX9nP900I9+PpUqmBxNWGl7qBOevUNlIxQGjwMc8TzRz63MGof6hhiC2Wge X-Forefront-PRVS: 0876988AF0 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(48376002)(81166005)(105586002)(229853001)(42186005)(50466002)(33646002)(19580395003)(189998001)(5001770100001)(97736004)(36756003)(19580405001)(47776003)(2906002)(1096002)(66066001)(50226001)(92566002)(3846002)(6116002)(77096005)(586003)(5009440100003)(2201001)(5008740100001)(5003940100001)(5004730100002)(4326007)(50986999)(7099028)(14143004)(4720700001)(2101003)(473944003);DIR:OUT;SFP:1101;SCL:1;SRVR:BLUPR0701MB1684;H:mypc.cavium.com.com;FPR:;SPF:None;MLV:nov;PTR:InfoNoRecords;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BLUPR0701MB1684;23:xCvmX4e9jOG/Qo0eyLOGuxo6lPDztCzVXzluHfz?= =?us-ascii?Q?OGgr/f036dtrOhkbGxIReXw1Rcov3jP2/zW11v1nbJgmJd0wQSKN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259U0F2FsuQCht6FAxkqFJtq+9kz?= =?us-ascii?Q?n5y9V3JWiIGSKaq5t992caY9o?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR0701MB1684;5:y+YT/dt5iAgrcBGEVhZhAJINiHB0dyur88rq8pSDsxLm6d712QDrBFAPsdwUK0Yv3LRNrBMY/Up31zzAiH9WeJWh9AfLKBqXBMzJWuQhK1QnMI1m7uZ0uoNmTAwfPqFydmRt7tV/W08eOLPlR6FZoA==;24:3YPIhumRkJhvBNzZXcPIFY4n1dcMeUmHqlHR80tAp6JZAf4wYcsUspKOOo9vH2WTacZZN1htebmMlkGp9qo7tRUPQXLQZGd2yreGVw6R6oU= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2016 05:03:20.5727 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0701MB1684 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2483 Lines: 63 Commit 2f4b829c625e ("arm64: Add support for hardware updates of the access and dirty pte bits") introduced support for handling hardware updates of the access flag and dirty status. ptep_set_wrprotect is setting PTR_DIRTY if !PTE_RDONLY, however by design it suppose to set PTE_DIRTY only if (PTE_DBM && !PTE_RDONLY). This patch addes code to test and set accordingly. This patch fixes BUG, kernel BUG at /build/linux-StrpB2/linux-4.4.0/fs/ext4/inode.c:2394! Internal error: Oops - BUG: 0 [#1] SMP on thunderx numa board, when ARM64_HW_AFDBM and NUMA_BALANCING are enabled. note: this patch is not tested on platform which supports AFDBM. Signed-off-by: Ganapatrao Kulkarni --- arch/arm64/include/asm/pgtable.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index f506086..d396892 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -613,20 +613,24 @@ static inline pmd_t pmdp_get_and_clear(struct mm_struct *mm, #define __HAVE_ARCH_PTEP_SET_WRPROTECT static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long address, pte_t *ptep) { - pteval_t pteval; + pteval_t pteval, pteval2; unsigned long tmp; asm volatile("// ptep_set_wrprotect\n" - " prfm pstl1strm, %2\n" - "1: ldxr %0, %2\n" - " tst %0, %4 // check for hw dirty (!PTE_RDONLY)\n" - " csel %1, %3, xzr, eq // set PTE_DIRTY|PTE_RDONLY if dirty\n" - " orr %0, %0, %1 // if !dirty, PTE_RDONLY is already set\n" - " and %0, %0, %5 // clear PTE_WRITE/PTE_DBM\n" - " stxr %w1, %0, %2\n" + " prfm pstl1strm, %3\n" + "1: ldxr %0, %3\n" + " and %2, %0, %4 //extract bits PTE_WRITE and PTE_RDONLY\n" + " cmp %2, %5 // compare wth PTE_WRITE\n" + " b.ne 2f\n" + " orr %0, %0, %8 // Set PTE_DIRTY if (PTE_DBM && !PTE_RDONLY)\n" + "2: tst %0, %6 // check for !PTE_RDONLY\n" + " csel %1, %6, xzr, eq // select PTE_RDONLY if !PTE_RDONLY\n" + " orr %0, %0, %1 // set PTE_RDONLY if !PTE_RDONLY\n" + " and %0, %0, %7 // clear PTE_WRITE/PTE_DBM\n" + " stxr %w1, %0, %3\n" " cbnz %w1, 1b\n" - : "=&r" (pteval), "=&r" (tmp), "+Q" (pte_val(*ptep)) - : "r" (PTE_DIRTY|PTE_RDONLY), "L" (PTE_RDONLY), "L" (~PTE_WRITE) + : "=&r" (pteval), "=&r" (tmp), "=&r" (pteval2), "+Q" (pte_val(*ptep)) + : "r" (PTE_WRITE|PTE_RDONLY), "r" (PTE_WRITE), "r" (PTE_RDONLY), "L" (~PTE_WRITE), "L" (PTE_DIRTY) : "cc"); } -- 1.8.1.4