From patchwork Tue Aug 18 14:24:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Cameron X-Patchwork-Id: 247893 Delivered-To: patch@linaro.org Received: by 2002:a54:3b12:0:0:0:0:0 with SMTP id j18csp3178155ect; Tue, 18 Aug 2020 07:26:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzskd1uvJW4LX86rCWAzY2ifIAfI0KELwbHkjv1B8NzCWcEY05Rpzt7jT8hYZBSS3lnbpf8 X-Received: by 2002:aa7:d304:: with SMTP id p4mr19277085edq.267.1597760802850; Tue, 18 Aug 2020 07:26:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597760802; cv=none; d=google.com; s=arc-20160816; b=mpD76rVrQpYcQmJJeCy1OJaCUsdn3Ttquso9TSaj68pzVs+ijqu5Evkub3v4misfKe zGA+JDiHf/MTs/pYu6m+XUED+ng4WGppy5m2/sT+Yj9wYWYpkxSvbVgX8UtsJ3Q1r/f0 S4tAVYq395oJkKC0Qe6dh5+KB8qEuooV5Ujpesi1maNwhQjtSqjVbNnUSMJ0TkLiZY0L S0fMZA+mbrnzyNEMvxfrmil5tu3Xd8D4jM84z/SGyV/EZuJufEANv45mGAp1yrF7srAO XtOJLpcTaxDq01LBqUvBZIvJOnx+wsx4GvOQ4CN/vfoVIpu6zuA7ixOyWQudRIAfAhlq XA7w== 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=7v3PNtVno2MNybT4a0JwwTABnjpGc29+Z6MYrJ6m89I=; b=mex4pHggTrcxkftSfjV/lez/r3NUjv95L0apwy+I8nkTR/pxXKFZodxtJFVj/l2sWU ZgapMLIXowhOyA45/wXhN3Di5Lhuesh1xycAnnkbvlbqmcgB+MbCsG769KjTlvw/d9dw Xvu5jYHj/MWbStANejXcie2dAo7oGBY2a/F/VEK9f/rhEVDoWEABcjM4c4vwwmV8oqk4 xmkeBoovZphdnBxmgn1FHBWZrMEe4w6P/AwBBGC3IlnjQdjxMFFKVWqCsQ3k4QfqUjE1 2oQQ4OZw3UyIPVKPOUqt8rK4g2jyuaiWBtWdiXlpdFpQVFiPOXXOv6iCFpeEQ+dEpgOc sk2A== 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 gr23si13682989ejb.132.2020.08.18.07.26.42; Tue, 18 Aug 2020 07:26:42 -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 S1726989AbgHRO0k (ORCPT + 7 others); Tue, 18 Aug 2020 10:26:40 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2619 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726709AbgHRO0i (ORCPT ); Tue, 18 Aug 2020 10:26:38 -0400 Received: from lhreml710-chm.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id 09C4E3BA7355E06700CE; Tue, 18 Aug 2020 15:26:37 +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_GCM_SHA256) id 15.1.1913.5; Tue, 18 Aug 2020 15:26:36 +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 v3 3/6] ACPI: Remove side effect of partly creating a node in acpi_map_pxm_to_online_node Date: Tue, 18 Aug 2020 22:24:27 +0800 Message-ID: <20200818142430.1156547-4-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20200818142430.1156547-1-Jonathan.Cameron@huawei.com> References: <20200818142430.1156547-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.123.41.22] X-ClientProxiedBy: lhreml710-chm.china.huawei.com (10.201.108.61) 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 Reviewed-by: Hanjun Guo --- 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 1e4cdc6c7ae2..a9fd122ae878 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); }