Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp866299imm; Fri, 3 Aug 2018 13:01:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcCjlqpFuKqWqJ7eBQMlLhlbr8rTekL2VKYk5y7OKI9NTTXsA6gjR2FESHC3Eg38d8fa80N X-Received: by 2002:a62:9d14:: with SMTP id i20-v6mr6073472pfd.3.1533326492689; Fri, 03 Aug 2018 13:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533326492; cv=none; d=google.com; s=arc-20160816; b=XgcPwuEtDBs08Pam5SMwdJSTexQEQnspuFoooOdb0k74Pd8zFcAcIuV4uh6g+kA+fY hwk2ADdHkYkj8139eEV1PfvfJjG45WQxsnas4PUoYRO2jI2c4ZFPpqBAtQKmXPL9cocq ITxANR5+Dnzils7DFFXri+Wcn/JjDfxphHv4IPhWOgGzPoI6Emi2tpem4ZfU9f1DHzdT e8psUrha4R3L/V9MpLpOpdqTQMteUUhubNv6j0SNzVUKU8xRud2JIYG/OLgLbfAjgkGo tckrMj0cNjHX8Gg4gUDZ3qB79TwGzEDSa9xhQvotYTCwaQNFvXXYBNITUCxEbMnnj551 BNvA== 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=1Lwv9g8aD6fP5UVKIGt8ZBz/0ontqJZ5QSPhDfAGISc=; b=eaES4CfjUlyCZIcjYC2IQ4e0EpRpvyTUVRuDB4jVknAACeYz9x6bHOguod6MJL7qLZ epcpv49U2RmCY+D3qhP5AVrNKV7/ME3htUXTdqn6/tGfSAVmd8ZMtZacEL3VrHptQuH2 SMLpmS3fq3XbIf0vd3cwr5inZKxNSdFJUYD7yqT80gOWP66mHcJkbEIAbjoLOza7iHPQ +vwj5o+5ua1yWVxM84q6I2xVNmkEeGiFl5lcb5/VrIOLDJvNkL0BOzoMQ5bI220+pmTv m7Kvr1didqVC5l0jiNw2gFlgOHsks/pyLJSmBX8I38V/S2bNTH2m5xRsK8gsGjfH3Uol xOlA== 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 m30-v6si4839613pgc.361.2018.08.03.13.01.17; Fri, 03 Aug 2018 13:01:32 -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 S1732150AbeHCV4y (ORCPT + 99 others); Fri, 3 Aug 2018 17:56:54 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57388 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732100AbeHCV4x (ORCPT ); Fri, 3 Aug 2018 17:56:53 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w73Jx4P4116395 for ; Fri, 3 Aug 2018 15:59:08 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2kmshah7wf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 03 Aug 2018 15:59:07 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 3 Aug 2018 20:59:06 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) 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) Fri, 3 Aug 2018 20:59:01 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w73Jx1GB41484482 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Aug 2018 19:59:01 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9BB8B42042; Fri, 3 Aug 2018 22:59:11 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D0E24203F; Fri, 3 Aug 2018 22:59:09 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.204.91]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Fri, 3 Aug 2018 22:59:09 +0100 (BST) Received: by rapoport-lnx (sSMTP sendmail emulation); Fri, 03 Aug 2018 22:58:58 +0300 From: Mike Rapoport To: Andrew Morton Cc: Richard Kuo , Ley Foon Tan , Richard Weinberger , Guan Xuetao , Michal Hocko , linux-hexagon@vger.kernel.org, nios2-dev@lists.rocketboards.org, linux-um@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport Subject: [PATCH 2/7] of: ignore sub-page memory regions Date: Fri, 3 Aug 2018 22:58:45 +0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533326330-31677-1-git-send-email-rppt@linux.vnet.ibm.com> References: <1533326330-31677-1-git-send-email-rppt@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18080319-0028-0000-0000-000002E51BB9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18080319-0029-0000-0000-0000239D33E2 Message-Id: <1533326330-31677-3-git-send-email-rppt@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-03_08:,, 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-1807170000 definitions=main-1808030216 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 Reviewed-by: Rob Herring --- 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