Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2567354yba; Mon, 6 May 2019 08:06:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvw5dqfM0yjbb8T0MqmOQIub3ovaoSChicWPCNGTdbucIueqnfL7oEIDp3iCfQ+ZliegXO X-Received: by 2002:a63:f712:: with SMTP id x18mr33200216pgh.293.1557155215357; Mon, 06 May 2019 08:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557155215; cv=none; d=google.com; s=arc-20160816; b=UAEFn5n/71vX8Du3NTdG0sXBzDicHIQp8rQvsWdy5RXPY5H8fQHEJ8hU/jFwUHArRR U+TeuaWutOl4r9xHLV/LT2CUYHQXfb9hyhznsuOroRZ3iyUowRmcMWnA0jkRDHVbLV9Q eBlLyd8Bj4BQpREMv3id6CHy9YIlhnMveb0Na7pwlLJjhcTCWs3V4HRLlSJIj8ZpwDmM cdXKxruHFOSxHYO5R0PDoEyQ+EicrqXsOiJICzuRMjRrLkW7cKcXX953ItEKn9Ly/B3K NtNxJJxr0ljyK4KSH9zM2TsTWqKHE2o9xf9KL3TS4ivuGad6anoWv6R+PzXmvkucP6zx c8Ww== 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=VJk9E50a3tu2PIimrxXtx2GGoel6EqK0VobR0hW+pvI=; b=NWLrGKpI2oGSC5hOR1VoQG6aj21vx6Jhs9t6xncrBeObgSmPrV+f5xnO/5G44zgBIj 8z56415Rp7bFRRKxKsvrlhAutmZ4pedas24czcdirRqtG/yRdizvY9A4Vzdp3jGYv6Mh egudR7f3uKeLOIAgszDWpHx89FmESA+TBjW+rJ2RBSEj+8023wpgGxMXbJchZC71LX00 /lsiWzEwoRVMWAhR86Xf0paKZrvD0ptsLlDKZ8gCCJeEKakPk3nZ21e+4lH7Pnk03cpT uxR3K2AsArrkh8WeqP+dz2pELfZfrdXsElySzLn4uSSyeecHFAE+zNynfzRJmceYy2YB qhrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CdUjSBWU; 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 90si15582086plf.299.2019.05.06.08.06.36; Mon, 06 May 2019 08:06:55 -0700 (PDT) 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=CdUjSBWU; 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 S1727078AbfEFOi2 (ORCPT + 99 others); Mon, 6 May 2019 10:38:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:59530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727601AbfEFOi1 (ORCPT ); Mon, 6 May 2019 10:38:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 03046206A3; Mon, 6 May 2019 14:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153506; bh=m3SyE3HDVUxz0/YHku9Vj8PnmGa/Efm5Uo1tFhUs7wg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CdUjSBWUJaWGkZ/qDkxcHOAXrpx21oQ5uf/VsuY1KjzSx8l89NWBNWc+UkEA3nzyj l0/esad5pLAaEgJneqj6yFU7FBbCNfJNnwoNYPTnOhHL+1zj5dNgJKt+dBTl2mcg+O Sl4+aayt3bQZTkzfJzdTp+db+fGkhLFEJanHgkqs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Laurent Dufour , "Aneesh Kumar K.V" , Michael Ellerman Subject: [PATCH 5.0 115/122] powerpc/mm/hash: Handle mmap_min_addr correctly in get_unmapped_area topdown search Date: Mon, 6 May 2019 16:32:53 +0200 Message-Id: <20190506143104.717707766@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143054.670334917@linuxfoundation.org> References: <20190506143054.670334917@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: Aneesh Kumar K.V commit 3b4d07d2674f6b4a9281031f99d1f7efd325b16d upstream. When doing top-down search the low_limit is not PAGE_SIZE but rather max(PAGE_SIZE, mmap_min_addr). This handle cases in which mmap_min_addr > PAGE_SIZE. Fixes: fba2369e6ceb ("mm: use vm_unmapped_area() on powerpc architecture") Reviewed-by: Laurent Dufour Signed-off-by: Aneesh Kumar K.V Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/mm/slice.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/arch/powerpc/mm/slice.c +++ b/arch/powerpc/mm/slice.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -377,6 +378,7 @@ static unsigned long slice_find_area_top int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT); unsigned long addr, found, prev; struct vm_unmapped_area_info info; + unsigned long min_addr = max(PAGE_SIZE, mmap_min_addr); info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; @@ -393,7 +395,7 @@ static unsigned long slice_find_area_top if (high_limit > DEFAULT_MAP_WINDOW) addr += mm->context.slb_addr_limit - DEFAULT_MAP_WINDOW; - while (addr > PAGE_SIZE) { + while (addr > min_addr) { info.high_limit = addr; if (!slice_scan_available(addr - 1, available, 0, &addr)) continue; @@ -405,8 +407,8 @@ static unsigned long slice_find_area_top * Check if we need to reduce the range, or if we can * extend it to cover the previous available slice. */ - if (addr < PAGE_SIZE) - addr = PAGE_SIZE; + if (addr < min_addr) + addr = min_addr; else if (slice_scan_available(addr - 1, available, 0, &prev)) { addr = prev; goto prev_slice; @@ -528,7 +530,7 @@ unsigned long slice_get_unmapped_area(un addr = _ALIGN_UP(addr, page_size); slice_dbg(" aligned addr=%lx\n", addr); /* Ignore hint if it's too large or overlaps a VMA */ - if (addr > high_limit - len || + if (addr > high_limit - len || addr < mmap_min_addr || !slice_area_is_free(mm, addr, len)) addr = 0; }