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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EF70BEB64DC for ; Fri, 21 Jul 2023 10:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ijzAYroOsgMOwIj6r4CMpNxvpKhcw3+MAMCk8vJkVy8=; b=2CfD0xDQPzqcih 2hQ/PO91BfkoPTUKvziRS9i11DcueESrHaiF8bqMJ0ksFhHSo4Qs23nv2gl1yCEh5ebvgKqdIdfcG c7sbf60ZCiNPzFuK4Wutz4/8lXeHj4Y3rj+kIv9fEiaqrEs2Km9ZkshIbNTKlhi6uLFwTZCgAGIbY 7kHRtemr3S8Wv0k2UlFtRPCcZh1PGCAKCgT0eb4Q31npDTpO8t85iiQepQkmQfcfKElgbf+iScHC1 QBeSKf8uUgh5f/WRv6mNYH0zQhmL2pQwc/B6wVonhr1ifq4CA2DaVuzWUYxawSM59DdbPL1BoJq/S 4VTjlskckDeIpIsuNTCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMnV0-00DnR5-2o; Fri, 21 Jul 2023 10:36:38 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qMnUy-00DnQZ-0j for linux-arm-kernel@lists.infradead.org; Fri, 21 Jul 2023 10:36:37 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4186E61059; Fri, 21 Jul 2023 10:36:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA1F3C433C7; Fri, 21 Jul 2023 10:36:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689935794; bh=d3RDQYHBiofoLtTOsVGd0+hDYbPOksiQmmPkI1vmf0M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=L/UWsDU4VYCbs4LhUhJWB2TbtnSnTADPvw3/xdSxrWWYc5Ut5Kz0JBEQi501rF5rn Y5azfgrgwsSWJUNSm/tGZLMZBeeqhNYVZKOkaKBSv9GTlgyrWB24l//X2DK7XaEhCg udrRlLvqWmAG9oBEYFTQwpztGAbWcUkcpX3Jsxd5ta/lmAlDSS3worDmILpldn3Xko zsWZ2TzZYs1AGUQk74sSHZwVE6SZAkO5pAMlnoaumMDvefFn3MYhyE2KJxG2SzVOdA L0dKvaEZgcFneP70XGrWfgG0RXib7YeLcsBYKbTh+GmBEGXgAmvAYWFbzqDfp0u5tW S3PkKsigEKd+Q== Date: Fri, 21 Jul 2023 11:36:29 +0100 From: Will Deacon To: Wupeng Ma Cc: catalin.marinas@arm.com, akpm@linux-foundation.org, sudaraja@codeaurora.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, wangkefeng.wang@huawei.com, linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, anshuman.khandual@arm.com Subject: Re: [RFC PATCH] arm64: mm: Fix kernel page tables incorrectly deleted during memory removal Message-ID: <20230721103628.GA12601@willie-the-truck> References: <20230717115150.1806954-1-mawupeng1@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230717115150.1806954-1-mawupeng1@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230721_033636_324360_C21344A9 X-CRM114-Status: GOOD ( 21.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jul 17, 2023 at 07:51:50PM +0800, Wupeng Ma wrote: > From: Ma Wupeng > > During our test, we found that kernel page table may be unexpectedly > cleared with rodata off. The root cause is that the kernel page is > initialized with pud size(1G block mapping) while offline is memory > block size(MIN_MEMORY_BLOCK_SIZE 128M), eg, if 2G memory is hot-added, > when offline a memory block, the call trace is shown below, > > offline_and_remove_memory > try_remove_memory > arch_remove_memory > __remove_pgd_mapping > unmap_hotplug_range > unmap_hotplug_p4d_range > unmap_hotplug_pud_range > if (pud_sect(pud)) > pud_clear(pudp); Sorry, but I'm struggling to understand the problem here. If we're adding and removing a 2G memory region, why _wouldn't_ we want to use large 1GiB mappings? Or are you saying that only a subset of the memory is removed, but we then accidentally unmap the whole thing? > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 95d360805f8a..44c724ce4f70 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -44,6 +44,7 @@ > #define NO_BLOCK_MAPPINGS BIT(0) > #define NO_CONT_MAPPINGS BIT(1) > #define NO_EXEC_MAPPINGS BIT(2) /* assumes FEAT_HPDS is not used */ > +#define NO_PUD_MAPPINGS BIT(3) > > int idmap_t0sz __ro_after_init; > > @@ -344,7 +345,7 @@ static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, > */ > if (pud_sect_supported() && > ((addr | next | phys) & ~PUD_MASK) == 0 && > - (flags & NO_BLOCK_MAPPINGS) == 0) { > + (flags & (NO_BLOCK_MAPPINGS | NO_PUD_MAPPINGS)) == 0) { > pud_set_huge(pudp, phys, prot); > > /* > @@ -1305,7 +1306,7 @@ struct range arch_get_mappable_range(void) > int arch_add_memory(int nid, u64 start, u64 size, > struct mhp_params *params) > { > - int ret, flags = NO_EXEC_MAPPINGS; > + int ret, flags = NO_EXEC_MAPPINGS | NO_PUD_MAPPINGS; I think we should allow large mappings here and instead prevent partial removal of the block, if that's what is causing the issue. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel