From patchwork Mon Mar 29 07:59:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 410823 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3436432jai; Mon, 29 Mar 2021 01:42:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEo6+E1GQoVZKZQ12mZ9Qy4kGPwj69/0wSGoA48Kt3QgoraXjM71Otd7psZGzo8GlqRgiw X-Received: by 2002:a17:907:98f5:: with SMTP id ke21mr27583612ejc.552.1617007233393; Mon, 29 Mar 2021 01:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007233; cv=none; d=google.com; s=arc-20160816; b=RwCpuPbMnrPnY7VBIDwhcteGPQIAtKJPgOJu5qIwIofbzx8NBGP+KxUVPRqv8dk1vD nUQ5h5fRBotGhA/bgyisyVzhPXZ+Kyten+94V3wwS2WJR0uhXjTqJoWzTEN6Ac0zRPkB sSgdHISMFpgLNSYVECI95pUSZLnG26X7bDujhl7F7OYGQrjdF70QqZWXCBRwF+2vprSP YRzV2HgGa/uebMKQzs/9nHrrFFjE4MU1EB0DKOrxiDh1H5KR2DtcFVBTWhB3Rl/HNJ9R 45jtXatvjZ4nQyGTGBcaJEzc85irPS0EWft4kkIcd2cnVZcHjLdeCCj4Wf1lWK0Jw1Ug CWPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PLhc6GrmA/TXE29BUHLyIpiYc9NFpOp1J6vU3c+QaYE=; b=oRiy9T5Hj7mTzbGLpRjwacy0TmTjuh2JUBPRR7aie+vJvLxvA/uRp4Z/6b1v74gQiS DbYTpDyvnzMHSN4a3vyePWU/1O1c5Xir/rIMTwkamWGkKxShqe3oMjICCkWERu2klUdt q6z2N4MX5P6heuq3nr8q+AP8/vS0rq8uCt+1qjDclJUi+5l8qq0+5sSo975lv7zahQ2i 5DQ4hYL4orE0T49aeB/Jpatt3o1/rEfNot99Fpb5bNyQk0IhJVatdqCdw/SHr5f62mfr OUU+SgEnrD51yOPo8FVjTYYGk6UPOz38SYuaaq875Q0bulZ8fwsU6imXpGvKITBdCX6h lxcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1an+dTIj; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si11690307ejj.746.2021.03.29.01.40.33; Mon, 29 Mar 2021 01:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1an+dTIj; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234947AbhC2Ijv (ORCPT + 12 others); Mon, 29 Mar 2021 04:39:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:32858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231725AbhC2Iif (ORCPT ); Mon, 29 Mar 2021 04:38:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 826FF61864; Mon, 29 Mar 2021 08:38:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617007115; bh=8km8l5VSew3GbQK2/Vpmt3lL3a2JnnSKkzsZAWyFuuo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1an+dTIjro9mlhO4D/Exm9OIpdoEki2fbZkF8qIWiCv+YPfdKwyTW0afCp3VNahSE 5TPnw9ochHoG2KziLWn1mU3GvD7B4+UuRezLcOdE9iFek6djBth1Gu+3YB+yrqA/wA HbwjNKBZDQ6ogZ4kaJGaLH/HAgwIYyvM/+k8VCgs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anshuman Khandual , David Hildenbrand , Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , Heiko Carstens , Jason Wang , Jonathan Cameron , "Michael S. Tsirkin" , Michal Hocko , Oscar Salvador , Pankaj Gupta , Pankaj Gupta , teawater , Vasily Gorbik , Wei Yang , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.11 225/254] arm64/mm: define arch_get_mappable_range() Date: Mon, 29 Mar 2021 09:59:01 +0200 Message-Id: <20210329075640.480623043@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075633.135869143@linuxfoundation.org> References: <20210329075633.135869143@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Anshuman Khandual [ Upstream commit 03aaf83fba6e5af08b5dd174c72edee9b7d9ed9b ] This overrides arch_get_mappable_range() on arm64 platform which will be used with recently added generic framework. It drops inside_linear_region() and subsequent check in arch_add_memory() which are no longer required. It also adds a VM_BUG_ON() check that would ensure that mhp_range_allowed() has already been called. Link: https://lkml.kernel.org/r/1612149902-7867-3-git-send-email-anshuman.khandual@arm.com Signed-off-by: Anshuman Khandual Reviewed-by: David Hildenbrand Reviewed-by: Catalin Marinas Cc: Will Deacon Cc: Ard Biesheuvel Cc: Mark Rutland Cc: Heiko Carstens Cc: Jason Wang Cc: Jonathan Cameron Cc: "Michael S. Tsirkin" Cc: Michal Hocko Cc: Oscar Salvador Cc: Pankaj Gupta Cc: Pankaj Gupta Cc: teawater Cc: Vasily Gorbik Cc: Wei Yang Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- arch/arm64/mm/mmu.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) -- 2.30.1 diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 6f0648777d34..92b3be127796 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1443,16 +1443,19 @@ static void __remove_pgd_mapping(pgd_t *pgdir, unsigned long start, u64 size) free_empty_tables(start, end, PAGE_OFFSET, PAGE_END); } -static bool inside_linear_region(u64 start, u64 size) +struct range arch_get_mappable_range(void) { + struct range mhp_range; + /* * Linear mapping region is the range [PAGE_OFFSET..(PAGE_END - 1)] * accommodating both its ends but excluding PAGE_END. Max physical * range which can be mapped inside this linear mapping range, must * also be derived from its end points. */ - return start >= __pa(_PAGE_OFFSET(vabits_actual)) && - (start + size - 1) <= __pa(PAGE_END - 1); + mhp_range.start = __pa(_PAGE_OFFSET(vabits_actual)); + mhp_range.end = __pa(PAGE_END - 1); + return mhp_range; } int arch_add_memory(int nid, u64 start, u64 size, @@ -1460,11 +1463,7 @@ int arch_add_memory(int nid, u64 start, u64 size, { int ret, flags = 0; - if (!inside_linear_region(start, size)) { - pr_err("[%llx %llx] is outside linear mapping region\n", start, start + size); - return -EINVAL; - } - + VM_BUG_ON(!mhp_range_allowed(start, size, true)); if (rodata_full || debug_pagealloc_enabled()) flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;