From patchwork Wed Jul 25 16:19:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 10544289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 584CF139A for ; Wed, 25 Jul 2018 16:19:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 471B12A409 for ; Wed, 25 Jul 2018 16:19:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B1E12A5BD; Wed, 25 Jul 2018 16:19:35 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06F542A409 for ; Wed, 25 Jul 2018 16:19:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB4E36B000E; Wed, 25 Jul 2018 12:19:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B65766B0010; Wed, 25 Jul 2018 12:19:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0CE76B0266; Wed, 25 Jul 2018 12:19:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by kanga.kvack.org (Postfix) with ESMTP id 3B3286B000E for ; Wed, 25 Jul 2018 12:19:32 -0400 (EDT) Received: by mail-ed1-f70.google.com with SMTP id g5-v6so3327970edp.1 for ; Wed, 25 Jul 2018 09:19:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id; bh=zqVLkTkU/lLq0stGM6EnRxGSYl8xHl8xQNFnRBhoK20=; b=e21dHQuzh01ZFlN/IeLNvjcmqyUNWtc8D0mJ1g4NU7og2173n5TlvxC6M7FtMZUEnj /RVhbx5hwB4SZsDMtmIRthIuZGI7BjbiYYBcu6+uIDVfNzLUtTp5w0FB1ywfQlOIXZ5C RKO4kI4q/E+Icd0gSdFUNXTwRqpl9HLIRlG68WztoHJst9y0C7iL2h65vw6Tw2XejPls XjPYEP4VwFC/BAo4suCJWH8H0+7ILszW66M+zg3ykj7/8Lum+7xIlcKWGPn31tLXXveB p5Nwc9YE3K3fqXn1ZjVHbAvn5S1d2OQmF4i0kcl8kpFH+HnrxwXRsD59gI2oLwFW7RQK quSA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: AOUpUlEWV5lTz+dFmWNCstfMfY1NeBb1P/wtSxD7z87OHna79quN0Cxd +/g9kyqrX3vzJq4O3u664fElxFyhKb9t9RjCDw8/DVXThxFu0N8u1HV2K4hIFijhO9f9SJwHUzv jWCNliTvv8o9Q7zSHRcjUpqLQuYNcdZbNPFN084ZFnGIdV3FQJbLLXxq1j2+NjT5C1A== X-Received: by 2002:a50:ad55:: with SMTP id z21-v6mr22861169edc.142.1532535571805; Wed, 25 Jul 2018 09:19:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfihkb0kXxLPnJRcLVUF+XkrZSUkB59Su0CgxkzF63EaX29B54vRFNZf4/o5er66na02n32 X-Received: by 2002:a50:ad55:: with SMTP id z21-v6mr22861135edc.142.1532535571174; Wed, 25 Jul 2018 09:19:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532535571; cv=none; d=google.com; s=arc-20160816; b=VBmn1YXJnN8NGhjgiwPuctHSg+YEBifs09JuiUnokPaJHOLuCQxsSp+LhUWwGveC7k VR2QSa90JV+tN/QaIw0OHYa/T6yGmmbPHStbC6Q/+PTUtMXoX5GuL1xNRX4/FQdenBLz LP4n9j4WvwUYFr+oSmyxwcVBMHlUhcULGHlBgxj0h2++XLbvFJ/wPso8n1s6p7MbWf3M GgXcRbYjSibuVtiuo7dzdC5ZuvhWyDSSpLviDVfafl6QBtbUOQcbD+AZJk58F9WLVYxP hGC8ZtwN45/L4WsK3Bqdwyf7lY+xWSOHm7ML92cLKkyycw8RUKR78ucxXYoo1uAzE4Ep BRsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from :arc-authentication-results; bh=zqVLkTkU/lLq0stGM6EnRxGSYl8xHl8xQNFnRBhoK20=; b=bJsqgywLdrGDURCzqA9bvIfAa5ZJWGg6TbuIH5wogb5/shjBvauqNpD2ka84Hhkawv tT4tjR0ulgX5a5F+qoDotZJq8kmmWOTgl8X1oFiyHLq+0YEvHLtjDg35tNHgH58WVSLA EkdvzH1LL1P2YVMnaB5naZ4c+S2fy1/rUS1obTf0kVWxK5/PwGuu890aopt1gy2Sd4iU oeILepFI1nZUCecoNLLQBwvL4sHlEObMJ+OVO7UH36dE9ZkB4NwXGWkpWlazWsykrdR9 OjwIsN5bzm6tJ8ggIYCBEzByYL2fT1aSkoP6eeErof/E0tXJyfY9xGah9AJj20MWUB3n M3qw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id n6-v6si1346353edb.59.2018.07.25.09.19.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Jul 2018 09:19:31 -0700 (PDT) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.156.1 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w6PGERvk008270 for ; Wed, 25 Jul 2018 12:19:29 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kevj206tr-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 25 Jul 2018 12:19:28 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 25 Jul 2018 12:19:27 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 25 Jul 2018 12:19:25 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w6PGJOWP11731332 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 25 Jul 2018 16:19:24 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46F4EAE062; Wed, 25 Jul 2018 12:18:39 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F412CAE05C; Wed, 25 Jul 2018 12:18:36 -0400 (EDT) Received: from skywalker.ibmmodules.com (unknown [9.199.35.55]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 25 Jul 2018 12:18:36 -0400 (EDT) From: "Aneesh Kumar K.V" To: npiggin@gmail.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, Naoya Horiguchi Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, "Aneesh Kumar K.V" Subject: [PATCH V2 4/6] arch/powerpc/mm/hash: validate the pte entries before handling the hash fault Date: Wed, 25 Jul 2018 21:49:01 +0530 X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180725161903.31257-1-aneesh.kumar@linux.ibm.com> References: <20180725161903.31257-1-aneesh.kumar@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18072516-0068-0000-0000-0000031E0581 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009425; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01065988; UDB=6.00547631; IPR=6.00843848; MB=3.00022321; MTD=3.00000008; XFM=3.00000015; UTC=2018-07-25 16:19:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18072516-0069-0000-0000-000045281CAE Message-Id: <20180725161903.31257-4-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-25_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=663 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807250174 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000014, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Make sure we are operating on THP and hugetlb entries in the respective hash fault handling routines. No functional change in this patch. If we walked the table wrongly before, we will retry the access. Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/mm/hugepage-hash64.c | 6 ++++++ arch/powerpc/mm/hugetlbpage-hash64.c | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/arch/powerpc/mm/hugepage-hash64.c b/arch/powerpc/mm/hugepage-hash64.c index f20d16f849c5..049dcb8c95c2 100644 --- a/arch/powerpc/mm/hugepage-hash64.c +++ b/arch/powerpc/mm/hugepage-hash64.c @@ -51,6 +51,12 @@ int __hash_page_thp(unsigned long ea, unsigned long access, unsigned long vsid, new_pmd |= _PAGE_DIRTY; } while (!pmd_xchg(pmdp, __pmd(old_pmd), __pmd(new_pmd))); + /* + * Make sure this is thp or devmap entry + */ + if (!(old_pmd & (H_PAGE_THP_HUGE | _PAGE_DEVMAP))) + return 0; + rflags = htab_convert_pte_flags(new_pmd); #if 0 diff --git a/arch/powerpc/mm/hugetlbpage-hash64.c b/arch/powerpc/mm/hugetlbpage-hash64.c index b320f5097a06..2e6a8f9345d3 100644 --- a/arch/powerpc/mm/hugetlbpage-hash64.c +++ b/arch/powerpc/mm/hugetlbpage-hash64.c @@ -62,6 +62,10 @@ int __hash_page_huge(unsigned long ea, unsigned long access, unsigned long vsid, new_pte |= _PAGE_DIRTY; } while(!pte_xchg(ptep, __pte(old_pte), __pte(new_pte))); + /* Make sure this is a hugetlb entry */ + if (old_pte & (H_PAGE_THP_HUGE | _PAGE_DEVMAP)) + return 0; + rflags = htab_convert_pte_flags(new_pte); if (unlikely(mmu_psize == MMU_PAGE_16G)) offset = PTRS_PER_PUD;