From patchwork Wed Oct 22 04:18:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 39240 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 02BEC202DB for ; Wed, 22 Oct 2014 04:21:06 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id d1sf143301wiv.2 for ; Tue, 21 Oct 2014 21:21:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:list-id:list-unsubscribe:list-post:list-help :list-subscribe:mime-version:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive :content-type:content-transfer-encoding; bh=HZj2Wf2Eqq/RGoGRw37VB42dbSVoQq2OrXZu7Ktocqc=; b=cQJFc8y6839lwCec44iRAdidWvyCeRHD2kCMb+84hYi+QdcvwqjjphbwpEjTjmUPQ8 ottcLnf45jhj9vqdXByLF9LfSwXy06zodX2ZCSXSbwZzJTVC5LdSFMxurBQ5Ss5EH99c OezISl4dcYYse1BFdOY9jjt4CGDcP6rHMkgDqPAVVca/sJF0DJFjdjDDW14bnazHoJVC daXfCxqBg4zGrEZn0IRVy/w4SyGdy3truLpMjZcXO60gIshtZnHLPWoIvzWaTJLOmnyI 81OJslO9SVBMeF7TrPWcCghQfnZlz3xSWSbMnqh22RsHcjm6s6wERwpO9mgn+xCyZMcK H06w== X-Gm-Message-State: ALoCoQkuq+2M5LNGUwHKMRFVOIpazl97ehkZ2HFlUOJRpJzJdefo8rPdKHyB3r9ndtJRTRBqe456 X-Received: by 10.112.147.131 with SMTP id tk3mr6020476lbb.2.1413951666087; Tue, 21 Oct 2014 21:21:06 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.174 with SMTP id p14ls114450lal.68.gmail; Tue, 21 Oct 2014 21:21:05 -0700 (PDT) X-Received: by 10.112.77.74 with SMTP id q10mr30447108lbw.66.1413951665850; Tue, 21 Oct 2014 21:21:05 -0700 (PDT) Received: from mail-la0-f43.google.com (mail-la0-f43.google.com. [209.85.215.43]) by mx.google.com with ESMTPS id y2si21691863lae.49.2014.10.21.21.21.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 Oct 2014 21:21:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) client-ip=209.85.215.43; Received: by mail-la0-f43.google.com with SMTP id mc6so2233383lab.2 for ; Tue, 21 Oct 2014 21:21:05 -0700 (PDT) X-Received: by 10.112.130.41 with SMTP id ob9mr38282407lbb.74.1413951665770; Tue, 21 Oct 2014 21:21:05 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp8576lbz; Tue, 21 Oct 2014 21:21:05 -0700 (PDT) X-Received: by 10.220.181.133 with SMTP id by5mr6057387vcb.44.1413951664642; Tue, 21 Oct 2014 21:21:04 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id b9si9647333vdw.73.2014.10.21.21.21.04 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 21 Oct 2014 21:21:04 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XgnO5-0001p9-Kq; Wed, 22 Oct 2014 04:19:05 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XgnO4-0001p4-Gk for xen-devel@lists.xen.org; Wed, 22 Oct 2014 04:19:04 +0000 Received: from [193.109.254.147:61491] by server-16.bemta-14.messagelabs.com id FC/4E-16990-73037445; Wed, 22 Oct 2014 04:19:03 +0000 X-Env-Sender: roy.franz@linaro.org X-Msg-Ref: server-2.tower-27.messagelabs.com!1413951541!11696651!1 X-Originating-IP: [209.85.213.177] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30774 invoked from network); 22 Oct 2014 04:19:03 -0000 Received: from mail-ig0-f177.google.com (HELO mail-ig0-f177.google.com) (209.85.213.177) by server-2.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 22 Oct 2014 04:19:03 -0000 Received: by mail-ig0-f177.google.com with SMTP id a13so222685igq.4 for ; Tue, 21 Oct 2014 21:19:01 -0700 (PDT) X-Received: by 10.43.2.74 with SMTP id nt10mr32322icb.68.1413951541514; Tue, 21 Oct 2014 21:19:01 -0700 (PDT) Received: from rfranz-v430.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id q20sm7087417ioe.21.2014.10.21.21.19.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Oct 2014 21:19:00 -0700 (PDT) From: Roy Franz To: xen-devel@lists.xen.org, ian.campbell@citrix.com, stefano.stabellini@citrix.com, tim@xen.org, jbeulich@suse.com Date: Tue, 21 Oct 2014 21:18:45 -0700 Message-Id: <1413951525-17657-1-git-send-email-roy.franz@linaro.org> X-Mailer: git-send-email 1.9.1 Cc: Roy Franz , fu.wei@linaro.org Subject: [Xen-devel] [PATCH for-4.5] EFI: Fix efi_arch_allocate_mmap_buffer() to return new size X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: roy.franz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.43 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: efi_arch_allocate_mmap_buffer() allocates a buffer for the EFI memory map, and for ARM it allocates a larger buffer than requested. This is done to account for the increase in the map size that may occur when the allocation is made. The previous code allocated a larger buffer, but did not adjust the size to match. This caused the later call to GetMemoryMap() to fail with a BUFFER_TOO_SMALL error, since the original, smaller size was used. This patch changes the argument to efi_arch_allocate_mmap_buffer() to be a pointer to UINTN, and the ARM version updates the size on a successful allocation. The x86 version uses a different allocation method, so only the function argument type is changed. Also add decode of the BUFFER_TOO_SMALL error code to PrintErrMesg(). Signed-off-by: Roy Franz Acked-by: Ian Campbell --- xen/arch/arm/efi/efi-boot.h | 6 ++++-- xen/arch/x86/efi/efi-boot.h | 4 ++-- xen/common/efi/boot.c | 5 ++++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h index d40d8b2..639942d 100644 --- a/xen/arch/arm/efi/efi-boot.h +++ b/xen/arch/arm/efi/efi-boot.h @@ -370,14 +370,16 @@ static void __init efi_arch_cfg_file_late(EFI_FILE_HANDLE dir_handle, char *sect { } -static void *__init efi_arch_allocate_mmap_buffer(UINTN map_size) +static void *__init efi_arch_allocate_mmap_buffer(UINTN *map_size) { void *ptr; EFI_STATUS status; + UINTN map_size_alloc = *map_size + EFI_PAGE_SIZE; - status = efi_bs->AllocatePool(EfiLoaderData, map_size + EFI_PAGE_SIZE, &ptr); + status = efi_bs->AllocatePool(EfiLoaderData, map_size_alloc, &ptr); if ( status != EFI_SUCCESS ) return NULL; + *map_size = map_size_alloc; return ptr; } diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 4348cfe..454ffb6 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -190,10 +190,10 @@ static void __init efi_arch_process_memory_map(EFI_SYSTEM_TABLE *SystemTable, } -static void *__init efi_arch_allocate_mmap_buffer(UINTN map_size) +static void *__init efi_arch_allocate_mmap_buffer(UINTN *map_size) { place_string(&mbi.mem_upper, NULL); - mbi.mem_upper -= map_size; + mbi.mem_upper -= *map_size; mbi.mem_upper &= -__alignof__(EFI_MEMORY_DESCRIPTOR); if ( mbi.mem_upper < xen_phys_start ) return NULL; diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index f272171..4257341 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -271,6 +271,9 @@ static void __init PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode) case EFI_COMPROMISED_DATA: mesg = L"Compromised data"; break; + case EFI_BUFFER_TOO_SMALL: + mesg = L"Buffer too small"; + break; default: PrintErr(L"ErrCode: "); DisplayUint(ErrCode, 0); @@ -1038,7 +1041,7 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) efi_bs->GetMemoryMap(&efi_memmap_size, NULL, &map_key, &efi_mdesc_size, &mdesc_ver); - efi_memmap = efi_arch_allocate_mmap_buffer(efi_memmap_size); + efi_memmap = efi_arch_allocate_mmap_buffer(&efi_memmap_size); if ( !efi_memmap ) blexit(L"Unable to allocate memory for EFI memory map");