Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2957488imu; Mon, 19 Nov 2018 08:36:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/UdsMM1o2i9aljdlWL0KdbEARS17KSD8mVYtjNWp0ImC7SFyux3gAtSqPmgG5ZzQgqMP+2P X-Received: by 2002:a63:5455:: with SMTP id e21mr1793245pgm.316.1542645409749; Mon, 19 Nov 2018 08:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542645409; cv=none; d=google.com; s=arc-20160816; b=AmvB17ORIcKEdA76hXUxEQFodb5ATeDf19Sjq0UAi5f2OF0lu70vg5tML7tm93DN5v VLMdhrWHv9o0Ktx5KU9Fqja3Q3gfmUr7Ro8ae6L2ZHDfvtZTVsuv8o4SYSuSJHf6fD5U 6rhrfMCAU3cLG2dbkwk6T81uWR2CiCgItVxBIlYEby4Y6rJ1jne1LtnSrISeRSuKxNJo E/yImN4souVe/3Tzek1NleOAxu5qMZ7pAR9ApnNKL3dQ7d+fbopUua4eJ6ibRNCEv5hU GvP8xmFhaPXhnLuBQuYQIXqfBe5TYezoddfmcRmnCR1GEUatOKBo0SvgA0Myli+nKrKS wYdw== 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=Z1cXc+k5lUzD5SS5chbnwXf7xtiWf2XF+Fy7nNCZCBA=; b=W+s9KiAfvzaw1oHCzY4PxEfFeCYwWfWk0aTPx4fB4KTbEDR65sI+30xA4GpmK/qhJy XWuzz81juLVIqQgK7Wa0xJv7Gd5S7nQlt1hbV2wPgNblnMvuurTJoPuzwd12l7XO76DL DJl9oFEKR3tkSWkMuaotKtM+oL/FG8y1GX6Ux9RJ53aGaaAyasBTMLd2HrW8ItRQFi3v yKf3aPF+dz/y4wUjtHXJuAnRFK/frRjLfkpXMZU31cSBnIYWe7R3xnKHcjQcDbrHbXC/ syu1KxDuibj16DOOK4LHyq+vBYfJKeKLOoIPYuJEWcBIwx1VXMqMcmIeVphigE5bBVbW rLrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ChlacaAe; 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 c191si24276248pfg.72.2018.11.19.08.36.34; Mon, 19 Nov 2018 08:36:49 -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=ChlacaAe; 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 S1731600AbeKTC7V (ORCPT + 99 others); Mon, 19 Nov 2018 21:59:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:58718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730350AbeKTC7U (ORCPT ); Mon, 19 Nov 2018 21:59:20 -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 84F8920C01; Mon, 19 Nov 2018 16:35:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542645312; bh=r0cNOc/Jn3Ob5GI1E5d4h0ufTq1gQ6OMrns43VRVIO8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ChlacaAeImikqbC63OPpPNAJuGnNNCaT1af1xC7s5FFmUxpRMnxMlDXH7b8x/pW0s QOQlLD/iLUDWCdwNjxnxsJo5fkmPTjBS4a3CX5QLWyseWS4xvBJB8I1wLIhX/i9G6t T1M1Wa9rN2mTb0ozMU3uiexowF3kHVcpRXz1QeoY= 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.19 117/205] of, numa: Validate some distance map rules Date: Mon, 19 Nov 2018 17:27:04 +0100 Message-Id: <20181119162635.575209689@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181119162616.586062722@linuxfoundation.org> References: <20181119162616.586062722@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.19-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 @@ -115,9 +115,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)