From patchwork Mon Jan 6 18:26:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 11319773 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20A9414DB for ; Mon, 6 Jan 2020 18:27:47 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id F1AD324676 for ; Mon, 6 Jan 2020 18:27:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="UWiQQqbY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1AD324676 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ioX5L-0003Ub-Bh; Mon, 06 Jan 2020 18:26:39 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ioX5K-0003UW-7H for xen-devel@lists.xenproject.org; Mon, 06 Jan 2020 18:26:38 +0000 X-Inumbo-ID: 1301f952-30b2-11ea-ab4f-12813bfff9fa Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1301f952-30b2-11ea-ab4f-12813bfff9fa; Mon, 06 Jan 2020 18:26:37 +0000 (UTC) Received: from sstabellini-ThinkPad-T480s.xilinx.com (c-67-164-102-47.hsd1.ca.comcast.net [67.164.102.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C48BE24676; Mon, 6 Jan 2020 18:26:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578335197; bh=NWWARxEV0s1XHYVPLrIrR8mW8V3zRq/cCBu1IzVnN1c=; h=From:To:Cc:Subject:Date:From; b=UWiQQqbYNm6Mft5Mdp4ELqXpUhmHEMmOOVMABl7hwZlbZ+5yIgytvjkKRq5V3kvBD k2B19NwMbteQmwS1qsWQOR33GsZs3FKHBdCEbVHfKNTPk6kVFQ8sSX0XfXJx4UQQ7t VrqphWor6JaRUWhla4ipHzaUQiuvx/KvYQEqk8J4= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Mon, 6 Jan 2020 10:26:20 -0800 Message-Id: <20200106182620.19505-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH] xen/arm: during efi boot, improve the check for usable memory X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: sstabellini@kernel.org, Julien Grall , Stefano Stabellini MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When booting via EFI, the EFI memory map has information about memory regions and their type. Improve the check for the type and attribute of each memory region to figure out whether it is usable memory or not. This patch brings the check on par with Linux and makes more memory reusable as normal memory by Xen. Reported-by: Roman Shaposhnik Signed-off-by: Stefano Stabellini CC: Julien Grall --- xen/arch/arm/efi/efi-boot.h | 11 +++++++---- xen/include/efi/efidef.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h index d7bf934077..5d1d526d17 100644 --- a/xen/arch/arm/efi/efi-boot.h +++ b/xen/arch/arm/efi/efi-boot.h @@ -149,10 +149,13 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR * for ( Index = 0; Index < (mmap_size / desc_size); Index++ ) { - if ( desc_ptr->Type == EfiConventionalMemory || - (!map_bs && - (desc_ptr->Type == EfiBootServicesCode || - desc_ptr->Type == EfiBootServicesData)) ) + if ( desc_ptr->Attribute & EFI_MEMORY_WB && + (desc_ptr->Type == EfiConventionalMemory || + desc_ptr->Type == EfiLoaderCode || + desc_ptr->Type == EfiLoaderData || + desc_ptr->Type == EfiPersistentMemory || + desc_ptr->Type == EfiBootServicesCode || + desc_ptr->Type == EfiBootServicesData) ) { if ( !meminfo_add_bank(&bootinfo.mem, desc_ptr) ) { diff --git a/xen/include/efi/efidef.h b/xen/include/efi/efidef.h index 86a7e111bf..f46207840f 100644 --- a/xen/include/efi/efidef.h +++ b/xen/include/efi/efidef.h @@ -147,6 +147,7 @@ typedef enum { EfiMemoryMappedIO, EfiMemoryMappedIOPortSpace, EfiPalCode, + EfiPersistentMemory, EfiMaxMemoryType } EFI_MEMORY_TYPE;