Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3427036pxf; Mon, 29 Mar 2021 01:47:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkZEtJbLt/Gf6pwBKp1KtymYNua4H42VhZ24D9ooOfEPLbsMjvTHnjKa4d7DZTRe8N1YDW X-Received: by 2002:a17:906:b2d6:: with SMTP id cf22mr27340606ejb.321.1617007625353; Mon, 29 Mar 2021 01:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007625; cv=none; d=google.com; s=arc-20160816; b=n3Ub9tjitemLgURvNFXpcfz6BEyjza5PeS0ulONIK3kMrHbUsSI5uC1XilWoek34Sq U+Z0a4four3KC1qD4LqYn3oUhprjB+NIsC81SPA/Qwtm938oUnivMvqsJN4dOjzoxuVO +CdmLXZ8BHiw9KleYKwS1GXD77Ue0EzQc9IzIcUwfbZDO0Ds0dCTBQxFKyhmDOpnvZbO HRDWv+mXKtbdBoGrzjiSTzNEQk2Kt4lsGmaJRZs9KH7Rg0nHCON2KuVokrfeVkta4GQY b+oHSc8zYHULE+LloHEL98N7aEdVy3ETAexo/HsJfPs1cY4lywmxEUBmC++ONFfgPLKb sQgw== 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=EuDHa3wm+kT7jsyL8MXQkXwNjb4LW9ukwgIDbnjO/49A6WBAzlfvfkUdWL6duKgvXt 3Z+FwyJS6v03AY1muxp4lwpJ2v1Pxz3QExmXlliADa7bKl4jtdzvuYH5ZZy23AoiLciw yAJ/oMBU5hEda0UxKC7OHlohDLnKrvD0LFVwyq6Ixtt6SG8E3z1pZ8/oO7IOdLtqSbj3 HcDi0sne5Bvgl0r070Tu9w9a4GDpL6cHJYebKX/THWKAhEdQdLwXRZZST/Es9Bypv8c1 cEHgPzE/sOUMF8ZuXxBU9oQ2Z0byb4cfaSWTUQHmGYyBFUmzUKlKrDYO3ibN+fQ82Mb/ dinw== 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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 j27si12693095edy.231.2021.03.29.01.46.43; Mon, 29 Mar 2021 01:47:05 -0700 (PDT) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1bAwTDNk; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232736AbhC2InQ (ORCPT + 99 others); Mon, 29 Mar 2021 04:43:16 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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; -- 2.30.1