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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 17F1EC433DB for ; Fri, 29 Jan 2021 14:50:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 68B2764E03 for ; Fri, 29 Jan 2021 14:50:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68B2764E03 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DE7BC6B0005; Fri, 29 Jan 2021 09:50:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D6E686B0006; Fri, 29 Jan 2021 09:50:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C11BF6B006C; Fri, 29 Jan 2021 09:50:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0166.hostedemail.com [216.40.44.166]) by kanga.kvack.org (Postfix) with ESMTP id A3C266B0005 for ; Fri, 29 Jan 2021 09:50:56 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 5E456180AD822 for ; Fri, 29 Jan 2021 14:50:56 +0000 (UTC) X-FDA: 77759099712.30.crack96_3a04f86275a9 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 2D31A180B3C83 for ; Fri, 29 Jan 2021 14:50:56 +0000 (UTC) X-HE-Tag: crack96_3a04f86275a9 X-Filterd-Recvd-Size: 16816 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Fri, 29 Jan 2021 14:50:54 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10TEnjoC118054; Fri, 29 Jan 2021 14:50:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=guBjhbDTE/YCNfIUAeq/cJUW3Hdz5NRQwVKq8/ZweTQ=; b=gf5ULFIxnv/yBhH/Fdp7ilrCDBxS1+tdtK5S+/Eg4hZB0DXT8a6xO5/la7UQMurMnkXn 6BI9EmwRhxj+rIZTh8n3igdFz/9MGKE3D9nGsMkCCwMuz7E7axPwq3UOkQaThiOAqTjX BJucyt94dkHm8NdGwwnenOJAOuo++sxXc1AyGF3dpbr5WtiX3J41DEw3yNeHqnTxSHiB bHF1bVOHwkZWlsUGeqFnpphR0X68Bf4VqeYcdQE1+bja+WAqXb5n4U/eqkLpQ3ZIBVUA IRg3GtmEQk7YHYlBmUfjyXE6ejL5zHzCcRmmtUyKWRnN2lWy0UZ4kurNZAi6wTbbOp1q sw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 36cmf8809k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 14:50:48 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10TEohJZ117152; Fri, 29 Jan 2021 14:50:47 GMT Received: from nam02-sn1-obe.outbound.protection.outlook.com (mail-sn1nam02lp2053.outbound.protection.outlook.com [104.47.36.53]) by aserp3020.oracle.com with ESMTP id 36ceufxww4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 14:50:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DxwAAPWdDplAFFZKvWFSbnb1DC6ab+gy/Wp/zzsdo4gbA08v1+YQua1e6MIFE6DI07NoGWHiJIUnm+otvOaSqhJfPZ5zU3o0gR41Ym2RBn0kz+2LoQz/aySIsCrnkR3eTQrgPOmuklsh7ea1Oa2nmqjmAa/o5NsaAucwSqMrhILqQtC2K7cWWJ7s818PDLIo/SX8QAJm5Jzhk2uLjzFg8xgbuoOZtx6RVOwIpR6Lob+FtsP8cDWd8ZGjxuzPR47tzo5PItGRjrzuXTnaAX4HRoLaa8UhdNHc28PfXHQBPqA9B8/8jQoixb+hv/c2gKcTIeBD11IasB/N0FlRhGhrag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=guBjhbDTE/YCNfIUAeq/cJUW3Hdz5NRQwVKq8/ZweTQ=; b=NJMLRnqKhuL608I6wkSvg14G4qtHtRWk2E5hA0w+oldtzqVyYJbuzPBDyARHZUK34nXZeCYthL4ifj4zwur2ZzKnBe67RPGiLSQDhfhBstcZiG7pcFWOz5sA/y3w8nXYlH03Yjw5yhoQ5D/eszsVwedD1HuFVvddWkBItpb0OfO7w0kW3OKd7KittToEL36XyE+ck4TyJv8hzo8B4g/GRmfGTy/j4JkMFPtSpkO2L8v8WHb3DGiGfhiM8qWhzOBq0X6MNNKyY1+K+i2CyUwAUNQ8XaGHt1WPkH2EOwOnGKO4iSLqIicHuyFQFlTrhbwBa5JZ9TKxB5KO966ViNaSFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=guBjhbDTE/YCNfIUAeq/cJUW3Hdz5NRQwVKq8/ZweTQ=; b=Vp1uEaaMekjL6qbfU72hltRUi0DO/nHi7ERJEObykUMfsATKZR7mqJ5forOXCgfP6WyT9PyKNiu8lDC6vbSEyJhhPFz1aglp0mhh8ZZiQxiJPCAsYAc6H8MRWzr+bvxjNe51ELDHKjOf+rqvck61yAAgVwgFu/opkD8n2jfqb8c= Authentication-Results: namei.org; dkim=none (message not signed) header.d=none;namei.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3077.namprd10.prod.outlook.com (2603:10b6:a03:8c::12) by BYAPR10MB3493.namprd10.prod.outlook.com (2603:10b6:a03:123::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16; Fri, 29 Jan 2021 14:50:44 +0000 Received: from BYAPR10MB3077.namprd10.prod.outlook.com ([fe80::74a8:8649:e20b:d571]) by BYAPR10MB3077.namprd10.prod.outlook.com ([fe80::74a8:8649:e20b:d571%7]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 14:50:44 +0000 Subject: Re: dax alignment problem on arm64 (and other achitectures) To: Pavel Tatashin , Dan Williams Cc: David Hildenbrand , linux-mm , LKML , Sasha Levin , Tyler Hicks , Andrew Morton , Michal Hocko , Oscar Salvador , Vlastimil Babka , Joonsoo Kim , Jason Gunthorpe , Marc Zyngier , Linux ARM , Will Deacon , James Morse , James Morris References: <8c2b75fe-a3e5-8eff-7f37-5d23c7ad9742@redhat.com> From: Joao Martins Message-ID: Date: Fri, 29 Jan 2021 14:50:34 +0000 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [94.61.1.144] X-ClientProxiedBy: LNXP265CA0016.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::28) To BYAPR10MB3077.namprd10.prod.outlook.com (2603:10b6:a03:8c::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [192.168.1.67] (94.61.1.144) by LNXP265CA0016.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:5e::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16 via Frontend Transport; Fri, 29 Jan 2021 14:50:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 054f8bfc-6fce-4019-d4cd-08d8c465411c X-MS-TrafficTypeDiagnostic: BYAPR10MB3493: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2kl1xzCxH/HQKrzURdldwpHNL909EU75ZNmsHe5R1pHwdzy3gjFYhHc4ItpmU5bFVWV/kwmiJNcWl9weJzmPZYDasV0msb2yHXmgt6+VQp8TeVkAPLr3Zc/tNx5sIRs7HFRqAoHhxS42mj7BCC+P7zgPXO2vKgA2z5i2fSUeZ5U8cviY4moPN5qgjAhciRmu+GyyZ2j4lYDbfuyK1h4pW+e1aszC4WRRKV2GsaYEICeymxQTkXODHIvhz8aR5hsxP5iVK1rw3JUpsTBqhbgoJW+OElQ1J4q4MYCrQkXIyAp7hbiRgYOfbAzzfc2dDyIVk7SMOLpI8O9FU329+98IOxLswuLYh4uHEnk8drbijUy5Oah/YyolSuKQtCjAM/+wSIwULMP22ybl6ufr/iosCCo0cefxUXDu53yrsbBqB2AJRDFCjX8DTDaXn3lDKkY0FJnEoQGfxrbSDvsGhPeTp8SaIkBla6TE2Cp5x2srA+KjeuVhDx7XfM/vCF4SpOcFIkjeq4raMYj43TfG1lmYA1ex9EPmRYMHAipArSIZ3BIKBPOo6GQH5a6JvO85c3GgO3oA6cOD8fx2ZDBY5ujoww== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR10MB3077.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(396003)(376002)(346002)(39860400002)(366004)(7416002)(16576012)(16526019)(186003)(31696002)(4326008)(2906002)(8936002)(53546011)(26005)(110136005)(86362001)(54906003)(6486002)(5660300002)(956004)(6666004)(2616005)(66476007)(66946007)(8676002)(36756003)(316002)(66556008)(478600001)(83380400001)(31686004)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?UzI4ekpuSlFZTmJVdWVJais4b0JOa2hyMGJieG1QNWhMZkdZRk5ObjQ5OGor?= =?utf-8?B?MVIvTzRsUDk2cGFLYVhmazlJWEtsd3BQbi9BaExJMHVZMXB2L2NqZFVZejl1?= =?utf-8?B?d0pqTEcwQjhIOWZ2eXJyUUdTeFJRSm15T0lHZFlHWlJiMGUvdyt6dVVNaHZG?= =?utf-8?B?b251dENWVGxlQm9EY3hoeVF3SkRJS2MxeEo2ZXlua3V1SHp3cFUrL3pVMFFM?= =?utf-8?B?L3VKRFB2NVNlNDJYMC9SUWFiQ0JTcndQMnN4U2lRN2tqUUI0dGMxMXp5OTJr?= =?utf-8?B?cVBGRXl2YkpRakhKSjM3V3BkM3BkSVd1cXJkTTlTTjFUUFBrWXUvM1JxSzZk?= =?utf-8?B?bXRxaTAvak50MTRUTHNqQllHemw3bWU5UGFwNXp0bVkxSGZqZC9XSllZL1V4?= =?utf-8?B?VkhEV2ZUeHBzV0RkaHltMFcyZGUwOU90RktLUCtWUFZONmZSd3JqLzV1RlR0?= =?utf-8?B?OEFjN1loSkJBZ1pjQ1BrRXRDR2toSUdCTjhBNlZZaUlocitrUWorNENibFUz?= =?utf-8?B?NWxaT1RCdHFSMUdZSTY1c3JWSkhJWGlmb2ZhcnlsclhsbGdYbWxtdlRuVmtJ?= =?utf-8?B?cFN5VnV2V2lCK01hdGZKR0dQcllZZmE3bzBNY012alExSlFTQnl5M2MwbDRV?= =?utf-8?B?Qjc2SHFobG9VUWd6emxMcWNhSVNzR2tMdjRYNU5Vb2o3UURJRDIvT1RXZm9h?= =?utf-8?B?NDh0MEFpcThxQzM4RnNKWTQ0MVgzcHIrZjZQc3pBQjBIK083ci9NZzNKL3Ny?= =?utf-8?B?NjVHMjNJQ3BEV0tXckh4Vmo3aGhpTHhBQldHQVQ0akdMMTNMelJONTFrWnFE?= =?utf-8?B?MDRGRTBiMmxDQks1Uk5Ock9NV0NHcVpRTEl3OXRsRDZucmJBemhhd1RHd2dG?= =?utf-8?B?SlVWUzViTmwyMlZpUWt3dmxOTFBzWWtzZGE0ZjJidCtIWjlVTWZRYVNUWFZX?= =?utf-8?B?RUp6S0RYVjh1MUFsQ3NrVUJFeXRGZWdCT011ckhKdEcvRWxiSHlpVGJOanVK?= =?utf-8?B?YjVmYUVXME9UZXBWc0xFcEMxdkNVN1BPaGhTSEhCTG1YU3F1TG5BQk1HNGtZ?= =?utf-8?B?OXhMVzJJOGxMdG1tRzR5RFV6QmZTalpIYmhlTFZtZ2JlU2RpMkRaSHNWOGU2?= =?utf-8?B?SkdtLzdXOUZEQTQ1NWxDS2FDR3B3eXpXcWR6eXVKcVBwVkx0US95dDBxZFBG?= =?utf-8?B?WHRVODBiTThHN1N1aXZEWW82eUJTR1A1eXJLVTRWcG5MRFZ1UDh1clcycjc2?= =?utf-8?B?NnBoQzRuMTdZVGlUNmpNSHJMYnFyMjB0Q1NHZWRXYmFiTDVUVVRIQk1oTzNX?= =?utf-8?B?aVdOVmUvbURCbWFYOCtPS09RZE1TamVKY1AxUTB4V0NDOHpzSzY5cjFLU3Fi?= =?utf-8?B?NzQvNW5kVHIzQkR3YllvNkdzMWx1L01PdFZ4N2tzVUIrZG8zVG5DREQyLzhY?= =?utf-8?Q?3SOwodLW?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 054f8bfc-6fce-4019-d4cd-08d8c465411c X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3077.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 14:50:43.8583 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: gXjnLxTUKsylG+zqIKKf5Yy9stBRtBq44xMG72paO4F8L6vL6lHs9telv/lxC7gH9xrmFVh3WMH4u7EAvpNrZPUgXtQ0aL95ECkc8AN80Hk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3493 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9878 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 spamscore=0 malwarescore=0 phishscore=0 mlxscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101290077 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9878 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 lowpriorityscore=0 spamscore=0 clxscore=1011 adultscore=0 priorityscore=1501 impostorscore=0 phishscore=0 mlxscore=0 malwarescore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101290077 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: Hey Pavel, On 1/29/21 1:50 PM, Pavel Tatashin wrote: >> Since we last talked about this the enabling for EFI "Special Purpose" >> / Soft Reserved Memory has gone upstream and instantiates device-dax >> instances for address ranges marked with EFI_MEMORY_SP attribute. >> Critically this way of declaring device-dax removes the consideration >> of it as persistent memory and as such no metadata reservation. So, if >> you are willing to maintain the metadata external to the device (which >> seems reasonable for your environment) and have your platform firmware >> / kernel command line mark it as EFI_CONVENTIONAL_MEMORY + >> EFI_MEMORY_SP, then these reserve-free dax-devices will surface. > > Hi Dan, > > This is cool. Does it allow conversion between devdax and fsdax so DAX > aware filesystem can be installed and data can be put there to be > preserved across the reboot? > fwiw wrt to the 'preserved across kexec' part, you are going to need something conceptually similar to snippet below the scissors mark. Alternatively, we could fix kexec userspace to add conventional memory ranges (without the SP attribute part) when it sees a Soft-Reserved region. But can't tell which one is the right thing to do. At the moment, HMAT ranges (or those defined with efi_fake_mem=) aren't preserved not because of anything special with HMAT, but simply because the EFI memmap conventional ram ranges are not preserved (only runtime services). And HMAT/efi_fake_mem expects these to based on EFI memmap. ---------------->8------------------ From: Joao Martins Subject: x86/efi: add Conventional Memory ranges to runtime-map Through EFI/HMAT certain ranges are marked with Specific Purpose EFI attribute (EFI_MEMORY_SP). These ranges are usually specified in a memory descriptor of type Conventional Memory. We only ever expose regions to the runtime-map that were marked with efi_mem_reserve(). Currently these comprise the Runtime Data/Code and Boot data. Everything else gets lost, so on a kexec boot, if we had an HMAT (or efi_fake_mem= marked regions) the second kernel kexec will lose this information, and expose this memory as regular RAM. To address that, let's add the Conventional Memory ranges from the firmware EFI memory map to the runtime. kexec then picks these up on kexec load. Specifically, we save the fw memmap first, and when we enter EFI virtual mode which on x86 is the latest point where we filter the EFI memmap to construct one with only runtime services. Signed-off-by: Joao Martins --- diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 8a26e705cb06..c244da8b185d 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -663,6 +663,53 @@ static bool should_map_region(efi_memory_desc_t *md) return false; } +static void __init efi_fw_memmap_restore(void **map, int left, + int *count, int *pg_shift) +{ + struct efi_memory_map_data *data = &efi_fw_memmap; + void *fw_memmap, *new_memmap = *map; + unsigned long desc_size; + int i, nr_map; + + if (!data->phys_map) + return; + + /* create new EFI memmap */ + fw_memmap = early_memremap(data->phys_map, data->size); + if (!fw_memmap) { + return; + } + + desc_size = data->desc_size; + nr_map = data->size / desc_size; + + for (i = 0; i < nr_map; i++) { + efi_memory_desc_t *md = efi_early_memdesc_ptr(fw_memmap, + desc_size, i); + + if (md->type != EFI_CONVENTIONAL_MEMORY) + continue; + + if (left < desc_size) { + new_memmap = realloc_pages(new_memmap, *pg_shift); + if (!new_memmap) { + early_memunmap(fw_memmap, data->size); + return; + } + + left += PAGE_SIZE << *pg_shift; + (*pg_shift)++; + } + + memcpy(new_memmap + (*count * desc_size), md, desc_size); + + left -= desc_size; + (*count)++; + } + + early_memunmap(fw_memmap, data->size); +} + /* * Map the efi memory ranges of the runtime services and update new_mmap with * virtual addresses. @@ -700,6 +747,8 @@ static void * __init efi_map_regions(int *count, int *pg_shift) (*count)++; } + efi_fw_memmap_restore(&new_memmap, left, count, pg_shift); + return new_memmap; } diff --git a/drivers/firmware/efi/fake_mem.c b/drivers/firmware/efi/fake_mem.c index 6e0f34a38171..5fd075503764 100644 --- a/drivers/firmware/efi/fake_mem.c +++ b/drivers/firmware/efi/fake_mem.c @@ -19,9 +19,30 @@ #include #include "fake_mem.h" +struct efi_memory_map_data efi_fw_memmap; struct efi_mem_range efi_fake_mems[EFI_MAX_FAKEMEM]; int nr_fake_mem; +static void __init efi_fw_memmap_save(void) +{ + struct efi_memory_map_data *data = &efi_fw_memmap; + int new_nr_map = efi.memmap.nr_map; + void *new_memmap; + + if (efi_memmap_alloc(new_nr_map, data) != 0) + return; + + new_memmap = early_memremap(data->phys_map, data->size); + if (!new_memmap) { + __efi_memmap_free(data->phys_map, data->size, data->flags); + return; + } + + efi_runtime_map_copy(new_memmap, data->size); + + early_memunmap(new_memmap, data->size); +} + static int __init cmp_fake_mem(const void *x1, const void *x2) { const struct efi_mem_range *m1 = x1; @@ -68,7 +89,12 @@ void __init efi_fake_memmap(void) { int i; - if (!efi_enabled(EFI_MEMMAP) || !nr_fake_mem) + if (!efi_enabled(EFI_MEMMAP)) + return; + + efi_fw_memmap_save(); + + if (!nr_fake_mem) return; for (i = 0; i < nr_fake_mem; i++) diff --git a/include/linux/efi.h b/include/linux/efi.h index 8710f5710c1d..72803b1a7a39 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1280,4 +1280,6 @@ static inline struct efi_mokvar_table_entry *efi_mokvar_entry_find( } #endif +extern struct efi_memory_map_data efi_fw_memmap; + #endif /* _LINUX_EFI_H */