Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2980458imu; Mon, 19 Nov 2018 08:56:23 -0800 (PST) X-Google-Smtp-Source: AJdET5eEbgrd40Zq9USv3ED4SUPjiib196MzO+lie3fib6dAe2FhuFqFvFv0BLMzUdikMebCOXM+ X-Received: by 2002:a63:e302:: with SMTP id f2mr21105030pgh.320.1542646583063; Mon, 19 Nov 2018 08:56:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542646583; cv=none; d=google.com; s=arc-20160816; b=jwDY10uOqZ+Iyizdn90AHzNN7IS5ExUgOHzTxv/tH/c3+wpq43MzDNg5/dkjfKMpJL WRrltYB3llZZtcn621K6UZky+pKg1gMJZO9rVaR+KYPkpimF3U247JmGkk3uHChdI/7K qOlUSIk4kb0wyU4x7UsFegbV1+lApsGlWzIhXcuRHxh2GOeJpXmu3vB5dveg9k7kNM0e ODBiDpPw3WnCWEzK7pbNi/4SsNuoDdIGtd5oJ1ROAsA+T6Gfqxo434G0UuiRgpcc0Mep fnl5ugEAnrkRt4euzwUvADGtA21YYf/fiIpk2ouIqNbT8jK4b5gFH9h5qEcdJCsdOGQz /iMA== 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:subject:cc:to :from:dkim-signature; bh=0RsxiQhHRi0vhhpZWv3g+YZaPCzUH0iBjL/W6luscS4=; b=VNbXzKIvdAO9YTZpmsiyoTiG54ahthRBhU2NXGl7aa/g6wlsxnUuRKrXeX/3/JXkcV gH82u4Vaa3nX4PbWHv5lfTeRs3XLPGErpWNcvvKSRangs4e9JeN9Je/hJ0Gh8DDErJrE y+bWueEEWQ3K8OFUDWTUha9PKO5qDa+TQyFddX2pWUDfOPj6GsrJXLZHuM9Xm5ucmXpP Ix3TJjfNRLS9W2TkvlEztZXDypTenRXv1GR9ObaOr3AcrIBJog0+kAMwU4bmI+EIWd4B 536NGn0dMKQUqrbfMWbvdPoX6pg7UsMM9RUUSpZon/8wTdcI4db3AZpGE/r2Ukc6kcfb M8Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vquwou2t; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f184-v6si33395971pfb.252.2018.11.19.08.56.08; Mon, 19 Nov 2018 08:56:23 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=Vquwou2t; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390930AbeKTDS0 (ORCPT + 99 others); Mon, 19 Nov 2018 22:18:26 -0500 Received: from mail.kernel.org ([198.145.29.99]:57284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403939AbeKTDSZ (ORCPT ); Mon, 19 Nov 2018 22:18:25 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A92C8208E3; Mon, 19 Nov 2018 16:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646451; bh=cMn39F6NdRX3QfedWHeUQMVbsy9R6tIaTOB1kaWFbwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vquwou2tF2WFr9xKX+/1XhsSiCSye0IgqBSabBJeQlzfuwKpmkxE1JBETPg79ONBk Ch7enbJegzDLcndz/LBGtyT7W8a899lwI5nRVHBLiS6YjAFMcjurd8UhfKYVC1K5Jr 7soub5y+62dTZkAl7XBy3agcsopwO3w8uW3nVQCk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Garry , Will Deacon , Rob Herring Subject: [PATCH 4.9 47/83] of, numa: Validate some distance map rules Date: Mon, 19 Nov 2018 17:29:13 +0100 Message-Id: <20181119162621.835564011@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162612.046511542@linuxfoundation.org> References: <20181119162612.046511542@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: John Garry commit 89c38422e072bb453e3045b8f1b962a344c3edea upstream. Currently the NUMA distance map parsing does not validate the distance table for the distance-matrix rules 1-2 in [1]. However the arch NUMA code may enforce some of these rules, but not all. Such is the case for the arm64 port, which does not enforce the rule that the distance between separates nodes cannot equal LOCAL_DISTANCE. The patch adds the following rules validation: - distance of node to self equals LOCAL_DISTANCE - distance of separate nodes > LOCAL_DISTANCE This change avoids a yet-unresolved crash reported in [2]. A note on dealing with symmetrical distances between nodes: Validating symmetrical distances between nodes is difficult. If it were mandated in the bindings that every distance must be recorded in the table, then it would be easy. However, it isn't. In addition to this, it is also possible to record [b, a] distance only (and not [a, b]). So, when processing the table for [b, a], we cannot assert that current distance of [a, b] != [b, a] as invalid, as [a, b] distance may not be present in the table and current distance would be default at REMOTE_DISTANCE. As such, we maintain the policy that we overwrite distance [a, b] = [b, a] for b > a. This policy is different to kernel ACPI SLIT validation, which allows non-symmetrical distances (ACPI spec SLIT rules allow it). However, the distance debug message is dropped as it may be misleading (for a distance which is later overwritten). Some final notes on semantics: - It is implied that it is the responsibility of the arch NUMA code to reset the NUMA distance map for an error in distance map parsing. - It is the responsibility of the FW NUMA topology parsing (whether OF or ACPI) to enforce NUMA distance rules, and not arch NUMA code. [1] Documents/devicetree/bindings/numa.txt [2] https://www.spinics.net/lists/arm-kernel/msg683304.html Cc: stable@vger.kernel.org # 4.7 Signed-off-by: John Garry Acked-by: Will Deacon Signed-off-by: Rob Herring Signed-off-by: Greg Kroah-Hartman --- drivers/of/of_numa.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- a/drivers/of/of_numa.c +++ b/drivers/of/of_numa.c @@ -126,9 +126,14 @@ static int __init of_numa_parse_distance distance = of_read_number(matrix, 1); matrix++; + if ((nodea == nodeb && distance != LOCAL_DISTANCE) || + (nodea != nodeb && distance <= LOCAL_DISTANCE)) { + pr_err("Invalid distance[node%d -> node%d] = %d\n", + nodea, nodeb, distance); + return -EINVAL; + } + numa_set_distance(nodea, nodeb, distance); - pr_debug("distance[node%d -> node%d] = %d\n", - nodea, nodeb, distance); /* Set default distance of node B->A same as A->B */ if (nodeb > nodea)