Message ID | 1670392853-28252-1-git-send-email-ssengar@linux.microsoft.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp8885wrr; Tue, 6 Dec 2022 22:14:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf47EIYdDxTL0qDM4YDVR6Oc5fmVsJg25co9W6FzEN/iVjPCoGPwo6GYnlaS61HqldnBhFfc X-Received: by 2002:a17:902:aa07:b0:186:a97d:6bcc with SMTP id be7-20020a170902aa0700b00186a97d6bccmr19260418plb.121.1670393676031; Tue, 06 Dec 2022 22:14:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670393676; cv=none; d=google.com; s=arc-20160816; b=PFULXEeGyaStPYfEvJZexHQO4/36fVXkQ1hRtb9ZIeH1XN+vAQsSwzJlzN8wVmVyDH ATv4/kZbJRqlNmvgb6w/YIT++P6SN2W1NqDMBPUYNUbVklAXxM0URq7P6EaQTEYiebeJ 5/AVV8wGUs78bewW+2FTLqB/HhWcs4azfDOFJdyEUNVyv3bCbtIt4atLX5iZEOlGW+p9 l4LeaanXsUbgh6mabSBM/8cX9fTRNWyD64yMKCS3hT+zyl+fcrZ5M6yDUlY+xcbqd/X5 8z/9EQNHc/WNj1LXBu2ekHgW4p5ELkPBKobzHShE1aQLwarxHmuGdpvqfnE89mfrSmUT F6pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from:dkim-signature :dkim-filter; bh=k8jVNADG7Oh2jsOUifOR+G61iy9ityYsT6Hp6c/5wPU=; b=lxSo/yWeOpblbttR/zfWTQ5IayWrdMAhXq46JRlPpV0sOlNYCZCh/x/S2WkHHu9uFt rSIf6yj68iiTswbhtSTRFq64Vy5r1zZllOe6d0joXd7LqBGyw2lhaXME9XZbP+kNb23t akiXWBhOo3cna4FJ+dE/fnmgBn5e+iSxbJD1oLTmGQJ3ao4UyB/IwFQ59l6l+0CkH2Er I8oEwA9HKA4kfCurpYq6066PXHoPQSpdYYfRGgnAy33NAxrf/v+QgEiSM+I4LY6Uo/Za NiQKpJ4Df/BsZtYk/3W9NlWqBZ1uYH3xEuuvfHMH4UmIyaRvfsQJs0OIzmcK+3FYgdEE Fabw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=nkQQDTss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r10-20020a63d90a000000b004787004c8dasi17882055pgg.123.2022.12.06.22.14.18; Tue, 06 Dec 2022 22:14:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=nkQQDTss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229680AbiLGGBO (ORCPT <rfc822;b08248@gmail.com> + 99 others); Wed, 7 Dec 2022 01:01:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbiLGGBF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 7 Dec 2022 01:01:05 -0500 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 647D858BCF for <linux-kernel@vger.kernel.org>; Tue, 6 Dec 2022 22:00:59 -0800 (PST) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 1FA4920B83CB; Tue, 6 Dec 2022 22:00:59 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1FA4920B83CB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1670392859; bh=k8jVNADG7Oh2jsOUifOR+G61iy9ityYsT6Hp6c/5wPU=; h=From:To:Subject:Date:From; b=nkQQDTssSXUvelqnG5aFSVw+pJekwS7MLXWYJxyaT0u8TzGB9UEru80O5TFiwB1CV jhW/e02xbSEITDGUo5N0JJJ1Fy93ApzvPui1ZtfOwfZaEtphBVtlQ2vl0GxOr4Knzj qqJv6+iOe/Yx9RGowI7qn45UitbxyKKjk/p+aJQ0= From: Saurabh Sengar <ssengar@linux.microsoft.com> To: ssengar@microsoft.com, akpm@linux-foundation.org, yuzhao@google.com, jack@suse.cz, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jostarks@microsoft.com Subject: [PATCH v2] mm/gup: fix gup_pud_range() for dax Date: Tue, 6 Dec 2022 22:00:53 -0800 Message-Id: <1670392853-28252-1-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747232360343863953?= X-GMAIL-MSGID: =?utf-8?q?1751534719495882052?= |
Series |
[v2] mm/gup: fix gup_pud_range() for dax
|
|
Commit Message
Saurabh Singh Sengar
Dec. 7, 2022, 6 a.m. UTC
From: John Starks <jostarks@microsoft.com> For dax pud, pud_huge() returns true on x86. So the function works as long as hugetlb is configured. However, dax doesn't depend on hugetlb. Commit 414fd080d125 ("mm/gup: fix gup_pmd_range() for dax") fixed devmap-backed huge PMDs, but missed devmap-backed huge PUDs. Fix this as well. This fixes the below kernel panic: general protection fault, probably for non-canonical address 0x69e7c000cc478: 0000 [#1] SMP < snip > Call Trace: <TASK> get_user_pages_fast+0x1f/0x40 iov_iter_get_pages+0xc6/0x3b0 ? mempool_alloc+0x5d/0x170 bio_iov_iter_get_pages+0x82/0x4e0 ? bvec_alloc+0x91/0xc0 ? bio_alloc_bioset+0x19a/0x2a0 blkdev_direct_IO+0x282/0x480 ? __io_complete_rw_common+0xc0/0xc0 ? filemap_range_has_page+0x82/0xc0 generic_file_direct_write+0x9d/0x1a0 ? inode_update_time+0x24/0x30 __generic_file_write_iter+0xbd/0x1e0 blkdev_write_iter+0xb4/0x150 ? io_import_iovec+0x8d/0x340 io_write+0xf9/0x300 io_issue_sqe+0x3c3/0x1d30 ? sysvec_reschedule_ipi+0x6c/0x80 __io_queue_sqe+0x33/0x240 ? fget+0x76/0xa0 io_submit_sqes+0xe6a/0x18d0 ? __fget_light+0xd1/0x100 __x64_sys_io_uring_enter+0x199/0x880 ? __context_tracking_enter+0x1f/0x70 ? irqentry_exit_to_user_mode+0x24/0x30 ? irqentry_exit+0x1d/0x30 ? __context_tracking_exit+0xe/0x70 do_syscall_64+0x3b/0x90 entry_SYSCALL_64_after_hwframe+0x61/0xcb RIP: 0033:0x7fc97c11a7be < snip > </TASK> ---[ end trace 48b2e0e67debcaeb ]--- RIP: 0010:internal_get_user_pages_fast+0x340/0x990 < snip > Kernel panic - not syncing: Fatal exception Kernel Offset: disabled Fixes: 414fd080d125 ("mm/gup: fix gup_pmd_range() for dax") Signed-off-by: John Starks <jostarks@microsoft.com> Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com> --- mm/gup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, 6 Dec 2022 22:00:53 -0800 Saurabh Sengar <ssengar@linux.microsoft.com> wrote: > From: John Starks <jostarks@microsoft.com> > > For dax pud, pud_huge() returns true on x86. So the function works as long > as hugetlb is configured. However, dax doesn't depend on hugetlb. > Commit 414fd080d125 ("mm/gup: fix gup_pmd_range() for dax") fixed > devmap-backed huge PMDs, but missed devmap-backed huge PUDs. Fix this as > well. > > This fixes the below kernel panic: > > ... > > Fixes: 414fd080d125 ("mm/gup: fix gup_pmd_range() for dax") Feb 2019. > Signed-off-by: John Starks <jostarks@microsoft.com> > Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com> > --- > mm/gup.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/gup.c b/mm/gup.c > index c2c2c6d..e776540 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -2765,7 +2765,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo > next = pud_addr_end(addr, end); > if (unlikely(!pud_present(pud))) > return 0; > - if (unlikely(pud_huge(pud))) { > + if (unlikely(pud_huge(pud) || pud_devmap(pud))) { > if (!gup_huge_pud(pud, pudp, addr, next, flags, > pages, nr)) > return 0; I assume this should be backported into -stable kernels?
On Wed, Dec 07, 2022 at 01:31:30PM -0800, Andrew Morton wrote: > On Tue, 6 Dec 2022 22:00:53 -0800 Saurabh Sengar <ssengar@linux.microsoft.com> wrote: > > > From: John Starks <jostarks@microsoft.com> > > > > For dax pud, pud_huge() returns true on x86. So the function works as long > > as hugetlb is configured. However, dax doesn't depend on hugetlb. > > Commit 414fd080d125 ("mm/gup: fix gup_pmd_range() for dax") fixed > > devmap-backed huge PMDs, but missed devmap-backed huge PUDs. Fix this as > > well. > > > > This fixes the below kernel panic: > > > > ... > > > > Fixes: 414fd080d125 ("mm/gup: fix gup_pmd_range() for dax") > > Feb 2019. > > > Signed-off-by: John Starks <jostarks@microsoft.com> > > Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com> > > --- > > mm/gup.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/gup.c b/mm/gup.c > > index c2c2c6d..e776540 100644 > > --- a/mm/gup.c > > +++ b/mm/gup.c > > @@ -2765,7 +2765,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo > > next = pud_addr_end(addr, end); > > if (unlikely(!pud_present(pud))) > > return 0; > > - if (unlikely(pud_huge(pud))) { > > + if (unlikely(pud_huge(pud) || pud_devmap(pud))) { > > if (!gup_huge_pud(pud, pudp, addr, next, flags, > > pages, nr)) > > return 0; > > I assume this should be backported into -stable kernels? That would be helpful, thanks.
diff --git a/mm/gup.c b/mm/gup.c index c2c2c6d..e776540 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2765,7 +2765,7 @@ static int gup_pud_range(p4d_t *p4dp, p4d_t p4d, unsigned long addr, unsigned lo next = pud_addr_end(addr, end); if (unlikely(!pud_present(pud))) return 0; - if (unlikely(pud_huge(pud))) { + if (unlikely(pud_huge(pud) || pud_devmap(pud))) { if (!gup_huge_pud(pud, pudp, addr, next, flags, pages, nr)) return 0;