Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DC02C433B4 for ; Wed, 21 Apr 2021 19:05:07 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0AC2B61454 for ; Wed, 21 Apr 2021 19:05:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0AC2B61454 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=kM8tiJmlIeBg2Z735E+GmxxOvThJHiyqDRzEBGuPJCU=; b=paGp8IasHVT390N3m+xitsvLf zV0chqSDUKlfMVnTcvQcuHmMaBHCiKSO5eObw3+ubimXM6bWck9EVGowZX1EjnLOAnDq2pXe48/eC aYVhty6sRqMy/4ZcNgSn6lEEsIvN0MZMowIPT0yoIUzuqdqmGUVBNuSBJQJ9L4fXBP8g8C9pY415v e5cv+vcOQEGj404py0NsboIlGE5RZ4eWx90rWGOoDupanhyRlAJT+9iNdqlHFSUoRr6sHhvP0cZIf Eg1uR8i7MCzUiOw6CskjCmm3ZablZg8YRwgMeJ4tH9pjKMVxMU+an/m7m3nLeG73u6lwmBaCrUeyy nyHiCY3AA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lZI7U-00EzK8-Hw; Wed, 21 Apr 2021 19:02:40 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZI7P-00EzJO-Q6 for linux-arm-kernel@desiato.infradead.org; Wed, 21 Apr 2021 19:02:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=iw+V37JgA+F4SsYKf28zN0ap1ybGadX/nBD4+2JYyZo=; b=NUQXt0XyoUiGKsorSrr2GexK/z cV7O9Y532Sy0V3BjAuZB2c0kRh6viLRBYRx2PBBhSCwDI7eYqYlh1/2IhncWIoqURIt/gh6a/r5uL yPtoS1qjL2XTRWbeez53uNaLeQTR0Z1P2zFJEL9RibonUU8lTu7zvumxPZDD3Qhichm+Y6+qVrsQa Qb1zVbS7R3L9tuzJUvvpeQIN3j+nMpp81qq9nyMxeg0yvmPc/forT+t2vvC41lQREACNS/VyOKFZD iV08hrxIhp0HFrsnPHu3XTU9hsDJ+9hchPaxVWrWJ/VV69+xJJovf2RlZv4Dq7toKK7CZldnfRJTo kY0jMplg==; Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lZI7M-00D7SV-QA for linux-arm-kernel@lists.infradead.org; Wed, 21 Apr 2021 19:02:34 +0000 Received: by mail-wr1-x435.google.com with SMTP id p6so35724313wrn.9 for ; Wed, 21 Apr 2021 12:02:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iw+V37JgA+F4SsYKf28zN0ap1ybGadX/nBD4+2JYyZo=; b=guldes+6D+2OIyMZHMiQgSYVlACoVxMnDeIe36d1XG8gtmy3AqlXBOq9wip856rFLX ooSoR8OZAAsrEHXfMdk9yaK/i5TjyZc13WzIomFI0TjZC0mFCk9TeX5iDQNaQ+iu0Pdk lARhuVuk7wB0SLoTA8OqoPcsmA2621Z0Suileq8hJRs56D1pQY5UPKyLOFm0fCTkYIPQ s/yQlDPsYE010T6PR9eb2Z13/Xs18kUX0jAbOKEBVNNoDtjGFwbEeVo/btDCiZJWdQmq Cm+xg+nIrdQXatfQmW5WdLovF8oLALxcZLxg1O6KcmrcKjjdyCPsQc5an+PboUs7WIwI 9eTA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=iw+V37JgA+F4SsYKf28zN0ap1ybGadX/nBD4+2JYyZo=; b=rwhobeZsaAJ9mX8+P28KABk4LJzK51h84Cz54K201qpmcx8xXhM47F3WOfYQ/GNvTn dMojImiGIuuloGISDEVx7EDvVf7ImWqJb5SmjvQxhX8vrwJVYaKH/wroX0WB+y+dXwCy AXGPpeRP9NM2ZYldV4PntwOTzGjWPdXEf5LUVd0M/MgczNJH7IRVCJN/rNeCMU/vYetG rIcrH11yrUOfRkZ3DknzxiS+puoHY0adFmpkhpou483isWEqxfwN/VBynf5p7jsijlLw pXF2GVHfMBT7khShd20ImmNx+WkoWVAoxAUWbNEAb5cc8cbzwdgGv/4LR7zEjnZIKPAV iDIA== X-Gm-Message-State: AOAM5308KgefbkSBmmtKfSW+jHty4TfCaDVXfgGklduTLLYipM2jJDtD EqNvBG2N4FAqqDd1nnTh52gzuUTMHtXoqHnZ X-Google-Smtp-Source: ABdhPJyQyITpLJfXtUF2jqQHc58do6wIz+g5syIL2dP39W4mfyyknSnfEbXxSX0k8bsBuIZUitFpxQ== X-Received: by 2002:a05:6000:118c:: with SMTP id g12mr29000676wrx.241.1619031749872; Wed, 21 Apr 2021 12:02:29 -0700 (PDT) Received: from amanieu-desktop.home ([2a00:23c6:f081:f801:93ef:94e:9f8:1f0]) by smtp.gmail.com with ESMTPSA id d10sm310829wri.41.2021.04.21.12.02.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 12:02:29 -0700 (PDT) From: Amanieu d'Antras To: linux-arm-kernel@lists.infradead.org Cc: Amanieu d'Antras , Ryan Houdek , Catalin Marinas , Will Deacon , Mark Rutland , Steven Price , Arnd Bergmann , David Laight , Mark Brown Subject: [RFC PATCH v3 1/8] mm: Add arch_get_mmap_base_topdown macro Date: Wed, 21 Apr 2021 20:02:00 +0100 Message-Id: <20210421190207.1803139-2-amanieu@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210421190207.1803139-1-amanieu@gmail.com> References: <20210421190207.1803139-1-amanieu@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210421_120232_915096_21413AE8 X-CRM114-Status: GOOD ( 14.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This allows architectures to customize the mmap base to use depending on the direction of allocation. The base argument is also removed from arch_get_mmap_base[_topdown] in prepartion for future changes. arm64 is currently the only user of the arch_get_mmap_* macros and is adjusted accordingly. Specifically it only needs to limit the upper bound of VM allocations and therefore only needs to customize arch_get_mmap_base_topdown but not arch_get_mmap_base. Signed-off-by: Amanieu d'Antras Co-developed-by: Ryan Houdek Signed-off-by: Ryan Houdek --- arch/arm64/include/asm/processor.h | 7 ++++--- mm/mmap.c | 14 +++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index efc10e9041a0..f47528aae321 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -88,9 +88,10 @@ #define arch_get_mmap_end(addr) ((addr > DEFAULT_MAP_WINDOW) ? TASK_SIZE :\ DEFAULT_MAP_WINDOW) -#define arch_get_mmap_base(addr, base) ((addr > DEFAULT_MAP_WINDOW) ? \ - base + TASK_SIZE - DEFAULT_MAP_WINDOW :\ - base) +#define arch_get_mmap_base_topdown(addr) \ + ((addr > DEFAULT_MAP_WINDOW) ? \ + current->mm->mmap_base + TASK_SIZE - DEFAULT_MAP_WINDOW :\ + current->mm->mmap_base) #endif /* CONFIG_ARM64_FORCE_52BIT */ extern phys_addr_t arm64_dma_phys_limit; diff --git a/mm/mmap.c b/mm/mmap.c index 3f287599a7a3..4937b34085cb 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2139,11 +2139,15 @@ unsigned long vm_unmapped_area(struct vm_unmapped_area_info *info) } #ifndef arch_get_mmap_end -#define arch_get_mmap_end(addr) (TASK_SIZE) +#define arch_get_mmap_end(addr) (TASK_SIZE) #endif #ifndef arch_get_mmap_base -#define arch_get_mmap_base(addr, base) (base) +#define arch_get_mmap_base(addr) (current->mm->mmap_base) +#endif + +#ifndef arch_get_mmap_base_topdown +#define arch_get_mmap_base_topdown(addr) (current->mm->mmap_base) #endif /* Get an address range which is currently unmapped. @@ -2184,7 +2188,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr, info.flags = 0; info.length = len; - info.low_limit = mm->mmap_base; + info.low_limit = arch_get_mmap_base(addr); info.high_limit = mmap_end; info.align_mask = 0; info.align_offset = 0; @@ -2227,7 +2231,7 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, info.flags = VM_UNMAPPED_AREA_TOPDOWN; info.length = len; info.low_limit = max(PAGE_SIZE, mmap_min_addr); - info.high_limit = arch_get_mmap_base(addr, mm->mmap_base); + info.high_limit = arch_get_mmap_base_topdown(addr); info.align_mask = 0; info.align_offset = 0; addr = vm_unmapped_area(&info); @@ -2241,7 +2245,7 @@ arch_get_unmapped_area_topdown(struct file *filp, unsigned long addr, if (offset_in_page(addr)) { VM_BUG_ON(addr != -ENOMEM); info.flags = 0; - info.low_limit = TASK_UNMAPPED_BASE; + info.low_limit = arch_get_mmap_base(addr); info.high_limit = mmap_end; addr = vm_unmapped_area(&info); } -- 2.31.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel