From patchwork Thu Oct 6 08:40:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13000058 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 5F0E1C433FE for ; Thu, 6 Oct 2022 08:41:11 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.416723.661387 (Exim 4.92) (envelope-from ) id 1ogMRB-0002W3-Ic; Thu, 06 Oct 2022 08:41:01 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 416723.661387; Thu, 06 Oct 2022 08:41:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1ogMRB-0002Vw-FI; Thu, 06 Oct 2022 08:41:01 +0000 Received: by outflank-mailman (input) for mailman id 416723; Thu, 06 Oct 2022 08:41:00 +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 1ogMRA-0002Vq-Il for xen-devel@lists.xenproject.org; Thu, 06 Oct 2022 08:41:00 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60043.outbound.protection.outlook.com [40.107.6.43]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 99e32e31-4552-11ed-964a-05401a9f4f97; Thu, 06 Oct 2022 10:40:59 +0200 (CEST) Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by DBAPR04MB7429.eurprd04.prod.outlook.com (2603:10a6:10:1a2::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.34; Thu, 6 Oct 2022 08:40:58 +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.034; Thu, 6 Oct 2022 08:40:58 +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: 99e32e31-4552-11ed-964a-05401a9f4f97 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hSQrbogoVk3ga0B/d42F/H87iBT10DMhFyudqRh1BHCJW94d3sPrSJyVyHa6dxLbu7nJSM4S5FyBk0bc+9c2TaTq9eg2yPWYjl475PDV6rN0fzfEHDx2h0AhCbUNt0YgoDCenlHLk9op6e0rnlhrrBwRdtRY7i+BW5N8BgxsUZ3xxVBLlmcl6Bxg6a+N+tVKGMz3lVXN18huTAy3N/iqJgYCVT6g+UiA16FHIKadpB39GUVRffQaB/n5AgYelEm6cIx0Yw+OvFLlIyk/2LZPNwoMCksIkRnUjXzhyJZV8DNEGbLlgebQWEEAhQ+nsfLn2touoQ51eV2E2aOEXblbdw== 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=KYJzW7pJsTsrG7cUmtwhu0ZLDOihzGR909f8ymBMUyw=; b=HNez0h8GEqh2P4s9sIkQlZmVJ6uCz5eTcd2DcnGvAr95oG22iUMF8vDKR+jzxmPbQRdj/DSyajof7V+l4kAirF4Ok/rJO7j35hRhaMTTk1tjGZiF2xwhEJZzDlNFaqc7IapOz02Kvr7kueh7xNRBXYwbhOaJcLs3nXKjn/GghydNGIxR/MfeDO29H3LJXimOi6RQlD6vB1AUZy0/BznsxrRky0Gsqv5JX/WNlA0UPQvDBiEuVGbJYacNCYV7wE7WU2B1jZKAPjO8x6pLXGiHRofpIAElIQ62PmE6MTFckUi4Uqj0GeyJ0klsK6oLluayatBF9WC0qgSrACKqI7/jeg== 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=KYJzW7pJsTsrG7cUmtwhu0ZLDOihzGR909f8ymBMUyw=; b=B1aZ94MoKoD0bk2QH1khEqQMkS0MiSHLGrd6Vf6ZtNXUDVV6J5vO337IfsoKEwJcVz97TIDOKZg+mgPWaaJ2XynvigHib9yr0kJ5Q9MkzJq0+wVKudUZnDpzlsKNm+M+/xMwuw3MyBGthZaAEj2ta8lnAIKk4HGD1QfXQ2tsbcK5H7afrFAzqqbEyg4GUGl7zZ5YPCIDyf77/udaZWHWxJ6OV/5BZtVJut+veFouM3gvdvQWqnKlQrBt2HX2x8YRVLCNiqZFOZ8l9+8mj4HBdQNbIvOOeVzNOlEl8z1HIdC5eQBJjgjzfWpbgrDI0dFl1YE6pGAY7fdg542PGcpwaQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: Date: Thu, 6 Oct 2022 10:40:56 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 From: Jan Beulich Subject: [PATCH v2][4.17] EFI: don't convert memory marked for runtime use to ordinary RAM 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 Content-Language: en-US X-ClientProxiedBy: FR3P281CA0151.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::12) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DBAPR04MB7429:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d07e23e-6956-493b-042d-08daa7767d82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CxVQ/fNHuW02DbY57+A8TPMt5uwbSOZl1fSQRtQPSVix0TbMfxH0DODuBKuZkaP9IQQLKcuMkvEqAwMjghhaWn22kwiSaaAQvWMyq8oZo6bWomCdTVrBhEH2hryVghXSK8BXUNR8PnMHjLdZ5raTSnOdRGQls7NHftbLOE1w3QIoRSgQ1PzfcF46/hqYYAmuFe8pES1O+0L+Zig+8za05iVlq6zVZhyKMeHla7FFQVWAHz1zBPQa/Iss6qcok5gvwaCQIyObPUZVPO56mTKJvbsbnUa2/ABvoPfGGG7Z/eiWyhvdOfLVyc+DG8rI3USMlsqEAgWKSz86x6kuItCHHPte25NvbZuU+niiQB/K/WLiT5Tx+7jxeV2zfeeEfYJ0AOXE7ljygu/Gi60hnzGOwG0F1CU9LCX9A1H9EgxHfSuXq3gTE2wTQOFdt0g5nOGUlOlz/MngxyyKGZAAkSsTPsa94UQKzu/kHxdCsayqU900seGZyp6+RLOcJlEN/h3nQKIJx5grPjFyjSpbDWnN88FX1IEVgJs3uMtBMl7X+TIzSAO8ojVeq0aBIcLjxI7PL1eewCfGru4gkQomWnaFAIfl12CfgYdSi4j0IPhAhEsELbe73Jz8erahCz8AVHVlRhDaCgtHWbrBBKLKequhfgGtcbG9pUuNuLax74w+BeE74RIkRQcaFiTuKyhaexWSjPKPv+PbrN6axUrgIUSRBTODlTTaDe4l8GEpbW0SNx+fdlIxg+T52ylMHd0n5tmyEx91Ld4G6byGPLAMehmr3iWehMFLbA52EctmejCd27U= 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)(39850400004)(136003)(346002)(396003)(376002)(451199015)(2616005)(83380400001)(38100700002)(31696002)(36756003)(186003)(86362001)(5660300002)(8936002)(6512007)(66946007)(66556008)(66476007)(41300700001)(2906002)(26005)(54906003)(478600001)(6486002)(31686004)(6506007)(316002)(4326008)(8676002)(6916009)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Tl1l9AqeWUF5DiZrWO8rQ23XB5wN?= =?utf-8?q?Oc9A9QJh2PAGs2Fm0EbxvrAU5o9K0dsiRfB9xAe7YnOFyJJ3xq70COlhdEiF48iro?= =?utf-8?q?JQFnxvWF2RkwD8FcZP+lDCXdBBRBZcuk9FR3UsPT6Uz5eni8YCg9H0u29pMuLwwHp?= =?utf-8?q?YxXMffco+zAcAvHVAdmtRxTdGRR+/AWsti8fKrJ+CXgTCV3TVUXGdUA8bngliY8RT?= =?utf-8?q?61r3oSxfQ3weBDkdaVUF0jpztI93yOtD2zEXNq3/RYMELpxFTkhfL5fqXQaFD5vCF?= =?utf-8?q?fM6kZFZQdbJPyEsK0mfDBJY6nvTAOt+nQH14shVDEF0ob24gddrz/Q+XxSvjDVAqu?= =?utf-8?q?QH5Sx2ov1QoiSge7uRlMJEfEV+bl00bJB/PLpJQ5NKNNSrne2tSvbxtVFY0AOTmPy?= =?utf-8?q?GQOnFmtnv9wgachB39u6Rla9A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Tz/TkZMVbnYnzXZWaI+5FeQGV/WDa?= =?utf-8?q?IO453M3a2kNYwgEyfK6By2ch69esKcOEGn2FiC1fmtT7gEp06KPKMyLStVyjKl6GR?= =?utf-8?q?+9EMXblD3jcIgxZCTpye0sACB8NxJKQbyxdhpIFXRz4L0+Wms0MLXcIZoJ36z3cfh?= =?utf-8?q?u84FugJWuQDe3/1zDjqiPHWI1IwumWjtea34GwqbmsvutiCb66MZQNTQUF27Dasgm?= =?utf-8?q?pxSsiyuB7TRT?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d07e23e-6956-493b-042d-08daa7767d82 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2022 08:40:58.1092 (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: gKZ7VbhggD7EILKc/qLDvHgLopJZpef1Y9NX4HGUWM7mu2xs6SBvW3axL1BBUGHmyC0Yd+tRiZPoSvVIobuzEA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR04MB7429 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 it would be a bug if the Dom0 kernel tried to do so, bypassing Xen's memory management), 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 # Arm Tested-By: Luca Fancellu # Arm Reviewed-by: Bertrand Marquis #arm Acked-by: Roger Pau Monné --- v2: Amend description. --- 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: