From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77021C433E1 for ; Fri, 17 Jul 2020 18:00:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B9CD206BE for ; Fri, 17 Jul 2020 18:00:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727021AbgGQSAr (ORCPT ); Fri, 17 Jul 2020 14:00:47 -0400 Received: from lhrrgout.huawei.com ([185.176.76.210]:2497 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726232AbgGQSAq (ORCPT ); Fri, 17 Jul 2020 14:00:46 -0400 Received: from lhreml710-chm.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id A95D0E120BD21A2B8C95; Fri, 17 Jul 2020 19:00:44 +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:00:44 +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 0/6] ACPI: Only create NUMA nodes from entries in SRAT or SRAT emulation. Date: Sat, 18 Jul 2020 01:59:53 +0800 Message-ID: <20200717175959.899775-1-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 Here, I will use the term Proximity Domains for the ACPI description and NUMA Nodes for the in kernel representation. ACPI 6.3 included a clarification that only Static Resource Allocation Structures in SRAT may define the existence of proximity domains (sec 5.2.16). This clarification closed a possible interpretation that other parts of ACPI (e.g. DSDT _PXM, NFIT etc) could define new proximity domains that were not also mentioned in SRAT structures. In practice the kernel has never allowed this alternative interpretation as such nodes are only partially initialized. This is architecture specific but to take an example, on x86 alloc_node_data has not been called. Any use of them for node specific allocation, will result in a crash as the infrastructure to fallback to a node with memory is not setup. We ran into a problem when enabling _PXM handling for PCI devices and found there were boards out there advertising devices in proximity domains that didn't exist [2]. The fix suggested in this series is to replace instances that should not 'create' new nodes with pxm_to_node. This function needs a some additional hardening against invalid inputs to make sure it is safe for use in these new callers. Patch 1 Hardens pxm_to_node() against numa_off, and pxm entry being too large. Patch 2-4 change the various callers not related to SRAT entries so that they set this parameter to false, so do not attempt to initialize a new NUMA node if the relevant one does not already exist. Patch 5 is a function rename to reflect change in functionality of acpi_map_pxm_to_online_node() as it no longer creates a new map, but just does a lookup of existing maps. Patch 6 covers the one place we do not allow the full flexibility defined in the ACPI spec. For SRAT GIC Interrupt Translation Service (ITS) Affinity Structures, on ARM64, the driver currently makes an additional pass of SRAT later in the boot than the one used to identify NUMA domains. Note, this currently means that an ITS placed in a proximity domain that is not defined by another SRAT structure will result in the a crash. To avoid this crash with minimal changes we do not create new NUMA nodes based on this particular entry type. Any current platform trying to do this will not boot, so this is an improvement, if perhaps not a perfect solution. [1] Note in ACPI Specification 6.3 5.2.16 System Resource Affinity Table (SRAT) [2] https://patchwork.kernel.org/patch/10597777/ Thanks to Bjorn Helgaas for review of v1 and Barry Song for internal reviews that lead to a slightly different approach for this v2. Changes since v1. * Use pxm_to_node for what was previously the path using acpi_map_pxm_to_node with create==false. (Barry) * Broke patch up into an initial noop stage followed by patches (Bjorn) to update each type of case in which partial creation of NUMA nodes is prevented. * Added patch 5 to rename function to reflect change of functionality. * Updated descriptions (now mostly in individual patches) inline with Bjorn's comments. Jonathan Cameron (6): ACPI: Add out of bounds and numa_off protections to pxm_to_node ACPI: Do not create new NUMA domains from ACPI static tables that are not SRAT ACPI: Remove side effect of partly creating a node in acpi_map_pxm_to_online_node ACPI: rename acpi_map_pxm_to_online_node to pxm_to_online_node ACPI: Remove side effect of partly creating a node in acpi_get_node irq-chip/gic-v3-its: Fix crash if ITS is in a proximity domain without processor or memory drivers/acpi/arm64/iort.c | 2 +- drivers/acpi/nfit/core.c | 6 ++---- drivers/acpi/numa/hmat.c | 4 ++-- drivers/acpi/numa/srat.c | 4 ++-- drivers/iommu/intel/dmar.c | 2 +- drivers/irqchip/irq-gic-v3-its.c | 7 ++++++- include/linux/acpi.h | 15 +++++++-------- 7 files changed, 21 insertions(+), 19 deletions(-) -- 2.19.1 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 226AEC433E7 for ; Fri, 17 Jul 2020 18:02:29 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E4DBC2076A for ; Fri, 17 Jul 2020 18:02:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="O5p/B7sc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4DBC2076A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=tuD+79R0Vx3eFdAg4ALfDH8pKCylaMMt6044EWoFHBo=; b=O5p/B7scxPjrZ0Oim1SdnRqsbo ySJ6mZgpIayQor7MYVuUPPsdYftjW622nZlctA8S4sq8CE6lbof3hnOT21dN39oOBJVcGDAOt0yaF UOpmXqMg2mUKszXeZpbJgVOv9HI79eXUj3egfWLWJGas/AVQkqMuqga1tI2MbHi/1TOZnhhbtClmU DTU2ZL/p60wkT7uL8wUq9VjWlkQ9NFYouvOQysjRJBBNKZquKzRA+OIAKP7HFDIM8xb9NUx9qVl1+ WdYUxYqto7zqO7Ub6kO6T0wmbcayRhiNqvhxScLrzMQlixJ3cEoldDDsAdsFQJxR2DZQfSHq5GHnA 5ScJwj6g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwUfL-00018I-OV; Fri, 17 Jul 2020 18:00:59 +0000 Received: from lhrrgout.huawei.com ([185.176.76.210] helo=huawei.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jwUfJ-00016b-9o for linux-arm-kernel@lists.infradead.org; Fri, 17 Jul 2020 18:00:58 +0000 Received: from lhreml710-chm.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id A95D0E120BD21A2B8C95; Fri, 17 Jul 2020 19:00:44 +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:00:44 +0100 From: Jonathan Cameron To: , , , Subject: [PATCH v2 0/6] ACPI: Only create NUMA nodes from entries in SRAT or SRAT emulation. Date: Sat, 18 Jul 2020 01:59:53 +0800 Message-ID: <20200717175959.899775-1-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.19.1 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200717_140057_440063_254AF8BC X-CRM114-Status: GOOD ( 14.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Song Bao Hua , Fenghua Yu , Lorenzo Pieralisi , linux-ia64@vger.kernel.org, Tony Luck , linux-pci@vger.kernel.org, Jonathan Cameron , linuxarm@huawei.com, Ingo Molnar , martin@geanix.com, Bjorn Helgaas , Thomas Gleixner , Dan Williams Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Here, I will use the term Proximity Domains for the ACPI description and NUMA Nodes for the in kernel representation. ACPI 6.3 included a clarification that only Static Resource Allocation Structures in SRAT may define the existence of proximity domains (sec 5.2.16). This clarification closed a possible interpretation that other parts of ACPI (e.g. DSDT _PXM, NFIT etc) could define new proximity domains that were not also mentioned in SRAT structures. In practice the kernel has never allowed this alternative interpretation as such nodes are only partially initialized. This is architecture specific but to take an example, on x86 alloc_node_data has not been called. Any use of them for node specific allocation, will result in a crash as the infrastructure to fallback to a node with memory is not setup. We ran into a problem when enabling _PXM handling for PCI devices and found there were boards out there advertising devices in proximity domains that didn't exist [2]. The fix suggested in this series is to replace instances that should not 'create' new nodes with pxm_to_node. This function needs a some additional hardening against invalid inputs to make sure it is safe for use in these new callers. Patch 1 Hardens pxm_to_node() against numa_off, and pxm entry being too large. Patch 2-4 change the various callers not related to SRAT entries so that they set this parameter to false, so do not attempt to initialize a new NUMA node if the relevant one does not already exist. Patch 5 is a function rename to reflect change in functionality of acpi_map_pxm_to_online_node() as it no longer creates a new map, but just does a lookup of existing maps. Patch 6 covers the one place we do not allow the full flexibility defined in the ACPI spec. For SRAT GIC Interrupt Translation Service (ITS) Affinity Structures, on ARM64, the driver currently makes an additional pass of SRAT later in the boot than the one used to identify NUMA domains. Note, this currently means that an ITS placed in a proximity domain that is not defined by another SRAT structure will result in the a crash. To avoid this crash with minimal changes we do not create new NUMA nodes based on this particular entry type. Any current platform trying to do this will not boot, so this is an improvement, if perhaps not a perfect solution. [1] Note in ACPI Specification 6.3 5.2.16 System Resource Affinity Table (SRAT) [2] https://patchwork.kernel.org/patch/10597777/ Thanks to Bjorn Helgaas for review of v1 and Barry Song for internal reviews that lead to a slightly different approach for this v2. Changes since v1. * Use pxm_to_node for what was previously the path using acpi_map_pxm_to_node with create==false. (Barry) * Broke patch up into an initial noop stage followed by patches (Bjorn) to update each type of case in which partial creation of NUMA nodes is prevented. * Added patch 5 to rename function to reflect change of functionality. * Updated descriptions (now mostly in individual patches) inline with Bjorn's comments. Jonathan Cameron (6): ACPI: Add out of bounds and numa_off protections to pxm_to_node ACPI: Do not create new NUMA domains from ACPI static tables that are not SRAT ACPI: Remove side effect of partly creating a node in acpi_map_pxm_to_online_node ACPI: rename acpi_map_pxm_to_online_node to pxm_to_online_node ACPI: Remove side effect of partly creating a node in acpi_get_node irq-chip/gic-v3-its: Fix crash if ITS is in a proximity domain without processor or memory drivers/acpi/arm64/iort.c | 2 +- drivers/acpi/nfit/core.c | 6 ++---- drivers/acpi/numa/hmat.c | 4 ++-- drivers/acpi/numa/srat.c | 4 ++-- drivers/iommu/intel/dmar.c | 2 +- drivers/irqchip/irq-gic-v3-its.c | 7 ++++++- include/linux/acpi.h | 15 +++++++-------- 7 files changed, 21 insertions(+), 19 deletions(-) -- 2.19.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Cameron Date: Fri, 17 Jul 2020 17:59:53 +0000 Subject: [PATCH v2 0/6] ACPI: Only create NUMA nodes from entries in SRAT or SRAT emulation. Message-Id: <20200717175959.899775-1-Jonathan.Cameron@huawei.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-mm@kvack.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org Cc: Lorenzo Pieralisi , Bjorn Helgaas , linux-pci@vger.kernel.org, martin@geanix.com, Ingo Molnar , linux-ia64@vger.kernel.org, Tony Luck , Fenghua Yu , Thomas Gleixner , linuxarm@huawei.com, Dan Williams , Song Bao Hua , Jonathan Cameron Here, I will use the term Proximity Domains for the ACPI description and NUMA Nodes for the in kernel representation. ACPI 6.3 included a clarification that only Static Resource Allocation Structures in SRAT may define the existence of proximity domains (sec 5.2.16). This clarification closed a possible interpretation that other parts of ACPI (e.g. DSDT _PXM, NFIT etc) could define new proximity domains that were not also mentioned in SRAT structures. In practice the kernel has never allowed this alternative interpretation as such nodes are only partially initialized. This is architecture specific but to take an example, on x86 alloc_node_data has not been called. Any use of them for node specific allocation, will result in a crash as the infrastructure to fallback to a node with memory is not setup. We ran into a problem when enabling _PXM handling for PCI devices and found there were boards out there advertising devices in proximity domains that didn't exist [2]. The fix suggested in this series is to replace instances that should not 'create' new nodes with pxm_to_node. This function needs a some additional hardening against invalid inputs to make sure it is safe for use in these new callers. Patch 1 Hardens pxm_to_node() against numa_off, and pxm entry being too large. Patch 2-4 change the various callers not related to SRAT entries so that they set this parameter to false, so do not attempt to initialize a new NUMA node if the relevant one does not already exist. Patch 5 is a function rename to reflect change in functionality of acpi_map_pxm_to_online_node() as it no longer creates a new map, but just does a lookup of existing maps. Patch 6 covers the one place we do not allow the full flexibility defined in the ACPI spec. For SRAT GIC Interrupt Translation Service (ITS) Affinity Structures, on ARM64, the driver currently makes an additional pass of SRAT later in the boot than the one used to identify NUMA domains. Note, this currently means that an ITS placed in a proximity domain that is not defined by another SRAT structure will result in the a crash. To avoid this crash with minimal changes we do not create new NUMA nodes based on this particular entry type. Any current platform trying to do this will not boot, so this is an improvement, if perhaps not a perfect solution. [1] Note in ACPI Specification 6.3 5.2.16 System Resource Affinity Table (SRAT) [2] https://patchwork.kernel.org/patch/10597777/ Thanks to Bjorn Helgaas for review of v1 and Barry Song for internal reviews that lead to a slightly different approach for this v2. Changes since v1. * Use pxm_to_node for what was previously the path using acpi_map_pxm_to_node with create=false. (Barry) * Broke patch up into an initial noop stage followed by patches (Bjorn) to update each type of case in which partial creation of NUMA nodes is prevented. * Added patch 5 to rename function to reflect change of functionality. * Updated descriptions (now mostly in individual patches) inline with Bjorn's comments. Jonathan Cameron (6): ACPI: Add out of bounds and numa_off protections to pxm_to_node ACPI: Do not create new NUMA domains from ACPI static tables that are not SRAT ACPI: Remove side effect of partly creating a node in acpi_map_pxm_to_online_node ACPI: rename acpi_map_pxm_to_online_node to pxm_to_online_node ACPI: Remove side effect of partly creating a node in acpi_get_node irq-chip/gic-v3-its: Fix crash if ITS is in a proximity domain without processor or memory drivers/acpi/arm64/iort.c | 2 +- drivers/acpi/nfit/core.c | 6 ++---- drivers/acpi/numa/hmat.c | 4 ++-- drivers/acpi/numa/srat.c | 4 ++-- drivers/iommu/intel/dmar.c | 2 +- drivers/irqchip/irq-gic-v3-its.c | 7 ++++++- include/linux/acpi.h | 15 +++++++-------- 7 files changed, 21 insertions(+), 19 deletions(-) -- 2.19.1