Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2469116pxb; Mon, 19 Apr 2021 06:31:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBiJwWSMtMyD5qJtpKSUGOTRuwDwGr4rlQPn9PafvtzRdngpvim6y6KZeWi1eVcVwVTyq/ X-Received: by 2002:a50:ed0a:: with SMTP id j10mr5795035eds.22.1618839084435; Mon, 19 Apr 2021 06:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618839084; cv=none; d=google.com; s=arc-20160816; b=pZwne6X9rL+FuY4SkRd5m4ln+xMoxGZj4P8WB79O28TIvpEA/dVBfsWNJKEFUm+gzw +kpg6rpTSzqVSn5a9lPM1lydwhGGLkTqHSYlfblF5ujAZj7d0otO1FlS1YXjq/T8Q41W VZUSKUfMo6qUBxdKmKNDoVmUVa6tzXY4jFAZ3ZNl85JnQW5FZ8vYDXO//CzZviiH4u2f pUzjoVsEpIofdXZSGoGQC9l1/z4pNf0jbS1gZfMuwVaL2+nRyYAzDY5h+r5DRhGwHBl2 ZLG4aCMbOxKQrKU5AxoCgy5GMUvLGCuRJCfDdMKr/ZvO/uQzy8W+HmuT3/nrf6MGD8Hg AS5w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zPWyeV0A2VSa9IwoqwfkPLPG7RPhUG8HI2jdxVS1OT4=; b=m4iOdh7ABSoZkaR5S1Hi/nJoFgTOeyGUEZU0DNJq5qQK+10eV7Le8BLrkaCWc2mNcP KGryeMt5b5O4yzKLC/YqzlQVCL4aR5cCgCGl32p8WZ5zFyseaSpFJ65f8N33WnCUhuqw 6C2YE/SSyMiTORpPQOz1hetP7LYJ2LQs3wTT43+xTvoQG4ccvGpwgDVVIdTG1RCQv/CM 40601zrlA3WWp7eK9Cb1vUBWkVQnOCQ1jwzT0JbfM9PNvtZMxD8ChHgdAfGqhd9tDVIB u+gXagGIbzi2Q4OIV6hs2g9f8+u0qm+v1HXYocyXilvBczGF0WbrztpI7OGPyhR8F4x7 KlPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=R4qNn94y; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si10574974edr.107.2021.04.19.06.30.55; Mon, 19 Apr 2021 06:31:24 -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 header.i=@linuxfoundation.org header.s=korg header.b=R4qNn94y; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242268AbhDSN3N (ORCPT + 99 others); Mon, 19 Apr 2021 09:29:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:55300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241471AbhDSNUj (ORCPT ); Mon, 19 Apr 2021 09:20:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A5C0A613FA; Mon, 19 Apr 2021 13:17:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618838221; bh=iZf7ClmEIC7bmKfIrlNMIND01K7HbcjvZy41yZ6C9n0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R4qNn94y0iOKg0beg69IgetAnKMyZ0jwsJbL2jl/jYweDg7aWFceThNqyVEXL0SEB IWJMkPhnC05u8IoqbNqDFHDRGRje59nYlGIHp2KLU7vkJN7tX2H+/pws0Z9vDb+Uwz 4mBNxmSJKaENgHZIKjvjgRGrqbTWvPqeU5xy4lUU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Murzin , Mike Rapoport , Russell King , Sasha Levin Subject: [PATCH 5.10 087/103] ARM: 9069/1: NOMMU: Fix conversion for_each_membock() to for_each_mem_range() Date: Mon, 19 Apr 2021 15:06:38 +0200 Message-Id: <20210419130530.790986558@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130527.791982064@linuxfoundation.org> References: <20210419130527.791982064@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Murzin [ Upstream commit 45c2f70cba3a7eff34574103b2e2b901a5f771aa ] for_each_mem_range() uses a loop variable, yet looking into code it is not just iteration counter but more complex entity which encodes information about memblock. Thus condition i == 0 looks fragile. Indeed, it broke boot of R-class platforms since it never took i == 0 path (due to i was set to 1). Fix that with restoring original flag check. Fixes: b10d6bca8720 ("arch, drivers: replace for_each_membock() with for_each_mem_range()") Signed-off-by: Vladimir Murzin Acked-by: Mike Rapoport Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/mm/pmsa-v7.c | 4 +++- arch/arm/mm/pmsa-v8.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/pmsa-v7.c b/arch/arm/mm/pmsa-v7.c index 88950e41a3a9..59d916ccdf25 100644 --- a/arch/arm/mm/pmsa-v7.c +++ b/arch/arm/mm/pmsa-v7.c @@ -235,6 +235,7 @@ void __init pmsav7_adjust_lowmem_bounds(void) phys_addr_t mem_end; phys_addr_t reg_start, reg_end; unsigned int mem_max_regions; + bool first = true; int num; u64 i; @@ -263,7 +264,7 @@ void __init pmsav7_adjust_lowmem_bounds(void) #endif for_each_mem_range(i, ®_start, ®_end) { - if (i == 0) { + if (first) { phys_addr_t phys_offset = PHYS_OFFSET; /* @@ -275,6 +276,7 @@ void __init pmsav7_adjust_lowmem_bounds(void) mem_start = reg_start; mem_end = reg_end; specified_mem_size = mem_end - mem_start; + first = false; } else { /* * memblock auto merges contiguous blocks, remove diff --git a/arch/arm/mm/pmsa-v8.c b/arch/arm/mm/pmsa-v8.c index 2de019f7503e..8359748a19a1 100644 --- a/arch/arm/mm/pmsa-v8.c +++ b/arch/arm/mm/pmsa-v8.c @@ -95,10 +95,11 @@ void __init pmsav8_adjust_lowmem_bounds(void) { phys_addr_t mem_end; phys_addr_t reg_start, reg_end; + bool first = true; u64 i; for_each_mem_range(i, ®_start, ®_end) { - if (i == 0) { + if (first) { phys_addr_t phys_offset = PHYS_OFFSET; /* @@ -107,6 +108,7 @@ void __init pmsav8_adjust_lowmem_bounds(void) if (reg_start != phys_offset) panic("First memory bank must be contiguous from PHYS_OFFSET"); mem_end = reg_end; + first = false; } else { /* * memblock auto merges contiguous blocks, remove -- 2.30.2