Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3882703pxu; Tue, 20 Oct 2020 03:04:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySO7EZwvtgs9llgK/7EAtijJOFLykpZv2Z/+fnbEMMzQzmk5gCYb91E7GKH2hlQDhNYIit X-Received: by 2002:a17:907:43c3:: with SMTP id i3mr2160470ejs.231.1603188255751; Tue, 20 Oct 2020 03:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603188255; cv=none; d=google.com; s=arc-20160816; b=rzGcJBxXVhiYRXZeVlz+MJN29hY5ax3MDS9F/KT8GD8WW7/8TXp6QqVdMFEgRwseNt 9w0ovx18oRDnxPIKGgyctbSXCTNBzovvWJpjl/aWx1Uzj2WsyWPlyFrzsEA2gDnSaDej 8RIucxC/IXtjrOLBB17KtZsqBCOWXySUJuMFpoOxTl0fC4KXwLnoXsdbVQBaBTYfaYaI qfYjPaGZGySqs7mZHFAGJ58bvq2EczSvvePziPizVlX8xJGxneyUWgrfeEP6cKWZnZQ0 rKqNbop0ldNC7luILDYwM84Vx4iA7EzGbPSviJpKXi1P+UqzCwwUDQmTCNS8w7ziavhS +cZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:dkim-signature; bh=D4vkQ2GJkx4mZuE7nm2B26D07QpN2qJtMInPupz2+oY=; b=kX6hKARjoVho0DQzovirmWb1GTSUI0WUKdH2goIHH19uP18E4JqnoZkkI1XtWIQerj X4i6g/aKD3TC7VnqbVRnZ0+NYac++D5yc/l8o4bOasS/Eg8q33JutA5fALa+pdCbaOOM vPJNf3Qc2iS2CHE1maBthazr6TtFVLlsDvfiv5VGBa/3JNZAfeIvbWsx8QdUWPZq+XzJ 7y1rI4P1vOEWwtU5NOVvYoB1mye5CAkz2RnT58y4bbjLB2v0JLq/pMHNQyUbv4OlFC0r HscFh+1CFW41qRz4xCiaIaMtJWG16wkf6OkFt9CxIO97X4VLo/cEpRFL0kZdlbSN1DVy BVQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=H0SR2qBn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t18si850141eje.652.2020.10.20.03.03.54; Tue, 20 Oct 2020 03:04:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=H0SR2qBn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731728AbgJTHn3 (ORCPT + 99 others); Tue, 20 Oct 2020 03:43:29 -0400 Received: from smtp2.axis.com ([195.60.68.18]:37444 "EHLO smtp2.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727427AbgJTHn3 (ORCPT ); Tue, 20 Oct 2020 03:43:29 -0400 X-Greylist: delayed 429 seconds by postgrey-1.27 at vger.kernel.org; Tue, 20 Oct 2020 03:43:28 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; l=1193; q=dns/txt; s=axis-central1; t=1603179809; x=1634715809; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=D4vkQ2GJkx4mZuE7nm2B26D07QpN2qJtMInPupz2+oY=; b=H0SR2qBn1vfh6Pjj7e7l62rSfGC/EvqknjGZksoxOwIlQ6tMrrFV2oSr qSBUeTNsBOqu1mxIX8d0u+xI75Yi2rXHQlJ7jPt1WWhY01g+QMfl+YrgX orCLtuNkfvHMCQ0Wykb/oYITOoqrvmVTU3tkrF2KlS+lo4fRTT9Y/AZAi VVJlzmY05wxIStkI9WRR7pTXHvgGf3f3lWNsWzJcZSC+X7IORh+yPsZwo rzPWiOhMGn3/K6/OPdJU+2BGMGaldD5l8VEgWZOzK6nXCjJJxY5IG8mkf kWQs+3/ql3luEOOj+jb7d8Gop2XL06Xwh6rC3aUOakI5smcLePgUaqoEA Q==; IronPort-SDR: Lh6NH79QCoUKUcdCH31XtFEYddz0YmPBa9xPR1adP+/FgrHLqanAVZSGbDjZA4DRW/qLkPwj+9 5ML2FsDCl9R882Zir4hXxQNwnyO4lBRoZ25dUNxRvuVIUirB+pZkRXAaECACPyacKg+apS/+kX rt0V/4XQnMTMjO2dsQxp6LfeWHOR2j+E3J8sjOUfufLEpnU095bdSHkig88/cC6g8r8ckk0eLS qlWRbTN3QzQ2bdk1+efD9+S49FPcj9v4b2g7fnCVDSnWtFRzaYkJ9EqHGHcqAmPBbouEv2eLo2 tM8= X-IronPort-AV: E=Sophos;i="5.77,396,1596492000"; d="scan'208";a="13696999" From: Vincent Whitchurch To: Rob Herring , Frank Rowand CC: , , Vincent Whitchurch , , Subject: [PATCH] of: Fix reserved-memory overlap detection Date: Tue, 20 Oct 2020 09:35:58 +0200 Message-ID: <20201020073558.3582-1-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The reserved-memory overlap detection code fails to detect overlaps if either of the regions starts at address 0x0. For some reason the code explicitly checks for and ignores such regions, but this check looks invalid. Remove the check and fix this detection. For example, no overlap is currently reported for this case: foo@0 { reg = <0x0000 0x2000>; }; bar@1000 { reg = <0x1000 0x1000>; }; but it is after this patch: OF: reserved mem: OVERLAP DETECTED! foo@0 (0x00000000--0x00002000) overlaps with bar@1000 (0x00001000--0x00002000) Signed-off-by: Vincent Whitchurch --- drivers/of/of_reserved_mem.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 46b9371c8a33..1c5259e3e81f 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -217,8 +217,7 @@ static void __init __rmem_check_for_overlap(void) this = &reserved_mem[i]; next = &reserved_mem[i + 1]; - if (!(this->base && next->base)) - continue; + if (this->base + this->size > next->base) { phys_addr_t this_end, next_end; -- 2.28.0