From patchwork Fri Aug 3 19:58:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 10555471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 570A713B4 for ; Fri, 3 Aug 2018 19:59:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46FC12C165 for ; Fri, 3 Aug 2018 19:59:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A7AE2C245; Fri, 3 Aug 2018 19:59:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A70C2C165 for ; Fri, 3 Aug 2018 19:59:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EBFEF6B0008; Fri, 3 Aug 2018 15:59:13 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E709E6B000E; Fri, 3 Aug 2018 15:59:13 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3C156B0008; Fri, 3 Aug 2018 15:59:13 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by kanga.kvack.org (Postfix) with ESMTP id 486EB6B000A for ; Fri, 3 Aug 2018 15:59:13 -0400 (EDT) Received: by mail-ed1-f72.google.com with SMTP id d5-v6so2132609edq.3 for ; Fri, 03 Aug 2018 12:59:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id; bh=1Lwv9g8aD6fP5UVKIGt8ZBz/0ontqJZ5QSPhDfAGISc=; b=Tbu0YFUKv23WtmsE0KOlFor3QqQQn+URD0NVQBhXOTnfNO7GBu4xqRLhehYSibvvvG DRduNY6wUJFzzkvnjo8ndveA++UUnk5UnzPWOXVTaXY0klzUqV9vW9AqzL4RkxXLJ83u CdmJ+JKT2z9h6/SOXWmShd68CxoNB+vCYZkEq5zzDPYgZKKODcD2TE7E9rNghRaouFfo DyVF2viUmqVfvHhNEnJYaK2/3XPJkr85g9nnZ/VmjkbcHr1PiBhC5Tc44Ynx90MU1oCk /pNMjsshrS/TGrCM9Ok2PpSyUZFr8cq18jst7WZHk1A9upVlXBLYPkEJBY33jacbEcnb zQ/Q== X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: AOUpUlE+xPDo2qVqdptkQNk64LuE40ont87ZLJMbYqmtsA8Y1+nZCYE1 S8E+ayCU/QYzoRJo+kx2b95nwWKjiI/vXzJcI8msEGZqsj++jGoY6VdgIl9h08vy3Fh9aZWVa4F 16K9EkHHYJ2+SzQ+uBoCtjoMFA02c5hi/SzAWdVnEPJZwDRo+ItCqJOtUUBAg1nY= X-Received: by 2002:a50:fa82:: with SMTP id w2-v6mr8766842edr.256.1533326352689; Fri, 03 Aug 2018 12:59:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfLmKHQVt8UtCuLve7KEbo4T2HD+UBZabUbR38VxyMKAe04YaUPF9YDmTRRn5kAa/gVngBE X-Received: by 2002:a50:fa82:: with SMTP id w2-v6mr8766808edr.256.1533326351797; Fri, 03 Aug 2018 12:59:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533326351; cv=none; d=google.com; s=arc-20160816; b=aWVVR4Cim4jh7pFuVPULIUxOeZ95Y1qdts4fh9tWzCT4Gwa3pajcScFVxalIf8pQ22 Wu6hbYAY/eK7D72vI9UCCVljFYsHTziake8z+iMv4nwbYDqUqcNrMNNQtYXyiE7d6poO Bavz5wTuyDTHn1RwxyYDnsrODuTEHh/+mFGgl3fYhXHyDG/MmLbAy6/ovHorkp+nVttY ePcTTgLgicgDSSiG2Pk4eciq3P/1AFnlc6N0OFc3OW2RnnCEIbkH5bAsNWG3ZzhnJi7Y rbgY+dkPvOpuQF6q8m9YfFNjko3CzsCFpz0k9ALOa7VdgJM/nTIvqSFj5fi84jJ58LU7 XOUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from :arc-authentication-results; bh=1Lwv9g8aD6fP5UVKIGt8ZBz/0ontqJZ5QSPhDfAGISc=; b=PRqU9lfrR9nNMLfTHFGbM3OY+vvkbM4I18MBNYqgfvwnFcP0dnSkHL1LpYNiIRdYiY So7/qKFxDDLdX9ddMUEE5EwNNjANlyV8ww09pDtM3EpAs1X9xdG1oZmOVb4U08PLaBsg rJC9SonzLu7P6Hud5bA0tbzr47G+OO8Sgcg17P22mjHGWYz+asvtMlC7+wrxDJ1Vab8X +ubkD1pJs7nIjkF0xYK7JN/uU9k54qkPC4eJ3Z0WoW0vrbiSOCsjCAGKs30GJ7+qCf2d 5bN3KQDAAnv1s6qbaQCc7JXGLT5R0zLsAbuImCEaQByEqzH7TZ0KYeNm5oFNRmKys1Vp a2EA== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id b40-v6si5262418edf.140.2018.08.03.12.59.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Aug 2018 12:59:11 -0700 (PDT) Received-SPF: neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w73Jx6BE076469 for ; Fri, 3 Aug 2018 15:59:09 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kmu30necd-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 03 Aug 2018 15:59:09 -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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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); }