Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3218872pxu; Sun, 29 Nov 2020 19:32:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxXe8AvBS6L1Hvmqk4iwCzaVZ6XpiPVtm7MHHHhgS3k24cZnW+P8i4Dw3tsw7V/e+Qy8jPH X-Received: by 2002:a05:6402:b45:: with SMTP id bx5mr19765180edb.193.1606707163391; Sun, 29 Nov 2020 19:32:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606707163; cv=none; d=google.com; s=arc-20160816; b=rvU5AmqCtD+Npc9S1yHs25NStzM31qvjcscZWu20sPc9wIxIvgu/hZSUaM6smMbdDL q1ssk4JrvcGzDzHCeeTA0tY2UUCmEa4QjpDcqjwQpXjG0rRZShLkcd5Ri/KMqV4N1ZZo /9WySHlpzTb7KVCFQlW1eQifnbmYPspjXcgjSNX9dZ29zph4D/WysRC6I2sznn9RQwiK tyuCHFWoTFeHXRJgSuzqliUfwmMhpESC2zjWq18J2kK//l3fLZdzDBKdkL3+EscLh5L0 f7yNXAoBbjqgm1IKySY16KLOYTMzoS8E8jMOp9vWLSQQ9sckR/ATtzbZoKidTT6HAKz+ B8tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=choPB9Q5Sae6Dh6HO0FrIZkSJQcpr68xGg3UQ14bna4=; b=DoHh53E01lww4JcQ3+a61OECkaWtmw+8oWSjw9DneT6NDH1AVRVvg/TRcYquLBvBHM vEArIXoRWqle6VGKmj5DcnWOxS7Gt2mAaT0Xhwyn1UquGTY060GPQvG/cLwQPb5EpUNU J0EKU5KSMxD9a3zVp5hxbROqxT/gWyGZJaNi9AUJPeWSu4mlQBgMAtGvy2ymPymKVW0S LOvJXPHkdbT80PSm5FR6pyUsmNq5T9ITVsjY8sDgsCKasIlvYuSn71F8sdxK6LItIGhf 3E2BUPeoW7w+FkXcg3W/9zW1PvlfK+DmFhKV9342tpZ2S5oOVmLeyPSpuPG3Be2TQHOP m90g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si10359409edu.277.2020.11.29.19.32.21; Sun, 29 Nov 2020 19:32:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728525AbgK3Da6 (ORCPT + 99 others); Sun, 29 Nov 2020 22:30:58 -0500 Received: from foss.arm.com ([217.140.110.172]:48708 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728480AbgK3Da6 (ORCPT ); Sun, 29 Nov 2020 22:30:58 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2722512FC; Sun, 29 Nov 2020 19:30:12 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.84.86]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4EE083F23F; Sun, 29 Nov 2020 19:30:09 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org, akpm@linux-foundation.org, david@redhat.com Cc: linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Anshuman Khandual , Heiko Carstens , Vasily Gorbik Subject: [RFC V2 3/3] s390/mm: Define arch_get_mappable_range() Date: Mon, 30 Nov 2020 08:59:52 +0530 Message-Id: <1606706992-26656-4-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1606706992-26656-1-git-send-email-anshuman.khandual@arm.com> References: <1606706992-26656-1-git-send-email-anshuman.khandual@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This overrides arch_get_mappabble_range() on s390 platform and drops now redundant similar check in vmem_add_mapping(). This compensates by adding a new check __segment_load() to preserve the existing functionality. Cc: Heiko Carstens Cc: Vasily Gorbik Cc: David Hildenbrand Cc: linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/s390/mm/extmem.c | 5 +++++ arch/s390/mm/vmem.c | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c index 5060956b8e7d..cc055a78f7b6 100644 --- a/arch/s390/mm/extmem.c +++ b/arch/s390/mm/extmem.c @@ -337,6 +337,11 @@ __segment_load (char *name, int do_nonshared, unsigned long *addr, unsigned long goto out_free_resource; } + if (seg->end + 1 > VMEM_MAX_PHYS || seg->end + 1 < seg->start_addr) { + rc = -ERANGE; + goto out_resource; + } + rc = vmem_add_mapping(seg->start_addr, seg->end - seg->start_addr + 1); if (rc) goto out_resource; diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c index b239f2ba93b0..06dddcc0ce06 100644 --- a/arch/s390/mm/vmem.c +++ b/arch/s390/mm/vmem.c @@ -532,14 +532,19 @@ void vmem_remove_mapping(unsigned long start, unsigned long size) mutex_unlock(&vmem_mutex); } +struct range arch_get_mappable_range(void) +{ + struct range memhp_range; + + memhp_range.start = 0; + memhp_range.end = VMEM_MAX_PHYS; + return memhp_range; +} + int vmem_add_mapping(unsigned long start, unsigned long size) { int ret; - if (start + size > VMEM_MAX_PHYS || - start + size < start) - return -ERANGE; - mutex_lock(&vmem_mutex); ret = vmem_add_range(start, size); if (ret) -- 2.20.1