From patchwork Fri Jul 17 17:59:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 235741 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1926759ilg; Fri, 17 Jul 2020 11:02:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7KpktCJt0VSdn5BwKY6wNoxMSNat2WuYV4yeEhrMRX2X/OtInX4fd8uSXr0psf81SSKRl X-Received: by 2002:a17:906:fad4:: with SMTP id lu20mr8157624ejb.1.1595008938808; Fri, 17 Jul 2020 11:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595008938; cv=none; d=google.com; s=arc-20160816; b=GtwHnbXBqjPQYLXCPmSYhCEDNOkGJm7Le//ubRvljz57YciLXy4/wqg/l68WeCC4Oe 1mTkwKPxg+2ZDBum53HshExdQTBAusC089kx2UxnXn6fJam+yVS1TtvkxZrLiWuCMK7o mXgVHKiaHr7nXEH4x8URfg18x8u2HBt5pP01eCF33olezfWD1gJITIagvslMhebLs5gs R5eJrgTVImrUCCSE2biguReU3xUMDSB0jmjp+ODyd0zgBfnGyHcJxLoPr+HM8/rFr+OE RbaAxgA9aCESHjYUnuzE7VhuxlawjAirCHdojRUcNL3KhIehXKTHTi/nQ1IxMs/AI+Cy hqSw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BrWAtnfNJBvhRB5cPUV87sQZwtOYts5C+XH8xaiJdyQ=; b=bEqLs0ZQgkmaJcXb23jlOfAXPOMVKCBC1pFlOVyUUW+wmEumlSyKK2K/wE4KtR4g3e 317rCMnOW/7U/kTZBYKVHG2wR3vCihDJLwKw8GkfAdM5Jgfq1vmHpHPqabZgm9hx669j Pf8klaB0pXq/Ura01lmWqjgJJu/YReSoeK6pu/PaGMMhKtPEWdEOUPndmOy4VWk+GCvg GiagTxMnIFgvTuXdEqMwpcyetPnLIa9ugnYrxBihcPFBXj71g1tutNB9RQEOsiEkfBrY 8qZq0mxPASSPweMBOYi2bd7gR+PkhSSmlYxtcYa1TWd6cmO+vEYsVhQHLFcpjZPpH08w UtyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r12si5851190edo.320.2020.07.17.11.02.18; Fri, 17 Jul 2020 11:02:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728048AbgGQSCR (ORCPT + 7 others); Fri, 17 Jul 2020 14:02:17 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2500 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726232AbgGQSCR (ORCPT ); Fri, 17 Jul 2020 14:02:17 -0400 Received: from lhreml710-chm.china.huawei.com (unknown [172.18.7.106]) by Forcepoint Email with ESMTP id 102AE61B9167C6AA9A63; Fri, 17 Jul 2020 19:02:16 +0100 (IST) Received: from lhrphicprd00229.huawei.com (10.123.41.22) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1913.5; Fri, 17 Jul 2020 19:02:15 +0100 From: Jonathan Cameron To: , , , CC: Lorenzo Pieralisi , Bjorn Helgaas , , , Ingo Molnar , , Tony Luck , Fenghua Yu , Thomas Gleixner , , Dan Williams , Song Bao Hua , Jonathan Cameron Subject: [PATCH v2 3/6] ACPI: Remove side effect of partly creating a node in acpi_map_pxm_to_online_node Date: Sat, 18 Jul 2020 01:59:56 +0800 Message-ID: <20200717175959.899775-4-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200717175959.899775-1-Jonathan.Cameron@huawei.com> References: <20200717175959.899775-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.123.41.22] X-ClientProxiedBy: lhreml706-chm.china.huawei.com (10.201.108.55) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Whilst this function will only return an online node, it can have the side effect of partially creating a new node. The existing comments suggest this is intentional, but the usecases of this function are related to NFIT and HMAT parsing, neither of which should be able to define new nodes. One route by which the existing behaviour would cause a crash is to have a _PXM entry in ACPI DSDT attempt to place a device within this partly created proximity domain. A subsequent call to devm_kzalloc or similar would result in an attempt to allocate memory on a node for which zone lists have not been set up and a null pointer dereference. We prevent such cases by switching to pxm_to_node() within acpi_map_pxm_to_online_node which cannot cause a new node to be partly created. If one would previously have been created we now return NO_NUMA_NODE. Documentation updated to reflect this change. We may want to think about renaming acpi_map_pxm_to_online_node to pxm_to_online_node to reflect this change. Signed-off-by: Jonathan Cameron --- include/linux/acpi.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.19.1 diff --git a/include/linux/acpi.h b/include/linux/acpi.h index d661cd0ee64d..b541a0b444fd 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -430,13 +430,12 @@ int acpi_get_node(acpi_handle handle); * ACPI device drivers, which are called after the NUMA initialization has * completed in the kernel, can call this interface to obtain their device * NUMA topology from ACPI tables. Such drivers do not have to deal with - * offline nodes. A node may be offline when a device proximity ID is - * unique, SRAT memory entry does not exist, or NUMA is disabled, ex. - * "numa=off" on x86. + * offline nodes. A node may be offline when SRAT memory entry does not exist, + * or NUMA is disabled, ex. "numa=off" on x86. */ static inline int acpi_map_pxm_to_online_node(int pxm) { - int node = acpi_map_pxm_to_node(pxm); + int node = pxm_to_node(pxm); return numa_map_to_online_node(node); }