From patchwork Fri Sep 30 07:50:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 12995030 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 BEF25C433F5 for ; Fri, 30 Sep 2022 07:50:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.414057.658123 (Exim 4.92) (envelope-from ) id 1oeAnF-0001Uv-BU; Fri, 30 Sep 2022 07:50:45 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 414057.658123; Fri, 30 Sep 2022 07:50:45 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oeAnF-0001Un-8g; Fri, 30 Sep 2022 07:50:45 +0000 Received: by outflank-mailman (input) for mailman id 414057; Fri, 30 Sep 2022 07:50:44 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oeAnE-0001Uh-Eu for xen-devel@lists.xenproject.org; Fri, 30 Sep 2022 07:50:44 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130053.outbound.protection.outlook.com [40.107.13.53]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 95c4e5a6-4094-11ed-964a-05401a9f4f97; Fri, 30 Sep 2022 09:50:43 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS4PR04MB9314.eurprd04.prod.outlook.com (2603:10a6:20b:4e5::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.19; Fri, 30 Sep 2022 07:50:41 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2459:15ae:e6cb:218a]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2459:15ae:e6cb:218a%7]) with mapi id 15.20.5676.023; Fri, 30 Sep 2022 07:50:41 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 95c4e5a6-4094-11ed-964a-05401a9f4f97 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XMnNtvO6FeD5ShvoaBrPOg5sVvAIJMKK3V9n6nIW0etyeqr9SN8kg7sV/sI49/nBOeY+FSYZatzIKAcYPIdm7uRNVuhqID+mYpnZcl6EVK1tlhVl22Cbu9x+cffBEmYAvkVkz6V5LqOyROBF5f6uBPIVhSbs0+1mZhq0c1a+bqKG5R+4tzC8mV+B6awfap9cXrSvgYqI5DSSFi49eRDbkoOaKdIHwMiDAMnaVWe4Fr/zgnfJPuGhfCkHOU8HCsGmkXPGtkLhgzB6q3ilKczuWNiePSUEXOh+OcOoiv3qeVCqcIE2747FfhsKl4JenLBR7UAOTZsrEGVJs6fMSfhzMg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=NCZxGTOUES+JAZXxkpQ5pJdIxnnVHQ/0Tkkf2ZdiNJI=; b=QeB6H93h070IAd2C1LdnQozW4GCeY41Nen+kqPXnH+b1cJfp9wLCsItiyZA5NeMNCCXsowmidgkV5oHOYU4EJnNf4mcmYXdB4aROX8VvejPjV/1qgEN7aMbKunMBunCJLiRW+u63x7RUxS47QD+R+yw0SVDGRexL0KVK1aoqOpTUx+oMKpqYjm7iWN5FtZfU/3SZWH7eT3+OAQ5YaF54JFtcATVrgyWq9KzSIyG9X+kjVaZ0v7+KnLzXhk2aH2SKzbElbMOUUrXCc6h9aBO0ydjH3ClGhyoASJP6B6ZuubjaJRx78ndMJCSPm/fjs1Y7fbgirr0OPLySt5+i3xzmgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NCZxGTOUES+JAZXxkpQ5pJdIxnnVHQ/0Tkkf2ZdiNJI=; b=y0DR18OzL9/2LuQlfEMzVJCpdqnqOGvbKcgqsoo27Bb22BfU64cal0oUbtCv3YzujsfSCOEM2iQMJqgBa/br/ucmtOUgYsuEOoWqsn+sRoB8GrdpfzP6Z2ZL5iA5aw+UY+MNlalqRWyNFEaiyIZM/2/wB6ZCMrzS0iKRi3nvF8CRvT9+jcOBnGi3IgKcTfN+kFUDKUMLj9bOPT8PKISdQr/M8bnZAG/cKy865HKBxa0VCMEBkqrYG4QmLC8c4n1Nma8imorYVEDrMCuCWU3gm/HHL+TdKuPqSoX9TPmuPX6xofxrPjRb6LD/qExsvqzLYlLf/s0QAjNpHGDgpfFnfw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Fri, 30 Sep 2022 09:50:40 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Content-Language: en-US To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Julien Grall , Stefano Stabellini , Volodymyr Babchuk , Bertrand Marquis , Henry Wang From: Jan Beulich Subject: [PATCH][4.17] EFI: don't convert memory marked for runtime use to ordinary RAM X-ClientProxiedBy: FR3P281CA0083.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::21) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS4PR04MB9314:EE_ X-MS-Office365-Filtering-Correlation-Id: d868520f-6d78-42eb-b8b1-08daa2b878bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q/W4TAiQ/nS9ULjd2lCh3472Tsnl59oPrbi4VUvK3MLkjf1oYQIe6i8f/RAnLTicxYcJ2rBwfkxiFzcxs4Ng4KJQvUBiwfJ/FEfiiYWpjdy/wMZuxkFEMnfoq9W7kMBNNN/2l7aYUHh63xyggUp0I8bkUHYtpaQFvJ+wEkZimZXOZnISE5i35nC/TOlgEmxOKaKl1dAoknFkUuLf1LJrX6D51cXYhh2FlmoJT6wl8NtbJy3qmbL24T/r3nQaW91dqUWhqNuWTJYlkaCtkxD1l51tB5BaS+aJIgtaVfMNmWN4llhKjPdvU6MfbpjnTidgRGdatGMuAogWrYMvwhlNdLu+8vfhBPDcHMcrx48dLMkkxqfDDZXE7vsqY9Zxrs3eBw1SG2zL/s+9q0Up83AR0u8BwCHphvALchFPBX2+OSPW8FHn949MTscGI8BQv6C3pP5PX72VRado3xa9EXDAhzr5yLOnn6QqcmFOwp8+ZYxfg2I42Uo0fAIphq1/i5q7AKJk1wzFlyQIxMZZPJV9LHhiZ3uDsHOqfsw8vWCG0COWnr3jXrBtbWOeWkWhkSjRTCN+/u7dlLL4RnEboxP4aH91RFLjWnxTk+5aoLHG6pD8JJcmiQD/4q+RUH/f5mgqb1nIx60rZ6pmfoLqmRl5u1qORH1J9O+DojI34EhzzWdCS+oXrC3LJ6No8hacqjDAquHlWOfPzCQFxIlm52hOXOJgA1M1+Dj4ZI68gGJCWxQbfbw7/Nl9/i84AhgTFxMV0A4RdU4TS+4MB7mXrDZWDS5aEVD4HdF1VkDdo0ltROc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR04MB6560.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(366004)(136003)(396003)(346002)(376002)(39860400002)(451199015)(36756003)(54906003)(6916009)(86362001)(31686004)(31696002)(38100700002)(2616005)(5660300002)(83380400001)(2906002)(478600001)(6512007)(316002)(8676002)(186003)(66946007)(4326008)(6486002)(6506007)(66556008)(66476007)(8936002)(41300700001)(26005)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?fhOIkq0NeNCuiSdC5zB9oiPUwyeQ?= =?utf-8?q?wRvw45K1ixeQbABkus3coyzuXngV2AYld0wKX+Y6kLL3Xab5RMXvvn7/7yoQMqPSQ?= =?utf-8?q?cts0l2ug2yqhKbMG8npzM6JLlHTJ5aHg7GHJaX/uf+X7LwC8mBtTFrxDojaB+6BAK?= =?utf-8?q?lIfKciszvPIVBCsZ/LX9zoct7MtOdjKSY09ABAtrlubwTCblX+GwQRQy3FEvkzN1r?= =?utf-8?q?rHw+8T8c3VuBZqLkBkhORurStZ9ipWImfmJKM6DDU0nTGRDkijnUP5CDY8xNmR4fv?= =?utf-8?q?LD5VdJ6jeD/WbEm2r5y2SJd1vvYtNU8sbFkwegGAso6CTEi9cDALRxnp5xPOINfQN?= =?utf-8?q?4TU8mxn2dIoDjT+YLBzPZqoUt6+LHtPz7BL7CtUPYhPXwjX0MF3PpYEklZ9uObOIJ?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-8?q?nLxYJd2nAt8y4ARcwYQbR22j1BBTxLw9LsHiNUoc//Wxen4SiIPqp5Bw0iv/V3wBV?= =?utf-8?q?I3kSm3lwmj4SsCUZtCH3VsVgPl+nP91SKp36SmWsgjJd3qJ8TkCTl8upAU0WQJG35?= =?utf-8?q?OxMHl30hisxj5kKA6LGMP2XxQwd1qFFFo3MjgUDLQE+eXtmnzY4Iul5vqkGvF1Xdg?= =?utf-8?q?nGlQV5SdBXtPjBR9172lnY9sOJqaAk5esGplslQnaVkr9Jdny0WXNnqjK94Zk6LIE?= =?utf-8?q?vWK92Pn6+e0g?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: d868520f-6d78-42eb-b8b1-08daa2b878bc X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Sep 2022 07:50:41.1068 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: N0w6Nq7u/BzLdqyY/gLQJaClzPriz9WFQxv7RDWmvfz5pgfTI96fMPqzfPWXwbyR4voLXSpsKovz4qf+GBEd8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9314 efi_init_memory() in both relevant places is treating EFI_MEMORY_RUNTIME higher priority than the type of the range. To avoid accessing memory at runtime which was re-used for other purposes, make efi_arch_process_memory_map() follow suit. While on x86 in theory the same would apply to EfiACPIReclaimMemory, we don't actually "reclaim" E820_ACPI memory there and hence that type's handling can be left alone. Fixes: bf6501a62e80 ("x86-64: EFI boot code") Fixes: facac0af87ef ("x86-64: EFI runtime code") Fixes: 6d70ea10d49f ("Add ARM EFI boot support") Signed-off-by: Jan Beulich Reviewed-by: Luca Fancellu Tested-By: Luca Fancellu Reviewed-by: Bertrand Marquis #arm --- Partly RFC for Arm, for two reasons: On Arm I question the conversion of EfiACPIReclaimMemory, in two ways: For one like on x86 such ranges would likely better be retained, as Dom0 may (will?) have a need to look at tables placed there. Plus converting such ranges to RAM even if EFI_MEMORY_WB is not set looks suspicious to me as well. I'd be inclined to make the latter adjustment right here (while the other change probably would better be separate, if there aren't actually reasons for the present behavior). On Arm efi_init_memory() is compiled out, so adjusting Arm code here is perhaps more for consistency (not leaving a trap for someone to later fall into) than a strict requirement. I wonder though how Arm has managed to get away without at least some parts of efi_init_memory() for all the years that ACPI support has been present there. I guess this is connected to most of runtime.c also being compiled out, but that continuing to be the case is another aspect puzzling me. --- a/xen/arch/arm/efi/efi-boot.h +++ b/xen/arch/arm/efi/efi-boot.h @@ -183,13 +183,15 @@ static EFI_STATUS __init efi_process_mem for ( Index = 0; Index < (mmap_size / desc_size); Index++ ) { - if ( desc_ptr->Attribute & EFI_MEMORY_WB && - (desc_ptr->Type == EfiConventionalMemory || - desc_ptr->Type == EfiLoaderCode || - desc_ptr->Type == EfiLoaderData || - (!map_bs && - (desc_ptr->Type == EfiBootServicesCode || - desc_ptr->Type == EfiBootServicesData))) ) + if ( desc_ptr->Attribute & EFI_MEMORY_RUNTIME ) + /* nothing */; + else if ( (desc_ptr->Attribute & EFI_MEMORY_WB) && + (desc_ptr->Type == EfiConventionalMemory || + desc_ptr->Type == EfiLoaderCode || + desc_ptr->Type == EfiLoaderData || + (!map_bs && + (desc_ptr->Type == EfiBootServicesCode || + desc_ptr->Type == EfiBootServicesData))) ) { if ( !meminfo_add_bank(&bootinfo.mem, desc_ptr) ) { --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -185,7 +185,9 @@ static void __init efi_arch_process_memo /* fall through */ case EfiLoaderCode: case EfiLoaderData: - if ( desc->Attribute & EFI_MEMORY_WB ) + if ( desc->Attribute & EFI_MEMORY_RUNTIME ) + type = E820_RESERVED; + else if ( desc->Attribute & EFI_MEMORY_WB ) type = E820_RAM; else case EfiUnusableMemory: