From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 476F9C07E99 for ; Mon, 12 Jul 2021 10:05:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F949610FA for ; Mon, 12 Jul 2021 10:05:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234690AbhGLKIY (ORCPT ); Mon, 12 Jul 2021 06:08:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60696 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231153AbhGLKIK (ORCPT ); Mon, 12 Jul 2021 06:08:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626084321; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X19mW+ZyTd9qQRM8Dsor2I88r2OdnUUiSY5B7Ckj4fA=; b=TC9upR1o6n+sS/lAMVp8OggsNCcj9gjPcnBE9lECEsKF8apQI1euv3aQhD9JwqA0/lZuEb /5CIrh09zUtKCY7CoFk3+QOWmgsAEq2TaasbNxhkgkbQ0YmfdOR2WKPbj9/WUYRFPUYcd7 F0L/365lOsX1D/jDJY10Obzoq8S26go= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-181-IY5gXIXyOcO9Ju-VHPa1jg-1; Mon, 12 Jul 2021 06:05:18 -0400 X-MC-Unique: IY5gXIXyOcO9Ju-VHPa1jg-1 Received: by mail-wr1-f71.google.com with SMTP id j6-20020adff5460000b029013c7749ad05so4599263wrp.8 for ; Mon, 12 Jul 2021 03:05:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=X19mW+ZyTd9qQRM8Dsor2I88r2OdnUUiSY5B7Ckj4fA=; b=HiCgISGfdl+O256Hw4q2hYeYN3Bu7NyNjgC460SL2ukxLuhwQboGfSJsj0YMcoSH7C DUYk2YSrIB6hqBQPAZpEy6F+yBReFSQXkkaGN3YrgKM7iX+drL3fHL2Z2UB9QUmCxl/D xsJWrQucOQtAAxdgS/bhhLNT8WP4EuuFYQ6WmMFad6DhuZBi/nV6U+xsqMMsQ19/WFAc Sys6ZgNL7O58HweuxplGDdPE93ioEiFpbRNeHGrUn8e169ljXDUzIITede7REtFoP1ut QVZ4x4UU5Bq/7pVWRPuy3m+ME1uWWXT83QlYUdggYb+qqYOwf7dIWyjD2y4l+Z0oND0a 84CA== X-Gm-Message-State: AOAM533PCp3+eG4s7PZZO5rvjAgLwIJMLLOszP3DpflY9slFK1zR7X3s pl4x8wKLhbPt+CarC6YZSdUfIEsWGZLmLmKCBi7rS43io5OHTxgfEInfAJEdtcHKZM8S6B7iSIa KlI13S2tBOwBHYtBQiHonQEfQAIvIUn1DckWw28RRXfUJJxoQvH4uo5ectIFdUfD5+rqAmSdW X-Received: by 2002:a7b:c7cb:: with SMTP id z11mr6527305wmk.102.1626084316952; Mon, 12 Jul 2021 03:05:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrXPeiamMLpTXMwJ301Lg2JUMHHqWIMLI5c5Sqw48VV42Z0KzUHpIcgWfFLtHjCHir8DNoUQ== X-Received: by 2002:a7b:c7cb:: with SMTP id z11mr6527281wmk.102.1626084316738; Mon, 12 Jul 2021 03:05:16 -0700 (PDT) Received: from ?IPv6:2003:d8:2f0a:7f00:fad7:3bc9:69d:31f? (p200300d82f0a7f00fad73bc9069d031f.dip0.t-ipconnect.de. [2003:d8:2f0a:7f00:fad7:3bc9:69d:31f]) by smtp.gmail.com with ESMTPSA id h10sm14373933wmb.46.2021.07.12.03.05.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 12 Jul 2021 03:05:16 -0700 (PDT) Subject: Re: [PATCH] memblock: make for_each_mem_range() traverse MEMBLOCK_HOTPLUG regions To: Mike Rapoport , Andrew Morton Cc: Greg Kurz , Mike Rapoport , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210712071132.20902-1-rppt@kernel.org> From: David Hildenbrand Organization: Red Hat Message-ID: <7c9bd547-5687-e9b1-817e-f7afab09afb4@redhat.com> Date: Mon, 12 Jul 2021 12:05:15 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210712071132.20902-1-rppt@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12.07.21 09:11, Mike Rapoport wrote: > From: Mike Rapoport > > Commit b10d6bca8720 ("arch, drivers: replace for_each_membock() with > for_each_mem_range()") didn't take into account that when there is > movable_node parameter in the kernel command line, for_each_mem_range() > would skip ranges marked with MEMBLOCK_HOTPLUG. > > The page table setup code in POWER uses for_each_mem_range() to create the > linear mapping of the physical memory and since the regions marked as > MEMORY_HOTPLUG are skipped, they never make it to the linear map. > > A later access to the memory in those ranges will fail: > > [ 2.271743] BUG: Unable to handle kernel data access on write at 0xc000000400000000 > [ 2.271984] Faulting instruction address: 0xc00000000008a3c0 > [ 2.272568] Oops: Kernel access of bad area, sig: 11 [#1] > [ 2.272683] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries > [ 2.273063] Modules linked in: > [ 2.273435] CPU: 0 PID: 53 Comm: kworker/u2:0 Not tainted 5.13.0 #7 > [ 2.273832] NIP: c00000000008a3c0 LR: c0000000003c1ed8 CTR: 0000000000000040 > [ 2.273918] REGS: c000000008a57770 TRAP: 0300 Not tainted (5.13.0) > [ 2.274036] MSR: 8000000002009033 CR: 84222202 XER: 20040000 > [ 2.274454] CFAR: c0000000003c1ed4 DAR: c000000400000000 DSISR: 42000000 IRQMASK: 0 > [ 2.274454] GPR00: c0000000003c1ed8 c000000008a57a10 c0000000019da700 c000000400000000 > [ 2.274454] GPR04: 0000000000000280 0000000000000180 0000000000000400 0000000000000200 > [ 2.274454] GPR08: 0000000000000100 0000000000000080 0000000000000040 0000000000000300 > [ 2.274454] GPR12: 0000000000000380 c000000001bc0000 c0000000001660c8 c000000006337e00 > [ 2.274454] GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > [ 2.274454] GPR20: 0000000040000000 0000000020000000 c000000001a81990 c000000008c30000 > [ 2.274454] GPR24: c000000008c20000 c000000001a81998 000fffffffff0000 c000000001a819a0 > [ 2.274454] GPR28: c000000001a81908 c00c000001000000 c000000008c40000 c000000008a64680 > [ 2.275520] NIP [c00000000008a3c0] clear_user_page+0x50/0x80 > [ 2.276333] LR [c0000000003c1ed8] __handle_mm_fault+0xc88/0x1910 > [ 2.276688] Call Trace: > [ 2.276839] [c000000008a57a10] [c0000000003c1e94] __handle_mm_fault+0xc44/0x1910 (unreliable) > [ 2.277142] [c000000008a57af0] [c0000000003c2c90] handle_mm_fault+0x130/0x2a0 > [ 2.277331] [c000000008a57b40] [c0000000003b5f08] __get_user_pages+0x248/0x610 > [ 2.277541] [c000000008a57c40] [c0000000003b848c] __get_user_pages_remote+0x12c/0x3e0 > [ 2.277768] [c000000008a57cd0] [c000000000473f24] get_arg_page+0x54/0xf0 > [ 2.277959] [c000000008a57d10] [c000000000474a7c] copy_string_kernel+0x11c/0x210 > [ 2.278159] [c000000008a57d80] [c00000000047663c] kernel_execve+0x16c/0x220 > [ 2.278361] [c000000008a57dd0] [c000000000166270] call_usermodehelper_exec_async+0x1b0/0x2f0 > [ 2.278543] [c000000008a57e10] [c00000000000d5ec] ret_from_kernel_thread+0x5c/0x70 > [ 2.278870] Instruction dump: > [ 2.279214] 79280fa4 79271764 79261f24 794ae8e2 7ca94214 7d683a14 7c893a14 7d893050 > [ 2.279416] 7d4903a6 60000000 60000000 60000000 <7c001fec> 7c091fec 7c081fec 7c051fec > [ 2.280193] ---[ end trace 490b8c67e6075e09 ]--- > > Making for_each_mem_range() include MEMBLOCK_HOTPLUG regions in the > traversal fixes this issue. > > Link: https://bugzilla.redhat.com/show_bug.cgi?id=1976100 > Fixes: b10d6bca8720 ("arch, drivers: replace for_each_membock() with for_each_mem_range()") > Signed-off-by: Mike Rapoport > --- > include/linux/memblock.h | 4 ++-- > mm/memblock.c | 3 ++- > 2 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/include/linux/memblock.h b/include/linux/memblock.h > index cbf46f56d105..4a53c3ca86bd 100644 > --- a/include/linux/memblock.h > +++ b/include/linux/memblock.h > @@ -209,7 +209,7 @@ static inline void __next_physmem_range(u64 *idx, struct memblock_type *type, > */ > #define for_each_mem_range(i, p_start, p_end) \ > __for_each_mem_range(i, &memblock.memory, NULL, NUMA_NO_NODE, \ > - MEMBLOCK_NONE, p_start, p_end, NULL) > + MEMBLOCK_HOTPLUG, p_start, p_end, NULL) > > /** > * for_each_mem_range_rev - reverse iterate through memblock areas from > @@ -220,7 +220,7 @@ static inline void __next_physmem_range(u64 *idx, struct memblock_type *type, > */ > #define for_each_mem_range_rev(i, p_start, p_end) \ > __for_each_mem_range_rev(i, &memblock.memory, NULL, NUMA_NO_NODE, \ > - MEMBLOCK_NONE, p_start, p_end, NULL) > + MEMBLOCK_HOTPLUG, p_start, p_end, NULL) > > /** > * for_each_reserved_mem_range - iterate over all reserved memblock areas > diff --git a/mm/memblock.c b/mm/memblock.c > index 0041ff62c584..de7b553baa50 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -947,7 +947,8 @@ static bool should_skip_region(struct memblock_type *type, > return true; > > /* skip hotpluggable memory regions if needed */ > - if (movable_node_is_enabled() && memblock_is_hotpluggable(m)) > + if (movable_node_is_enabled() && memblock_is_hotpluggable(m) && > + !(flags & MEMBLOCK_HOTPLUG)) > return true; > > /* if we want mirror memory skip non-mirror memory regions */ > > base-commit: e73f0f0ee7541171d89f2e2491130c7771ba58d3 > Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb