Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2898501pxu; Mon, 7 Dec 2020 20:23:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0KSWiVbKxWZ2lQmJZL97HDKTVt/DtyJeCDNEAcBE5HNUZqbBXDLd07oLpykrD9rifxKXj X-Received: by 2002:a17:906:7784:: with SMTP id s4mr4077844ejm.93.1607401398475; Mon, 07 Dec 2020 20:23:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607401398; cv=none; d=google.com; s=arc-20160816; b=MDtvv7a4GUtrzvEWNYvR3X5qhbUcsZT4zqoatF8GgWaLtAMqouCTe5EH3C1024oB/k NPKXMisEfdDed/godNZvlasPiaXDozzaW6yb/f6MXjiDMWtTICY8iwplDGhszVcEe6LY rYxeFckrXLD/XFREZ6RSSuac0HmQhBxZIvkMtXU0PMAemhk6Pg5VsR7iHTLtdajLGoPW z4DGnJ7nn9RjYhdTLaR/IcT3IfPjHbPJ8/t2o33v8jFDw37gg2gCRAa6AlhT8CUwY/oD 5fyLpCQG+SVCeP9ETLKkr+Qy3jJuz2roDkmTfR1azTiKAFqmTlCrnjJv8XLpfOCO9zDb DJLw== 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=OvQA1MFa8bv57f3NWBsaVMBvWWtYdZBHOFgenn6sp24=; b=INY7Hh0er2EE6SBP9cnfg5jQlUUcOHOCXk0LZDK7Be4qJ9HQFrTGFg4OilMzKxSVCh krNog1vUGFGNr8/MpwOOdpwvjhUyPokARmOYgdtfZgN2lGam2/S/2KwML8iyAu9UPQZ1 2aD0i5mDfqquYLwvVRMTyRo8SLhS/Yh30Ew6R4+IZhzTuxQA+9a6QSoeRET26FMbpVoG 701V6IHnEE03IsWgxJrSeVxJhY4hvPHRHBZ6zvr+QE0aZd8lqmbNKxPVo/rSyzFI3eF4 Cbfy4JUP4uGtLU/jrXTW8BkzDFmYTDjXitl3XWgqSioQNxV4I1KJsi1p/Wlr4wfFqoBt M7Xw== 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 ck15si9227646edb.37.2020.12.07.20.22.55; Mon, 07 Dec 2020 20:23:18 -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 S1726730AbgLHESB (ORCPT + 99 others); Mon, 7 Dec 2020 23:18:01 -0500 Received: from foss.arm.com ([217.140.110.172]:40648 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726584AbgLHESB (ORCPT ); Mon, 7 Dec 2020 23:18:01 -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 5BDA111FB; Mon, 7 Dec 2020 20:17:15 -0800 (PST) Received: from p8cg001049571a15.arm.com (unknown [10.163.87.7]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DC8423F718; Mon, 7 Dec 2020 20:17:10 -0800 (PST) From: Anshuman Khandual To: linux-mm@kvack.org, akpm@linux-foundation.org, david@redhat.com, hca@linux.ibm.com, catalin.marinas@arm.com Cc: linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Anshuman Khandual , Vasily Gorbik , Will Deacon , Ard Biesheuvel , Mark Rutland Subject: [PATCH 3/3] s390/mm: Define arch_get_mappable_range() Date: Tue, 8 Dec 2020 09:46:18 +0530 Message-Id: <1607400978-31595-4-git-send-email-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607400978-31595-1-git-send-email-anshuman.khandual@arm.com> References: <1607400978-31595-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 which will be used with recently added generic framework. It drops a redundant similar check in vmem_add_mapping() while compensating __segment_load() with a new address range check to preserve the existing functionality. It also adds a VM_BUG_ON() check that would ensure that memhp_range_allowed() has already been called on the hotplug path. 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/init.c | 10 ++++++++++ arch/s390/mm/vmem.c | 4 ---- 3 files changed, 15 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/init.c b/arch/s390/mm/init.c index 77767850d0d0..64937baabf93 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -278,6 +278,15 @@ device_initcall(s390_cma_mem_init); #endif /* CONFIG_CMA */ +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 arch_add_memory(int nid, u64 start, u64 size, struct mhp_params *params) { @@ -291,6 +300,7 @@ int arch_add_memory(int nid, u64 start, u64 size, if (WARN_ON_ONCE(params->pgprot.pgprot != PAGE_KERNEL.pgprot)) return -EINVAL; + VM_BUG_ON(!memhp_range_allowed(start, size, 1)); rc = vmem_add_mapping(start, size); if (rc) return rc; diff --git a/arch/s390/mm/vmem.c b/arch/s390/mm/vmem.c index b239f2ba93b0..749eab43aa93 100644 --- a/arch/s390/mm/vmem.c +++ b/arch/s390/mm/vmem.c @@ -536,10 +536,6 @@ 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