From patchwork Thu Jan 9 14:26:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Xinhai X-Patchwork-Id: 11325835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0217217EE for ; Thu, 9 Jan 2020 14:27:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B88DF20673 for ; Thu, 9 Jan 2020 14:27:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="s7YXQOOS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B88DF20673 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E17308E0014; Thu, 9 Jan 2020 09:27:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DC7E68E0001; Thu, 9 Jan 2020 09:27:53 -0500 (EST) 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 C68848E0014; Thu, 9 Jan 2020 09:27:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0221.hostedemail.com [216.40.44.221]) by kanga.kvack.org (Postfix) with ESMTP id AD08F8E0001 for ; Thu, 9 Jan 2020 09:27:53 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 69CB92460 for ; Thu, 9 Jan 2020 14:27:53 +0000 (UTC) X-FDA: 76358324826.23.trees87_a9edb5adcf19 X-Spam-Summary: 2,0,0,a54ab5755c146978,d41d8cd98f00b204,lixinhai.lxh@gmail.com,::kirill.shutemov@linux.intel.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1540:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3867:3868:3870:3871:3872:5007:6119:6120:6261:6653:7514:7875:7901:7903:8957:9413:10004:11026:11473:11658:11914:12043:12296:12297:12438:12517:12519:12555:12895:13069:13255:13311:13357:14096:14181:14384:14394:14687:14721:21080:21212:21444:21451:21627:21666:21990:30054,0,RBL:209.85.208.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: trees87_a9edb5adcf19 X-Filterd-Recvd-Size: 3562 Received: from mail-lj1-f195.google.com (mail-lj1-f195.google.com [209.85.208.195]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Thu, 9 Jan 2020 14:27:52 +0000 (UTC) Received: by mail-lj1-f195.google.com with SMTP id u1so7446550ljk.7 for ; Thu, 09 Jan 2020 06:27:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=wTaTGVbsUpcoXo1s1mBR+uimXJ4RdpYySad7mI4AIyI=; b=s7YXQOOSMRgcTX1S4Vn/5LSWq3F3JYLknR6iH1wq+c9QrqHSNXURmOeoe2jECXe7K/ pPKurpWAGEhi2DCErypwJrUxGcQeUqDxNqE1IFA9cwxunA30fjWbxq7ep0Cb7isliOiX rj6qf1BS3+L3LxludE1P9XvmbwiT2UEcIiqKzeUGuu00tHZkajW945ga1vWDavZx69Xh RWbB3qydHYTTyUwI3Fca3cm7hE7HQlkv/0nCJm5pVQgHkJ6WB834MzOlBY3vd1IHUitT HVdA08vMjQINIta0q4wGtdDbXKTP9sGfr2OaB52nIGlnerEBwhNKAVUA+SNcONjDkI0S Nx7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=wTaTGVbsUpcoXo1s1mBR+uimXJ4RdpYySad7mI4AIyI=; b=Ng9VA6I4g+C+addxwkLpxj3MYjo4ifcU9do+rY/oV1KqEI8XTg8pCOKYHXPmCLKMJi 8JEjy1MnUxTsLn6YJ06E7yB6w1mBtxoyOwhyHP5oj8B/h4MD2qtlhlmnhU+V7ozROFd8 Wvw/xk5a5SpbHHGzle+c4UBhBfPAXI9P1QCnrJ3UAmasxHYRdXGIFp7VOBthR9NJ+syX tZdazOt4LEiNIQlaT7B9GhUnfcEGfiGKyvisbKhu53/8YGM+1m7tuT1mnSrMg7J3/lvP EzwaQjJq5/H2poNDRF+GD7bN5SvHfDXswlE0dwMsI7JPDXaHQfdbBz5yvjTwYz9Gc9P0 GUpg== X-Gm-Message-State: APjAAAU4186eS3vlP0byo/kiskXKzgjYznQgYte2La5PLOX4GRlgP/U+ Nb6I/+sLKgwO/c5TbhTv3MrQg9jL X-Google-Smtp-Source: APXvYqz3OzzAv+pqUSFPZq0QeljQhmfRmEwDwb4Tc+4vKEaPqk8XjHx/niJnig+AjQDBhB5ob0LFmQ== X-Received: by 2002:a2e:7e11:: with SMTP id z17mr6799021ljc.117.1578580071116; Thu, 09 Jan 2020 06:27:51 -0800 (PST) Received: from localhost.localdomain.localdomain ([131.228.2.21]) by smtp.gmail.com with ESMTPSA id q17sm3110732ljg.23.2020.01.09.06.27.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Jan 2020 06:27:50 -0800 (PST) From: Li Xinhai To: linux-mm@kvack.org Cc: "Kirill A. Shutemov" Subject: [PATCH v2] mm/page_vma_mapped.c: Detect mismatched pfn of hugetlbfs page in pfn_in_hpage() Date: Thu, 9 Jan 2020 14:26:02 +0000 Message-Id: <1578579963-6075-1-git-send-email-lixinhai.lxh@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: check_pte is called for hugetlbfs page and comparing pfn in pfn_in_page, where pfn is compared in range [hpage_pfn, hpage_pfn+HPAGE_PMD_NR). For hugetlbfs page, pfn must equal to hpage_pfn, so catch it as bug if they are not equal. Signed-off-by: Li Xinhai Cc: Kirill A. Shutemov --- mm/page_vma_mapped.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index eff4b45..713aaed 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -55,6 +55,7 @@ static bool map_pte(struct page_vma_mapped_walk *pvmw) static inline bool pfn_in_hpage(struct page *hpage, unsigned long pfn) { unsigned long hpage_pfn = page_to_pfn(hpage); + VM_BUG_ON_PAGE(PageHuge(hpage) && pfn != hpage_pfn, hpage); /* THP can be referenced by any subpage */ return pfn >= hpage_pfn && pfn - hpage_pfn < hpage_nr_pages(hpage);