Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3114606pxj; Mon, 17 May 2021 18:08:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykqm02htmSibyfO3yJeOC19DtFQLv0/JgmuIQsGINUq/harJeDe2aeMwoeNJ7uBW4XQ7zR X-Received: by 2002:a50:9f05:: with SMTP id b5mr3774513edf.24.1621300133460; Mon, 17 May 2021 18:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621300133; cv=none; d=google.com; s=arc-20160816; b=KizUA6G4d07f/cGg8Qfx0Nz8FYJwtCV+5MdhcdP1VZFCrRNmKhEArzi1fiuYNxmtsj Td7xUFVbZZQ8UFgSR51v566IiVAW9w5I92pxl+BDhPpHSXkaFvbtx362vFCmlH8Ew7uf LpRx1LDQ5yEV9tQsVmg2Co5aLe6WD44+2oxiA2tFjEwAx+TV5/Sa3BSjI1E/u6P1o+jM KyxVH89bm/PNhTWT8whSFuUNqzFaKbA0zrwlme2yqBgdQu7BEPhEfr6iUnbQm2xB5VmM 9kvEpeqfEBoHzGTLKMJA6XpuXE29Xb+i+nBs15dxggpqXRgPBWOQMmr78B0YEpxCekLV BNhg== 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=dIieibEKRtIxIt4lTtZQ8axrtsG1KfQUPs79kFhc0Is=; b=MyAIrdV28vHbKcwYQjVsf0fqKr843ccarRmSV4bAqyARcZbnmtVDmlVBxcjG8MrtkM ggpBbNLhSBxj/zhfPd5NNLiYigGAEDTIio6e+GTCn1iZ0y0ZxsYxusAMnfsS9esTXecB kgDN2tnTkiBy3+nx4mxqgEvGTP+Pr+cIPohuUTSsiRhgH3huFDrjABgreQqCF/oPuTXk 6IQw3GOEhqeYSdbh253veh3UekATrJ5lcC9TW6wu+G2phO8Iu75BMf0ivX1h9egeIRAg e0qEKkgEBuJ4TYdzgjazU+AeQfxBVdfeqsHOTwSrx4nJf9dCKeiIo5zeskya3Ud8ju1Q rnJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="MDzb1u/H"; 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 i17si17048edt.91.2021.05.17.18.08.30; Mon, 17 May 2021 18:08:53 -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="MDzb1u/H"; 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 S237903AbhEQOaa (ORCPT + 99 others); Mon, 17 May 2021 10:30:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:53290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239357AbhEQO0L (ORCPT ); Mon, 17 May 2021 10:26:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E56726157F; Mon, 17 May 2021 14:13:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260806; bh=USVj1aOx32BkPfqjHMaJuj3wboIQBZOYm6l01M15d1w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MDzb1u/HiBH2kaTPzscH4gU9E2n537fDkwZ8bnVE85rjMNFlPZVVMI7F3LROn3ilk uqxUtqeLH2a2E/1h5RLlhmftqudv4ioyc9Bj36IlSvuQSaCVJ5y/DxYr7eiV8ZrVBn mmMbo5asOPxqaBNIsp1MB3wEzsFWN7ZdolQYeyl4= 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.12 240/363] kernel/resource: make walk_mem_res() find all busy IORESOURCE_MEM resources Date: Mon, 17 May 2021 16:01:46 +0200 Message-Id: <20210517140310.702720198@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 4efd6e912279..16e0c7e8ed24 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -470,7 +470,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