Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp804075imm; Wed, 4 Jul 2018 06:19:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeKGZ3Ox95VA/NoD68nmE3Ar5CyeBqWcgvPj6OrPd1fB48m9z3PPt8zfhpTZCHKk4jRIb26 X-Received: by 2002:a17:902:76c4:: with SMTP id j4-v6mr2098975plt.19.1530710368641; Wed, 04 Jul 2018 06:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530710368; cv=none; d=google.com; s=arc-20160816; b=TnJjKI9VI89NAaxjtgdvNubEdzsZveOB6f9akPb+LGf7QOI7e0e4sYMOYDECQMJT9n nWvt4ENaPuq2JsQ9C8L94JMYLnQbGKWZLFzkULffhPWDChm6bJD9rDYxHfP8DdrL3n8W O4CyGPEFQPiZaJe3F4xh8sYIlDDnTfDZBttyUVisgosUakak/J0JDWZQT9pwqo7F2b/4 tFCDxuRBW/hsrNpDCjysTkeqEX7NfAeNebG9IYbXWeVvVa66nUwi4g/AB/LoYW+vNfNY PB7LApjKS6Be0q4GMYPGyMBkpaH5Bux7H5rxPkVyusdEEriTIj1G+F7B9ALXxY6JNydQ mWjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=1Y1449rGesiQt9zXydOvgcPzmSSvQavBm4gBTNTW63M=; b=K4hPM9iFs685P8FKT0dJ2U9/EEe+JuDEnUbms5U6m0r5oRG9bg/JE6FjMmaSq2kE9D g4MQg3VnA7D+qiEwDMF1USPPKoI7e5oqUOgUj97BXeRp7OMtq+/kh0IKMKGLIP7zUk/k iQt5q2bMOtv/GiZVFWRfjuyvfgHpV6tRXk7rtAejt3aB6f8Qf6d9ZdOw6y0Y0poI7U2J MWIk7XcY4QC+8qMmHJ4QFx06mBpo3O1J22mLISzVTD7gbE47/9yNuqf/M4XQORcdH6dp i49sIBPt/EFDJSc9GRbqTeOztxxP5FPWAIspFtR4VbrNYRyjzzP74rjYawoitwnL3pFj XI6A== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13-v6si3358159pga.413.2018.07.04.06.19.13; Wed, 04 Jul 2018 06:19:28 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753469AbeGDNS3 (ORCPT + 99 others); Wed, 4 Jul 2018 09:18:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50762 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753207AbeGDNS0 (ORCPT ); Wed, 4 Jul 2018 09:18:26 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w64DA5st049436 for ; Wed, 4 Jul 2018 09:18:26 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2k0w2ed6xy-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 04 Jul 2018 09:18:26 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 4 Jul 2018 14:18:24 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 4 Jul 2018 14:18:21 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w64DIKkW30277830 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Jul 2018 13:18:20 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D3D805204F; Wed, 4 Jul 2018 16:18:45 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.8.160]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 41A0A5204E; Wed, 4 Jul 2018 16:18:44 +0100 (BST) Received: by rapoport-lnx (sSMTP sendmail emulation); Wed, 04 Jul 2018 16:18:18 +0300 From: Mike Rapoport To: Ley Foon Tan Cc: Rob Herring , Frank Rowand , Michal Hocko , nios2-dev@lists.rocketboards.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport Subject: [PATCH 1/3] of: ignore sub-page memory regions Date: Wed, 4 Jul 2018 16:18:13 +0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530710295-10774-1-git-send-email-rppt@linux.vnet.ibm.com> References: <1530710295-10774-1-git-send-email-rppt@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070413-0028-0000-0000-000002D822C7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070413-0029-0000-0000-0000238FAA64 Message-Id: <1530710295-10774-2-git-send-email-rppt@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-04_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807040152 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Memory region size is rounded down to page boundary and with sub-page region it becomes 0 and there is no point to add an empty region. Moreover, when the base is less than PAGE_SIZE we get a bogus size as (base + size - 1) evaluates to -1. The commit 8cccffc52694 ("of: check for size < 0 after rounding in early_init_dt_add_memory_arch") introduced a test for wrap around for the case when base is not page aligned, the same test can be used to ignore sub-page region sizes. Signed-off-by: Mike Rapoport --- drivers/of/fdt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 6da20b9..e866745 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -1134,12 +1134,13 @@ void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) { const u64 phys_offset = MIN_MEMBLOCK_ADDR; + if (size < PAGE_SIZE - (base & ~PAGE_MASK)) { + pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", + base, base + size); + return; + } + if (!PAGE_ALIGNED(base)) { - if (size < PAGE_SIZE - (base & ~PAGE_MASK)) { - pr_warn("Ignoring memory block 0x%llx - 0x%llx\n", - base, base + size); - return; - } size -= PAGE_SIZE - (base & ~PAGE_MASK); base = PAGE_ALIGN(base); } -- 2.7.4