Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp545373pxj; Tue, 18 May 2021 08:59:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAEfvFjRjGCy5Y7IWOuLJbn+0uK4Uyj4/+vgEtDwldYoC7bSD7c/rN8S0KqXjvUKClILZH X-Received: by 2002:a17:906:a51:: with SMTP id x17mr6816632ejf.25.1621353574927; Tue, 18 May 2021 08:59:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621353574; cv=none; d=google.com; s=arc-20160816; b=H+d9XYEZeP915o6F2z04ltwYIetFsVdXv4ufecv/Xwkpt3DHWf0SxVFmEzL5qbTGzB h7E+RtPMeJsVHJfpQJPzEdwA319thRmzxT/kD9HbiTZ9zq3aL7ccm5KBaZujaPXXGfWt LwND4Ryw6pfzxuWiAEAL6fWyYbaFx1krvM7RSGXPjn2MrNbYX3aSQ7i8h9qDh58UsNJn D22ps73FJvzhx8usDarzFEmu0+cqJ0TDkebyHZRAyLMtssl9a2wutlt5NNgRUVZPu77K 94XM17kIKNYUnZxc75YBYiJEyqovBuWCpq5UsjzhdMrBFXe+jvNJBOd6EGknJBUnWCYk ifzw== 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=Wi7CzxurgrewQ4KJSY6nbkXqbk/OztlZP3hTU/JOObU=; b=jJlYOUfGMyBRqE+kcMIWk7fPXklTUE77dVjSX12CdQ3GhAFiadZnYU5pIITKLkSC/Q D/dQkZO2Cj1e9OGdZ+76eGIa57SlXWcKu3fvAi7123ReTBk4dNdcjBMjNm/63pxAmutd cWTbZt2TsGK8zlLBj/2E9f2kUBlxOYZTvHbKo0V5tjLLH4iOL1wlGZeHDJM67SALaeTy UZ/O+8fFtqLDM7v1k3+TBQCzWyqIaHkxIueoGbIHQydMKpUCEkdytlJjpDF6bVm5See1 juiQAckVReOUF3hQwWEDzEpTPiUQIHLcF8IvMrGGS78xMYr5X36z2NuEjroGYxv5TRVM BZvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DLRwm38z; 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 cx12si19817581edb.413.2021.05.18.08.58.49; Tue, 18 May 2021 08:59:34 -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=DLRwm38z; 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 S1346100AbhEQP6F (ORCPT + 99 others); Mon, 17 May 2021 11:58:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:42232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244831AbhEQPhY (ORCPT ); Mon, 17 May 2021 11:37:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC20161CEC; Mon, 17 May 2021 14:40:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262431; bh=RgnXyFa4aiP4mg/aphn4O+kdtN8kh/vuQzBK7UhspZw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DLRwm38zCgI/hX2ECku4DWmM4eCTy++eNq5isgRyraUWRtP0YyjzhiN19FyQj0wEN pci5SYA9nx5AHdpn1xXrEtLMoSZgrkpGAOIx9o4TNpdfb8b3S5UVKTvQFxfWkmG0i2 ikCS91+7VKb82ITkD7MefB91owE2ornqKhUM7XPg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Hildenbrand , Dan Williams , Daniel Vetter , Andy Shevchenko , Mauro Carvalho Chehab , Dave Young , Baoquan He , Vivek Goyal , Dave Hansen , Keith Busch , Michal Hocko , Qian Cai , Oscar Salvador , Eric Biederman , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Tom Lendacky , Brijesh Singh , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.10 186/289] kernel/resource: make walk_mem_res() find all busy IORESOURCE_MEM resources Date: Mon, 17 May 2021 16:01:51 +0200 Message-Id: <20210517140311.373219930@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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: David Hildenbrand [ Upstream commit 3c9c797534364593b73ba6ab060a014af8934721 ] It used to be true that we can have system RAM (IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY) only on the first level in the resource tree. However, this is no longer holds for driver-managed system RAM (i.e., added via dax/kmem and virtio-mem), which gets added on lower levels, for example, inside device containers. IORESOURCE_SYSTEM_RAM is defined as IORESOURCE_MEM | IORESOURCE_SYSRAM and just a special type of IORESOURCE_MEM. The function walk_mem_res() only considers the first level and is used in arch/x86/mm/ioremap.c:__ioremap_check_mem() only. We currently fail to identify System RAM added by dax/kmem and virtio-mem as "IORES_MAP_SYSTEM_RAM", for example, allowing for remapping of such "normal RAM" in __ioremap_caller(). Let's find all IORESOURCE_MEM | IORESOURCE_BUSY resources, making the function behave similar to walk_system_ram_res(). Link: https://lkml.kernel.org/r/20210325115326.7826-3-david@redhat.com Fixes: ebf71552bb0e ("virtio-mem: Add parent resource for all added "System RAM"") Fixes: c221c0b0308f ("device-dax: "Hotplug" persistent memory for use like normal RAM") Signed-off-by: David Hildenbrand Reviewed-by: Dan Williams Cc: Greg Kroah-Hartman Cc: Dan Williams Cc: Daniel Vetter Cc: Andy Shevchenko Cc: Mauro Carvalho Chehab Cc: Dave Young Cc: Baoquan He Cc: Vivek Goyal Cc: Dave Hansen Cc: Keith Busch Cc: Michal Hocko Cc: Qian Cai Cc: Oscar Salvador Cc: Eric Biederman Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Borislav Petkov Cc: "H. Peter Anvin" Cc: Tom Lendacky Cc: Brijesh Singh Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- kernel/resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/resource.c b/kernel/resource.c index 88a0ed866777..817545ff80b9 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -463,7 +463,7 @@ int walk_mem_res(u64 start, u64 end, void *arg, { unsigned long flags = IORESOURCE_MEM | IORESOURCE_BUSY; - return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, true, + return __walk_iomem_res_desc(start, end, flags, IORES_DESC_NONE, false, arg, func); } -- 2.30.2