From patchwork Thu Nov 3 02:27:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huang Shijie X-Patchwork-Id: 9410073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A065660721 for ; Thu, 3 Nov 2016 02:30:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E9212A497 for ; Thu, 3 Nov 2016 02:30:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82E5C2A6F1; Thu, 3 Nov 2016 02:30:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 396CA2A497 for ; Thu, 3 Nov 2016 02:30:15 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c27lb-0001QZ-0h; Thu, 03 Nov 2016 02:28:35 +0000 Received: from mail-he1eur01on0059.outbound.protection.outlook.com ([104.47.0.59] helo=EUR01-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c27lO-0001Nj-60 for linux-arm-kernel@lists.infradead.org; Thu, 03 Nov 2016 02:28:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=bw/YiAadWchiSAvL9U/88awZDEvfIX6QjxU3ttDYgRw=; b=E4GTmAA6lkDL/OgDSbE59JyeFpacZU61P3VkfjbTId8Tn9GNPOuvQYya3WgSwkJmdeVPFKRB6NhqQLsi5K2goWcn1WfcTLSoUtZ8eIhZPa7nYUdeOOui46C4YoymCrD13J5JjPN+QDxAvgF8kCaQYCmMynFhIWJO4YSxLGEwRZ8= Received: from VI1PR0801CA0058.eurprd08.prod.outlook.com (10.168.60.154) by VI1PR0802MB2576.eurprd08.prod.outlook.com (10.172.255.142) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.693.12; Thu, 3 Nov 2016 02:27:59 +0000 Received: from DB3FFO11FD050.protection.gbl (2a01:111:f400:7e04::147) by VI1PR0801CA0058.outlook.office365.com (2603:10a6:800:4d::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.609.9 via Frontend Transport; Thu, 3 Nov 2016 02:27:59 +0000 Authentication-Results: spf=pass (sender IP is 217.140.96.140) smtp.mailfrom=arm.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 217.140.96.140 as permitted sender) receiver=protection.outlook.com; client-ip=217.140.96.140; helo=nebula.arm.com; Received: from nebula.arm.com (217.140.96.140) by DB3FFO11FD050.mail.protection.outlook.com (10.47.217.81) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.693.6 via Frontend Transport; Thu, 3 Nov 2016 02:27:58 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:939; Count:13 Received: from sha-win-210.shanghai.arm.com (10.1.2.79) by mail.arm.com (10.1.106.66) with Microsoft SMTP Server id 14.3.294.0; Thu, 3 Nov 2016 02:27:53 +0000 From: Huang Shijie To: Subject: [PATCH 1/2] arm64: hugetlb: remove the wrong pmd check in find_num_contig() Date: Thu, 3 Nov 2016 10:27:38 +0800 Message-ID: <1478140059-13829-2-git-send-email-shijie.huang@arm.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1478140059-13829-1-git-send-email-shijie.huang@arm.com> References: <1478140059-13829-1-git-send-email-shijie.huang@arm.com> MIME-Version: 1.0 X-IncomingHeaderCount: 13 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:CAL; SCL:-1; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(199003)(189002)(586003)(104016004)(189998001)(26826002)(5003940100001)(11100500001)(229853001)(76176999)(106466001)(4326007)(626004)(2351001)(50986999)(2906002)(50466002)(48376002)(77096005)(92566002)(47776003)(36756003)(33646002)(2950100002)(5660300001)(110136003)(6636002)(6666003)(7846002)(19580395003)(19580405001)(8676002)(305945005)(356003)(50226002)(8936002)(87936001)(86362001)(246002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0802MB2576; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD050; 1:0BFJ412mAlQC0xBaYuu4wkYs1BQGdk32HQyROGZYyAjFCIksss+QTXeRgSqLDYwo1cJUdHVWvhj3pnJHfnYIRaqYmtyopH7zIJ4QMGhk2RCjF3JfPCp7bhTzMStTAvYRe69tptrqnZiiWpkSwRS1a9ntm82UXzr89IyDm9KSpHQ2J0mx9TLp1euP4QfYJDWO/s094PQY2+7ox7DJ6rxspIrqdJE3OHLivoyR7sic2yl1oz4+uHb8pV6jEyeAswhRZvXWO+cvX+QktfMQcI5H0D9EKNyWX6RJLBYfqtlplo5FL1SYEIsawYnu1Mr4sRfav5n9VqGtYpva0DTSE9ZHGZE/aPJJYYrEMbqkgeui+COl5VIU8bD2+ZNX1JSQUWWrH1Mp6GXMkkjpm9f7N/9kR6qtyzI4zLT7xqDAxCux3RqxvZE5tjYT/5LXp9V1+ve0MN+ljxzQb4WtBhuGj2Dv6WZsjk3jr9HR+eWPicl1Nhyz7SfjftLyStkw1yCEoSAYIinQSp2WbNJhO/v9lGOVj1zFqk3ng6hQ1QjHPIuEKxTJiz5g896hMQ9yD0bUoKxrsaAi+iVqgbPH1Zg6suxr5eUDFHMlE4sAxOnMVmgsKTSpzrvrIJc/nUmCQV3ui7Si X-MS-Office365-Filtering-Correlation-Id: 69d50a63-dca4-42aa-f2d7-08d4039106cc X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2576; 2:OI1E0Rd1D2XZSvM4G/7n1tY9RTPBs2opDJdkblxZVS1xPoO1ZUCOOXlEma3bW5uJT1wcSEQ20pcaGEXiHvGkgol8fAzA7niAHo+SxgjPwYTNr2rz2XUcv8CuiYF02fheiUWYOU+pVRyvB8dBKw4TNzy8LWJDvx2eACEImKSWq3EOKTlrrwLEu0x23OxmzHdO8fOW2E3BmF1q5+1hif5Iaw==; 3:6i9zhjF7/m7TTJHP8SspHfOr0N5HQ5+vF7wMzPJYIHCU0SsnTwI/T9ZMYCcsBPOm0F51CzEWF9g6zfHoKG4qasXCahYI6pM8hDsbfkgatbAWlGAc6pLs10E+Q/TUdiwEPThjvpnL5QioyLTxQqVXHCzHurce6H9g0TMdzYpEc/PlJVvmV563YJN290nXidrqok0qL5JOvM4i9UOio1nFI6y7dMAJEWyx9RRSWI8Cx3+wTImoybHa2yvd5Axue+7XBjuxOWQCWScuDOwPr6Fn9YOaIddTXvXFfRi0YonJXy8= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:VI1PR0802MB2576; X-Microsoft-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35qnPB7mZtxbjGXLDdU7IAHqyiFj3ESULsiw==; 20:XFwEBMfysOPAdXrUebcaqVYbGQKYJWtmaGCjhyJcNNqsovRJT93gQ1ZabC0OOsylCKZhh6xmLrGoXGmexd9t/jdCSnNPU6E7ikLwHB/5Urv7mlcKECZ9fynu8pMdXHCzkjhU9JfvO0L1rR6fzWlBJ0jP8DHW3T37apYfspyQbVCQWrTxZKIZVYdvWcPZfkK5kokoaw7DyB7JBWWY3kZHHuS95jWnQ30NrxJpw+Ztw0qBx/0jgRtXghEj58DZFoGO NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(13024025)(13020025)(13013025)(13023025)(3002001)(10201501046)(6055026); SRVR:VI1PR0802MB2576; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0802MB2576; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2576; 4:RGf7evleLFVRbQOS4O37QHoO+tU+IL+QplE199BoQ/TpyD9QtAEfFfJy5PV7TVIBTG/Brzwqwtlkiw14xKuyUb1lJkirHIUBbm/g544A/EAA6dCdRg+7qw+TYD29AgoM0SDXWWKMgQN6qNCvbKiUG8vF3/2MwknM2V59E7Sz1vktSyuXEDvM2zBpo416Bc7zD/BcgCTC+Shofx6G6yiIcMb87H8L71eKJzlTfCsNRr762K51FLtJ04YR6NOaYUb5tLQ5vCf4dv1aJCZpv12OOcD/dgeaqiWcaBgY1uM3LmxVHitQX3B6KV0gu2RJifGA0RmpVmHqW0AAMQrbNX1wMRDb7C499es9BJFIJuwnTI95PpaDV4Df0RhzUoi8g+X1PzAAx5uTA+E93GflkWMCXqIdwPFpgH5JFYQwoSrpbjqmLbp0OxycG09zM6liT1RvgmWyNsQA/N3koVEtveudprOgK/xNMr2l0HW2SDqb0yIHPN+QkYEoeW1rvqgeLxOC2iY1gzinKgmKAt2GBkViTui5EsxnA6s13V4R3SEG//Q= X-Forefront-PRVS: 011579F31F X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0802MB2576; 23:5sP5F4npLKjq/ThJWYTTrk6R/DJXANSBUG06A8A?= =?us-ascii?Q?8D9ibUiYS30itO+DOECj9HyYoUlm2S7+NQwBncSrRhkS7A5nX5RI7TJL4WRx?= =?us-ascii?Q?drExzTqUQu2P23mC2z5Itc4F++UiHXYWfuuqV2b9/5f54/d4Xb+h3y5JLlCi?= =?us-ascii?Q?HbcL7TlK17FD1AYUWgIZ1jHBULBMSAi/+tCLtu5Rf9TJDLrfwspcjATU+W4A?= =?us-ascii?Q?OYblRWEyljnR8Sd3S3IME+2DUsQqVNipzIZ3opkq68ojnZ3PabTJ6dssYUP/?= =?us-ascii?Q?qr9htZ+A0BTQr+7JTbyTm/gcfNM1RBn2PBNdY58lG440eCj8jjmNuSbSOpoI?= =?us-ascii?Q?6wYynSBM03STOb8gtw7gsFig9rpL7Bq6RrL38lpjl1jh/Q3a61+d/hecqb69?= =?us-ascii?Q?9RJCg72v9WDDHcsB20iQ5x3gAyO1fVQpP4wx+k4V7mzo3K2uQwlHYgqAWAg1?= =?us-ascii?Q?zTQnSpyrgddF/4gKMewKtSX0hiLY3GeIxRWUGB1t7I/aL7x8gJtm363g5cfS?= =?us-ascii?Q?Upzp2hPNQOrx+ylgIvtqg0Kfrf7bJNDOyyy4n2YOOwOevnngSfGSx14tp1O8?= =?us-ascii?Q?+7hCTsnkCrpEDycbPk0N6Or4lO00nT0InMsu9HhHlgvOrisJjFVBz09LYeaP?= =?us-ascii?Q?fP6ydZ1LLeQG++fx7SubHe9zXIXGRwmrSKTxfZm/ivphwrY21kGcWtzyuQ0y?= =?us-ascii?Q?PyaQ4RBYJ65iIDY5BhQLV+72QcZ2MVYq9CMrcl9p06S9ZDGO/KnEZmYeit3d?= =?us-ascii?Q?YIAg3K0kCM3FH5nyacMvWw3/q7e2pXn+4YgeMYmFCS/FGwLH+Hwpnnv0RVjw?= =?us-ascii?Q?wifm5SuZE01vuhU8yWS8PA0bOTw05Wx4TIM7ADwzALZK5TjvaT5ywpypx3tG?= =?us-ascii?Q?wajY318K21QnhvftkWNewK6QQrn+zk7mSXeUESPZw3wjPoaoJWdXKuzATwff?= =?us-ascii?Q?ALtg1HjP5lBrKMIxH2BKANaX97QN4pGc4FZRKlmzUd2u9ewLf0nuMxdoHv8g?= =?us-ascii?Q?8DwtQ8Gs/vxUbxEvPtrQpdTtMw64Z7wX6tZygDuBw6XkRMofw6xXLgRIi+oH?= =?us-ascii?Q?Tq2oBbMBfPcjME2EXwpjRELPlfEse?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2576; 6:mk1/FqLZBsfYbb1odIjmf7Tpkd2ULX8C85qnL4p5IwqmRA9G/qgLLQv56kpTTR2yAZ8ImTKnXM7UKH0heT4YMYjVPodv9wG5XyqXdMHR4oqeEnCBAGvYV3Q8rdzE6b4dIHWw0DfR5vpY2vmWSqIw8AKuihj2omoCIuZFtjqur3YbQdZyeF+lxTqzpgOR7iayoErb/ux8C3AZ6JtG4pWM9LTxnR4nI9/jM0pXAuwhifKe/QeAOZV310WWv/ZWdl95XSvfEkLIfCnpJZXaGWFOnJGBqpmuqprf+7K/WeZm7XhWIIEQAsjEQf38+77EP8cig4rj/Eemc04AEi4mTpG7vg==; 5:Ho3MbC9NRN/8keAAh6c7RM8PwK+mu2BpyZtzVKHhAimKBlWWwf7KlNMdRo58mP6KySOIHiwf9VVZUrNVJ4ZI3QNhbpxPTJfPKWIlh/KXWb54RjndysDxUS7NWMSHD7txRk20u/pycKJboYxjwPMeww==; 24:0BGTIF/VZCcMhY0ssllguU3dgUulMrxqWFRXtZs3skIZsd1Us3hyPoBGvm4zzlqxzTZOKTVQd0EfT+oVpN4MHoRSItSD3GTXdRopYr9Co7U= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0802MB2576; 7:BhugHJAUiYLJyuu6aIog9LUm0n9j/Eri5FK3NJpEV5KP4MvvQB11EFkPAyKq0Fjue5jTTSn/Zb8NLeUGnp+3iHglPwNB+FVYk/hfsPWmvMs3gI0x20YWjbkuOaLUHUQ7HmshcQmjfDcLuGEeXNfLzXb0lWIftnAmqLTqd6Wu3EH/fgO5gjPjbN1tcJUmt1ytMDle2KVam8EUhiUG2/2QVg6u8zvEZ0A7pRe95TiDzAJt0Rwf7BtNgWc2+TSQENOxpgKsgVIi/tms8XoSRi6ddX0/6TiH6mzkiyXW53byUR/MglYHQc7X5dJa5tmgibAqi/YOOrjdJ4UjZP73pWdHOLAR+3AM5J6KSAiAauZPzJs= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Nov 2016 02:27:58.2822 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0802MB2576 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161102_192822_697282_BD748BC8 X-CRM114-Status: GOOD ( 10.05 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dwoods@mellanox.com, steve.capper@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, kaly.xin@arm.com, Huang Shijie , akpm@linux-foundation.org, nd@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The find_num_contig() will return 1 when the pmd is not present. It will cause a kernel dead loop in the following scenaro: 1.) pmd entry is not present. 2.) the page fault occurs: ... hugetlb_fault() --> hugetlb_no_page() --> set_huge_pte_at() 3.) set_huge_pte_at() will only set the first PMD entry, since the find_num_contig just return 1 in this case. So the PMD entries are all empty except the first one. 4.) when kernel accesses the address mapped by the second PMD entry, a new page fault occurs: ... hugetlb_fault() --> huge_ptep_set_access_flags() The second PMD entry is still empty now. 5.) When the kernel returns, the access will cause a page fault again. The kernel will run like the "4)" above. We will see a dead loop since here. The dead loop is caught in the 32M hugetlb page (2M PMD + Contiguous bit). This patch removes wrong pmd check, and fixes this dead loop. Acked-by: Steve Capper Signed-off-by: Huang Shijie --- arch/arm64/mm/hugetlbpage.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 2e49bd2..4811ef1 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -61,10 +61,6 @@ static int find_num_contig(struct mm_struct *mm, unsigned long addr, return 1; } pmd = pmd_offset(pud, addr); - if (!pmd_present(*pmd)) { - VM_BUG_ON(!pmd_present(*pmd)); - return 1; - } if ((pte_t *)pmd == ptep) { *pgsize = PMD_SIZE; return CONT_PMDS;