Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2973731imu; Mon, 19 Nov 2018 08:50:27 -0800 (PST) X-Google-Smtp-Source: AJdET5e2aUhVW3eQYAziNE0uiGwNyVBVczGqe2XUH+bnXjtguDKOaim8t7EIIp5XoaaciG+5NAic X-Received: by 2002:a62:35c2:: with SMTP id c185-v6mr23926559pfa.82.1542646227362; Mon, 19 Nov 2018 08:50:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542646227; cv=none; d=google.com; s=arc-20160816; b=QXqEEZr93VUrSK135jtaBtsE4Gt4avrvUHpvzXa8EqikVqu15CxX8kLpHhGHqE/nDE axbca/8hriHe/wIv3vH4Wrs/I+9K84HzRYXcTiQCThgY9+Zb8WxTwrrPaQcB1OmYI/39 L0t8OxhUmtiSxlc9sC25AHhEnmzXhtKXxT83fRcTGPc/4UKTt8oGsAdWnDsmmL7TWHDJ Yf6CRLDP4WltMCthRHkBPF0Ms4aMPoG9tVHvgNbllXFVr9nEPA/uNAvj20VmEk6st3Lu 8jHmELtH7jx87xMOzwYsxzCwx/dhc891a9iV5FQoSyMGPuWn5LQMmf+oj2UvFJQ2rD/V wOLQ== 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=huhkLJp0ncOa7t6ggOfQ1PPwMM6gr/b3Jr+oPenZ9JA=; b=FZuNqjJ1rB1mEJB79oKlWjM7yQoDEr496z+JwfEQwSnRi2ew3orGOGfJCzj0si2z2i hdGP5NF28dEL6upbVkNUtMpYHPcMs+5RGqvxfPutQ4ZPt3GjToLl2vWTAXlxAfj4TFYN NFNdh4NKYCgam1NqJJU9g3gL+fctxLAG14ehiC/7ZHUFJrIJks5mazxkCbdtIvuDfM4e +hS3TQbUOSwl39FBFxR+R7ruGLO8ZzW/bRFQRMGVhh9ZvJQQ4sT+LlhiYxqN9f9QUtPu 3Y9NMPYHjRnJC2dQbcoeLOgAt0b0uA9Wk+U1m+j56EgKrDQxOqJhrQFPmdsW9CumQuYZ zz1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hv8EPJkk; 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 v75si3941060pfd.157.2018.11.19.08.50.11; Mon, 19 Nov 2018 08:50:27 -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=hv8EPJkk; 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 S2389774AbeKTDNo (ORCPT + 99 others); Mon, 19 Nov 2018 22:13:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:50612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388931AbeKTDNn (ORCPT ); Mon, 19 Nov 2018 22:13:43 -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 16886206BA; Mon, 19 Nov 2018 16:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542646170; bh=dy6oD/qNGFDZ/TDAiAlt8cT3bxPoveEbwCb/BvjR2hQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hv8EPJkkULFega9+hGURMZVKDh66zSIF1ldlgv10ugX0pJEx+hI9CCT9kb7/Y2dzO jxtEtFsD72rJ59Blpg0zj10qR87ZwIFn0AeWrZU210f3yfzQFnDz1/cYkhEZAzJQEU E+Avbiw6bxP5wMqNZIF+tPvRGoGuiEqRESW8f7dY= 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.14 062/124] of, numa: Validate some distance map rules Date: Mon, 19 Nov 2018 17:28:36 +0100 Message-Id: <20181119162625.467356259@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162612.951907286@linuxfoundation.org> References: <20181119162612.951907286@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.14-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)