Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2864190ybb; Sun, 22 Mar 2020 09:29:49 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsD52MhF0P7wu6pcvMJc4GTnDkPXtoMkOFZsIlQNGaRaU5MPVuCYoiAPeuYiybQa1CJ1Fdd X-Received: by 2002:aca:cd0e:: with SMTP id d14mr13456590oig.167.1584894589214; Sun, 22 Mar 2020 09:29:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584894589; cv=none; d=google.com; s=arc-20160816; b=CCV9Ok93p4NkQgqbfj3bvkPYebZQ8DsW5blfPGRZuEFfr8zgWZ4CWXpQzKe8Zfwa0W /dam7kgBeM2ATuss5F5B/GHkuvlUikqH+NgQbzaJhFeimjoKenBEl462fEbkBA1cHh5h R83jwPZ/rLZZTLRatjPCJlC6mdBC352JQXq3yQibVeQgOrC23OgvJaG0+/WvjXzNu/G1 enbdIg1+gooxnKRhz2chWfCNhStLF6PMsVIJ6C1KZGj0m9c7jv5EOsTd9UclJM6mD3RL qZ4xwDKqzsvn547X3hDoNE2ewHbDN0JxkWBmEfo0Bm//drNMdPzDmss+/z//tLOdLK0V ld1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:ironport-sdr:ironport-sdr; bh=NEb9m2qnMSluSw/ZnlZcdaJtz4JixBB9FJkt+DFqGRA=; b=l0VyjqO9HxpmVsoxrtl0bGa+utzwHWzdKG/zV2jqO707rl/cBY9gHFwWItpEZIeRAv 8N7G8t4t6jXNcP479ZlZWw41t5fhkdFKAkoSuj5nxU2tSjyQ91lD8EGWMEQAxZWiBuTi ggwJUPDsnlFK4PYKLVDfZWeUSKNAtnoAma+RcU5lu8ld2NIEBB8GPJ/RduHbyfKuo37Y IRl8oOUmxusXdhC3cSsxsjDnG8cC+tK56ybVSqox6fCByJdfzgLmtcRt6PNKPOrDLOMx oM0MUHcLV4BBt2KimXHoql5dr+UpOiOy7YvkohNZz0SAv5bO4SvFcggZfOu3/J6dE/zy OLog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66si6020517ota.244.2020.03.22.09.29.37; Sun, 22 Mar 2020 09:29:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727068AbgCVQ3A (ORCPT + 99 others); Sun, 22 Mar 2020 12:29:00 -0400 Received: from mga12.intel.com ([192.55.52.136]:57351 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbgCVQ3A (ORCPT ); Sun, 22 Mar 2020 12:29:00 -0400 IronPort-SDR: Gicg/Nzs4reNJKVeusJ+R6VDoQ+RGh2S4r3OV5Sp3UhmooKy1HwuNgoMK4CxwCCNZcS1KIP2Tn i8AINAPiAGyA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2020 09:28:59 -0700 IronPort-SDR: um5GE78ju4nfrA/VjdbZYcOGGU/BRuJmmu5A67WcdWOPvsUY1RVM1iFWn91ruJto9s2Xz6JB2p 6PDNOOMfrC7g== X-IronPort-AV: E=Sophos;i="5.72,293,1580803200"; d="scan'208";a="239698755" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2020 09:28:59 -0700 Subject: [PATCH v2 5/6] resource: Report parent to walk_iomem_res_desc() callback From: Dan Williams To: linux-acpi@vger.kernel.org Cc: Jason Gunthorpe , Dave Hansen , Wei Yang , Tom Lendacky , peterz@infradead.org, ard.biesheuvel@linaro.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, x86@kernel.org, joao.m.martins@oracle.com Date: Sun, 22 Mar 2020 09:12:53 -0700 Message-ID: <158489357311.1457606.12568065258967741013.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <158489354353.1457606.8327903161927980740.stgit@dwillia2-desk3.amr.corp.intel.com> References: <158489354353.1457606.8327903161927980740.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In support of detecting whether a resource might have been been claimed, report the parent to the walk_iomem_res_desc() callback. For example, the ACPI HMAT parser publishes "hmem" platform devices per target range. However, if the HMAT is disabled / missing a fallback driver can attach devices to the raw memory ranges as a fallback if it sees unclaimed / orphan "Soft Reserved" resources in the resource tree. Otherwise, find_next_iomem_res() returns a resource with garbage data from the stack allocation in __walk_iomem_res_desc() for the res->parent field. There are currently no users that expect ->child and ->sibling to be valid, and the resource_lock would be needed to traverse them. Use a compound literal to implicitly zero initialize the fields that are not being returned in addition to setting ->parent. Cc: Jason Gunthorpe Cc: Dave Hansen Cc: Wei Yang Cc: Tom Lendacky Signed-off-by: Dan Williams --- kernel/resource.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/resource.c b/kernel/resource.c index 76036a41143b..f54ccf7a1009 100644 --- a/kernel/resource.c +++ b/kernel/resource.c @@ -382,10 +382,13 @@ static int find_next_iomem_res(resource_size_t start, resource_size_t end, if (p) { /* copy data */ - res->start = max(start, p->start); - res->end = min(end, p->end); - res->flags = p->flags; - res->desc = p->desc; + *res = (struct resource) { + .start = max(start, p->start), + .end = min(end, p->end), + .flags = p->flags, + .desc = p->desc, + .parent = p->parent, + }; } read_unlock(&resource_lock);