Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3697713ybv; Mon, 10 Feb 2020 04:55:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyKkMU2EAZgzXYHaDAeI+hcObWB3wTAASrtFO/qmqHa6iksw07cGKhi+TjaUN5L96+NWFNH X-Received: by 2002:a9d:6b03:: with SMTP id g3mr949941otp.200.1581339327764; Mon, 10 Feb 2020 04:55:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339327; cv=none; d=google.com; s=arc-20160816; b=Th0yvqstG7u+pxkGrLMrS6/U7egvS3i9Bp0qojQHKViYE+vtxe/y3Sus5t6qukD3h8 W7BvTbCPvpqxm1+FSU8ZiYa4yu7khjE9GnqgBIegj86cc4joBoGeYkwITLwXD8Sl56qn 1U/YQYLR+nMjSx4LNeEUWbXavP7UAtNsD75r7KcFoZYqRtqb0b45lUU9qBUR6bngPVLN gl/CAUal6GFkUcTqx0gBgcdBOAPp/l3qNoYcob4lS88EBFaT2KKOq/UBOx4YNb4dUYPF 0btqbSRe0YO+4YsVfn9z/ijIf6mMMJvE0as4LiUpKrIkGCE/TCJ5eSqGakTLF6c/TSHy hV9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=quq7S4Pfe9ds92mCoUI1l8gzs15/XwdLsMQnfZa5sfk=; b=ddE75gyeMQBYn+3G92wLn1MDwLd6s3dfJuZGHpRqomQORYGHk81j596Pn2A1iSzRY+ uUqKy8IBSL9fIXPf98f2dRZyzai2Oxg2yFq4GTu2VTpke3ePcYs/usIUuxRbaXDldDhb eJ5dzTgPwXdck5v7ebvgJmdUfBS9qfPkQzV7G9sijugaxbHfWh+lMvksUFf82CJX4oaP k0KgJbBH78BdLuP9MdHsI6KsSuk+CswSxOPNNcfBLr0uMvLVFyDIByBVsRSaoBHgMx4l csGsL3yI3eHxuNvf+RrdMbCeMq+aFZLz4LmcIIv/XNA4C7icbzEjXS6rzUWrZO+eR8ko 5lOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DP8H5OmE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si172873otk.29.2020.02.10.04.55.14; Mon, 10 Feb 2020 04:55:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DP8H5OmE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729405AbgBJMyP (ORCPT + 99 others); Mon, 10 Feb 2020 07:54:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:45582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730132AbgBJMmD (ORCPT ); Mon, 10 Feb 2020 07:42:03 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CCE3021569; Mon, 10 Feb 2020 12:42:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338521; bh=Yen33XZj5jzRF7T5ghNTODxCPnPv6ubE0UKa8No/Edc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DP8H5OmEDgnBYs3LaIMZwWLhBZcMTfCwuKcgTD/ilOjP5ajVadlsnctUBK0MPr2wN SAq0amdR1HQXgfIdnMs7AMXChp9KUlNJ6bJYy8HNBNzqRt2YJ/16BdVekM6gfMwJPc rSAYNSeMuw007b3dehxm6F/L779+x8goqTeBCjwc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yishai Hadas , Artemy Kovalyov , Leon Romanovsky , Jason Gunthorpe Subject: [PATCH 5.5 296/367] IB/core: Fix ODP with IB_ACCESS_HUGETLB handling Date: Mon, 10 Feb 2020 04:33:29 -0800 Message-Id: <20200210122451.006693701@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yishai Hadas commit 9ff1b6466a291a33389c4a9c7f3f9b64d62df40a upstream. As VMAs for a given range might not be available as part of the registration phase in ODP. ib_init_umem_odp() considered the expected page shift value that was previously set and initializes its internals accordingly. If memory isn't backed by physical contiguous pages aligned to a hugepage boundary an error will be set as part of the page fault flow and come back to the user as some failed RDMA operation. Fixes: 0008b84ea9af ("IB/umem: Add support to huge ODP") Link: https://lore.kernel.org/r/20191222124649.52300-4-leon@kernel.org Signed-off-by: Yishai Hadas Reviewed-by: Artemy Kovalyov Signed-off-by: Leon Romanovsky Reviewed-by: Jason Gunthorpe Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/umem_odp.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) --- a/drivers/infiniband/core/umem_odp.c +++ b/drivers/infiniband/core/umem_odp.c @@ -241,22 +241,10 @@ struct ib_umem_odp *ib_umem_odp_get(stru umem_odp->umem.owning_mm = mm = current->mm; umem_odp->notifier.ops = ops; - umem_odp->page_shift = PAGE_SHIFT; - if (access & IB_ACCESS_HUGETLB) { - struct vm_area_struct *vma; - struct hstate *h; - - down_read(&mm->mmap_sem); - vma = find_vma(mm, ib_umem_start(umem_odp)); - if (!vma || !is_vm_hugetlb_page(vma)) { - up_read(&mm->mmap_sem); - ret = -EINVAL; - goto err_free; - } - h = hstate_vma(vma); - umem_odp->page_shift = huge_page_shift(h); - up_read(&mm->mmap_sem); - } + if (access & IB_ACCESS_HUGETLB) + umem_odp->page_shift = HPAGE_SHIFT; + else + umem_odp->page_shift = PAGE_SHIFT; umem_odp->tgid = get_task_pid(current->group_leader, PIDTYPE_PID); ret = ib_init_umem_odp(umem_odp, ops); @@ -266,7 +254,6 @@ struct ib_umem_odp *ib_umem_odp_get(stru err_put_pid: put_pid(umem_odp->tgid); -err_free: kfree(umem_odp); return ERR_PTR(ret); }