From patchwork Mon Mar 29 07:58:42 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: 410811 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp3429242jai; Mon, 29 Mar 2021 01:29:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxor9l141YZA2v8sXAMDw6dAK3a+vGDaNEDEAaQVCKiHuDsxC4LWkwxKZnFpDq+v7iRCF5n X-Received: by 2002:a17:906:d94:: with SMTP id m20mr26619631eji.511.1617006577886; Mon, 29 Mar 2021 01:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617006577; cv=none; d=google.com; s=arc-20160816; b=Q+PoaHnixdrc5NEUacWtbms3HK7ZdhBAIjvakXosob1M+N/OghYusOvq4+H8F0mNMC JLlcVf1kr7+xg4IYe4jjjbRS39ufmmigjC71GxuH2iKz2fVhMIDjE9tDKK8Df5ePFX78 4TODYUOEexIRy1gCIHxF5DejWTkDC/esM1W45S4Byf4EeTEKR/pRy7XEWDfeMDcOKFh/ PXqjESmvrinQjjfe8zP7MAju6wbbo5LVY6mmkERhYv492YCV/yLAIlYy7Yv3ZdKkTLrQ QpTf81IU6mlzXYDJoqGoTBNDyXmy75DPkgw2f7cf9bcaNKmovfGmK6elGllCfIZumLaL TRFg== 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=NnmTxUXnROyAlsJxlqC4vUpOAxmrLzmhRsJ8o3xsFHQ=; b=ReNdcO89hKtSfNJ4RaDrl5nA150y4MDl0PFqhWMpD3oY6zzaNMyplUQ22JxNQRS1ak plPaw4B/kUuhmPqIA8G8g9jvEFuAbQI0l33SfXy80ABuul0ErCe1VKaR430511tdJq+C heesNnypoWnx/stRDX7HflHmFnmmMrUhekhX21ASz/vdqy8F/sEe6wiHCJdjoT6an8kU uM7psu0AFSNE/+yngjpcf2hj8In+dokr/yyppDpk8cZ2mEvZ6nwnfJgb+bUpH9RKPESr ctBC0f5BjZlmK3LoiTXirh/6GXRPulVGeRfsERkVlO1egv1qj8I0MKehuxESjlGvdAEQ m8VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1bAwTDNk; 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 n23si12339235ejs.705.2021.03.29.01.29.37; Mon, 29 Mar 2021 01:29:37 -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=1bAwTDNk; 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 S234792AbhC2I3C (ORCPT + 12 others); Mon, 29 Mar 2021 04:29:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:41832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233203AbhC2IZd (ORCPT ); Mon, 29 Mar 2021 04:25:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 435B26196E; Mon, 29 Mar 2021 08:24:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006299; bh=D2c0yfhlEE5amncLHwFC5M34mtZgt7/IViBZIwaeAF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1bAwTDNkh5i9PldoCRRbwQvs4sgDPKpJflijxyXdj3T67uMC7amYt4H4LQVKRsExX tn5vHzGdxhVLfyR3vdOjxLfchgkRd5CCN7HILDSci4rSOyu7D49RWd/Ho0wgrUcKv7 O6SM54RvgXWC8XzmmLuCWmobU5zF6rMOERl6AhrU= 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.10 191/221] arm64/mm: define arch_get_mappable_range() Date: Mon, 29 Mar 2021 09:58:42 +0200 Message-Id: <20210329075635.502877514@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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 6aabf1eced31..0635803463a5 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -1445,16 +1445,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, @@ -1462,11 +1465,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;