From patchwork Tue Jan 14 23:31:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 11332965 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 65B5413A0 for ; Tue, 14 Jan 2020 23:33:12 +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 42063222C3 for ; Tue, 14 Jan 2020 23:33:12 +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="Gsv2SsH5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 42063222C3 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 1irVfE-0006xh-23; Tue, 14 Jan 2020 23:32:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1irVfC-0006xb-7A for xen-devel@lists.xenproject.org; Tue, 14 Jan 2020 23:31:58 +0000 X-Inumbo-ID: 0e3e1d5c-3726-11ea-b89f-bc764e2007e4 Received: from mail.kernel.org (unknown [198.145.29.99]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0e3e1d5c-3726-11ea-b89f-bc764e2007e4; Tue, 14 Jan 2020 23:31:57 +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 146B924679; Tue, 14 Jan 2020 23:31:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579044717; bh=4rf87aTkKhOyWrEcDfzAHBn6Y486BEPHFJPLZ/NZjd0=; h=From:To:Cc:Subject:Date:From; b=Gsv2SsH5XOfSqvietm/QWMg0nG/hKfk6coQTqsMav5bSvrukKJzPg/Grh+A8ZEZs9 Dgt2VTkHyN3YqlglciLrzUSRZIp/mlWNv9Qnsv9cvobCsmVnZZm4ef8GHcHx9sS+/e 3mplmyZ2bcjU+JBhspWpl/FkiFqPuZWepx8MDl04= From: Stefano Stabellini To: xen-devel@lists.xenproject.org Date: Tue, 14 Jan 2020 15:31:55 -0800 Message-Id: <20200114233155.26411-1-sstabellini@kernel.org> X-Mailer: git-send-email 2.17.1 Subject: [Xen-devel] [PATCH v2] 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 v5.5-rc6 and makes more memory reusable as normal memory by Xen (except that Linux also reuses EFI_PERSISTENT_MEMORY, which we do not). Specifically, this patch also reuses memory marked as EfiLoaderCode/Data, and it uses both Attribute and Type for the check (Attribute needs to be EFI_MEMORY_WB). Reported-by: Roman Shaposhnik Signed-off-by: Stefano Stabellini CC: Julien Grall Acked-by: Julien Grall --- Changes in v2: - improve commit message - do not allocate memory marked as EFI_PERSISTENT_MEMORY - do not change map_bs' behavior --- xen/arch/arm/efi/efi-boot.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h index d7bf934077..6527cb0bdf 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 || + (!map_bs && + (desc_ptr->Type == EfiBootServicesCode || + desc_ptr->Type == EfiBootServicesData))) ) { if ( !meminfo_add_bank(&bootinfo.mem, desc_ptr) ) {