Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1256308iog; Tue, 14 Jun 2022 02:26:42 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vrHuX0S6L+DqrM8zfgvuVZbkgJ5bKWeQwWDxMaR2j5IIkKfFypbkzKBP7s4D1NqC2fs2pf X-Received: by 2002:a17:902:dac5:b0:164:13b2:4916 with SMTP id q5-20020a170902dac500b0016413b24916mr3550652plx.32.1655198801999; Tue, 14 Jun 2022 02:26:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655198801; cv=none; d=google.com; s=arc-20160816; b=BavXf7EvvN5j5tLwoEbwavZTtvIVihHQdnUnOtfjsIAXwF0rGKbVvo4dXbs7a+RjSC aM1JSkOc18RqO4vRQZW8eK+rZX8XreFuZvlXy6tr7MbiSX4/jWbQFSyIzxrdU/TIg3Sf bLXjuyJ0/sF9lpd7tj6k4Ql5qFm9gcNCkXh4eoxvzCJ0LCxe47YmYjUXpP5NUG9zGk7y ID371asGPf5E2khlGJODmoiBG7rwQ0VghuVBI/F+o972vXbTxSFlWNyV2+BrlvdG3bzj kUwDfF3df3f0iSWLr41qNc7xYwYBplAQJ/wq/+T7mkrz6E9zbYo3D6BHhHAO48UdYhBx Xjbg== 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 :message-id:date:subject:cc:to:from; bh=xrE+Qez03zPZPwSXuEXyIBHv7uqyIWLfuDcyj31Dzrk=; b=qmGuVQFPIV6PAcvvBK4QtSF8hmFYqu7aOARs+S9HhBjifNnhQDFNs2tvayxQdLkAEc V4ahXgA2KRczOtxPZzkooExemEzyjQC/r8B7xLXmtFUQziOAz/n/4rVGfyEel/RRTtLq nL6pYIlbT76HX4jLWfl42KB7rZGialm1mI7duz8f/VsYyjGWhw3h0mqmdfPYHL4tukwQ AuumJQL7IkXnhtBWaGAZRi1l90E18oR5996zMcQtSmafxs9wTvg+1aKpnOPg59WCnpn4 g1MT2gwg8sYKlost6fMmGj18CopeMbEYRwYCUObhrDdj4EAmdqETLrOlBOXV59CD8cN0 3RgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q66-20020a632a45000000b004051d97d38asi11865702pgq.438.2022.06.14.02.26.30; Tue, 14 Jun 2022 02:26:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242175AbiFNJBJ (ORCPT + 99 others); Tue, 14 Jun 2022 05:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241913AbiFNJBI (ORCPT ); Tue, 14 Jun 2022 05:01:08 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3CD827B37; Tue, 14 Jun 2022 02:01:06 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LMj4q5qWfzRhtq; Tue, 14 Jun 2022 16:57:47 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 14 Jun 2022 17:00:35 +0800 Received: from localhost.localdomain (10.175.112.125) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 14 Jun 2022 17:00:33 +0800 From: Wupeng Ma To: , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v5 0/5] introduce mirrored memory support for arm64 Date: Tue, 14 Jun 2022 17:21:51 +0800 Message-ID: <20220614092156.1972846-1-mawupeng1@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ma Wupeng Commit b05b9f5f9dcf ("x86, mirror: x86 enabling - find mirrored memory ranges") introduced mirrored memory support for x86. This support rely on UEFI to report mirrored memory address ranges. See UEFI 2.5 spec pages 157-158: http://www.uefi.org/sites/default/files/resources/UEFI%202_5.pdf Memory mirroring is a technique used to separate memory into two separate channels, usually on a memory device, like a server. In memory mirroring, one channel is copied to another to create redundancy. This method makes input/output (I/O) registers and memory appear with more than one address range because the same physical byte is accessible at more than one address. Using memory mirroring, higher memory reliability and a higher level of memory consolidation are possible. These EFI memory regions have various attributes, and the "mirrored" attribute is one of them. The physical memory region whose descriptors in EFI memory map has EFI_MEMORY_MORE_RELIABLE attribute (bit: 16) are mirrored. The address range mirroring feature of the kernel arranges such mirrored regions into normal zones and other regions into movable zones. Arm64 can support this too. So mirrored memory support is added to support arm64. The main purpose of this patch set is to introduce mirrored support for arm64 and we have already fixed the problems we had which is shown in patch #5 to patch #8 and try to bring total isolation in patch #9 which will disable mirror feature if kernelcore is not specified. In order to test this support in arm64: - patch this patch set - add kernelcore=mirror in kernel parameter - start you kernel Patch #1 introduce mirrored memory support form arm64. Patch #2-#4 fix some bugs for arm64 if memory reliable is enabled. Patch #5 disable mirror feature if kernelcore is not specified. Thanks to Ard Biesheuvel's hard work [1], now kernel will perfer mirrored memory if kaslr is enabled. [1] https://lore.kernel.org/linux-arm-kernel/CAMj1kXEPVEzMgOM4+Yj6PxHA-jFuDOAUdDJSiSxy_XaP4P7LSw@mail.gmail.com/T/ Changelog since v4: - merge the first two patches into one - change __initdata to __initdata_memblock in patch #5 Changelog since v3: - limit warning message in vmemmap_verify via pr_warn_once() - only clear memblock_nomap flags rather than bring the mirrored flag back - disable mirrored feature in memblock_mark_mirror() Changelog since v2: - remove efi_fake_mem support - remove Commit ("remove some redundant code in ia64 efi_init") since efi_print_memmap() is not public - add mirror flag back on initrd memory Changelog since v1: - update changelog in cover letter - use PHYS_PFN in patch #7 Ma Wupeng (5): efi: arm64: Introduce ability to find mirrored memory ranges mm: Ratelimited mirrored memory related warning messages mm: Limit warning message in vmemmap_verify() to once arm64: mm: Only remove nomap flag for initrd memblock: Disable mirror feature if kernelcore is not specified arch/arm64/mm/init.c | 2 +- arch/x86/include/asm/efi.h | 4 ---- arch/x86/platform/efi/efi.c | 23 ----------------------- drivers/firmware/efi/efi-init.c | 1 + drivers/firmware/efi/efi.c | 23 +++++++++++++++++++++++ include/linux/efi.h | 3 +++ mm/internal.h | 2 ++ mm/memblock.c | 7 +++++-- mm/page_alloc.c | 2 +- mm/sparse-vmemmap.c | 2 +- 10 files changed, 37 insertions(+), 32 deletions(-) -- 2.25.1