From mboxrd@z Thu Jan 1 00:00:00 1970 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,USER_AGENT_GIT autolearn=unavailable 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 07C4CC433ED for ; Tue, 18 May 2021 09:10:14 +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 8A28061285 for ; Tue, 18 May 2021 09:10:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A28061285 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=poLiCgsoA/Ga37rY23A0EBO7V q1zvkn4vUvWkzi/6XEqcFS2P/JsQiZx94Z+M+A3KLPlc84ssXdm0aWCFGMb4aWvIcYg7pFh7ch5ja oWAV75CCZ6b+AB9qb4+GZWOv3vocYROImPUDNZBFZ4qMDi92pAfXswhrvX/JwSp+fItmuzoMVpgWW /XnhbUIVzlCT+Nza1mt5Xg0d8+kiy6URWAGNvZkfGdZXNcH+/eXKX9H10cdjQzJmQJVUnfJZtwDgI 49Zf6E/fyRAQ88hnMzCGHEESs6dTLpbWDFYADpZhWRSAoqa//GLc5a5+CH9XLw6tsroAnv04mQoFS kZsFlqqVQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1livhS-0002hz-Nt; Tue, 18 May 2021 09:07:39 +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 1livh4-0002Zt-5X for linux-arm-kernel@desiato.infradead.org; Tue, 18 May 2021 09:07:14 +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=lajUkczQZI8aL5FCB+EcL4Mapu p9/u1xZQp25GT1aZIBl2H1mgCA32qysUZhyvRp6kwn5cBt/p/3H2B/onwnofKv1/GyoOGKABhVkBT PvFWIQXdKdtBv7x6awWMQkOf0Rpk/IZdbPx9sHF4Og3Rn6/cW196zoUDCkXln22z9t08Z44N+5WUh npqCCr+TAI69jEebou+JI0XbZ1H09XCjlomiJY9Yz6GvnwX7wJ+x1E4KVuqSlEP6qW2grYeIr/ORf 0MAANfc6X8ZDpIYJsOcdlGDlyx5a+SQ2R3sKOZYvRZ9ePYolm67F3e+r8KTMMXsgVspXLdopbsVNe 0Qlbutxg==; Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1livgz-00EUUX-R1 for linux-arm-kernel@lists.infradead.org; Tue, 18 May 2021 09:07:12 +0000 Received: by mail-wr1-x42f.google.com with SMTP id x8so9316590wrq.9 for ; Tue, 18 May 2021 02:07:09 -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=iTek3TJr/YFjmB4UfL1edPWpPsdj7IE8wcUP7qFv4mY9W3+0rrXVj2i4BAbIXp9MVz no224x94Qw8CWQxPyZxYsXrig3Ka0SnZJqSGshyuj/4FgA1tLLF49wvcdMZkZInVfKim kPApG10/E6NQjNu7KZulPTP6HZOhR3Nq+NfnJ2Epz9pF1sjPRchcUvbHOJLTrHN6XNkX fdbZVSSI/voKrJh+zBoYx/bMePq7Nwqvu/kkdg66zafR0egMiyT35X20TwM6lTMwcopz v2Lztg0+gawG427Kq/kUAtTBdOhLNGjOn3pabRp2oL/yiqJazMn7icnxAed9oE4cI5oB VCjQ== 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=S3natEwzEOQFkOn9m5ZQSIcyg5V4N4YN2/cIe06SWTl+qpx0q+XKWB8vSgHEGuCmzn BG8VsNVLhY/8GgroLsXYN4pXyseLQ/iCIWA53Fc0Qn1C3SAUixrEB8uiDnIxPTEMbn2Y 8cezR/sCWg4PAxcUechyL4kIaNTdKCIIp3RPih3bHEsTMKuu6aXO0vZVZtloK2F0Yu9o 6yoGkNYmY3SkwjOn2EXcUnJSxKD3voxupltARSOi0JDUy9A7OGmvuH0ccrWHM/QX+qci 9ycU3CA1tCEKidguA3SFhbFylN7EWLB9Wi56JK4cEk6vHVo5qBYLLjAQcaOnC3PqYuwD RTXg== X-Gm-Message-State: AOAM530lc8pKei91LA/ff8m96aj01srjF1F4TrzdUgXlibF7eXaJREIN 7xdaB1PLhIE1aaGYppY1B0c= X-Google-Smtp-Source: ABdhPJwqlJzu9U/zTbd6UMrv4emOFKb20RwGvFolAezPWYNdsqqHpRvkUnjCsF+jPcrBgjwttyw0VQ== X-Received: by 2002:a5d:4a81:: with SMTP id o1mr5284414wrq.177.1621328827965; Tue, 18 May 2021 02:07:07 -0700 (PDT) Received: from amanieu-laptop.home ([2a00:23c6:f081:f801:91cf:b949:c46c:f5a9]) by smtp.gmail.com with ESMTPSA id z17sm7520306wrt.81.2021.05.18.02.07.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 02:07:07 -0700 (PDT) From: Amanieu d'Antras To: Cc: Amanieu d'Antras , Ryan Houdek , Catalin Marinas , Will Deacon , Mark Rutland , Steven Price , Arnd Bergmann , David Laight , Mark Brown , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH v4 1/8] mm: Add arch_get_mmap_base_topdown macro Date: Tue, 18 May 2021 10:06:51 +0100 Message-Id: <20210518090658.9519-2-amanieu@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210518090658.9519-1-amanieu@gmail.com> References: <20210518090658.9519-1-amanieu@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210518_020709_901664_4DA576DA X-CRM114-Status: GOOD ( 14.99 ) 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