From patchwork Mon Jun 18 14:08:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 930933 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 418YNB0nkzz9s2t for ; Tue, 19 Jun 2018 00:27:53 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 9FBFCC21EE8; Mon, 18 Jun 2018 14:21:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id A7BBFC21EFF; Mon, 18 Jun 2018 14:21:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4CD78C21EFF; Mon, 18 Jun 2018 14:09:57 +0000 (UTC) Received: from mail-ot0-f201.google.com (mail-ot0-f201.google.com [74.125.82.201]) by lists.denx.de (Postfix) with ESMTPS id 30DA4C21EC2 for ; Mon, 18 Jun 2018 14:09:54 +0000 (UTC) Received: by mail-ot0-f201.google.com with SMTP id p12-v6so10163473oti.6 for ; Mon, 18 Jun 2018 07:09:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=4aKriWbdjkssW15Q/i87EyWwepJhqjjF4/OyKD7krh4=; b=hhNTPttyep+csD7f3Yy++c8++vpFVUFSdoGFAEf0p0fq9fRTaePQABM4qhIDnbi7Pf MErp2bZuiTbv3GWOy4MrCHzfrEpw0eGVC6Ug6cxYACr6Z3oTfOVzG13EghnKcHGbueMG ujZsmdWqqp7tU6MQq6LQ7Mlcy3iO696SvcpU9Sq2DToVWncYCxT1k7nFUQEn6ckj3AZN 1mGSdBfJCzCgFxoNoc8wxzwnnVzEOSVwbJ2Fg8FRbO+Q8RYYDpur1jfK3gMRwCrmVda+ wSzoF4oPnAFZo9OqYWniYwgpWRhlG83+F/Xclk2Kcgxqj1ZXrG8p7lq8ciLDxTJPFuzU amvQ== X-Gm-Message-State: APt69E1OFLkGkuFm6iYWr6ghep6aTHqIb9vT/PAT8FUoaCC0Wx1pQOPe 9LRuCOrs+rBk6tYrIBzU8+vDiUk= X-Google-Smtp-Source: ADUXVKLgXKVLvg2pbRCgck/Xbe4GZrCsqJmNzWRkmveP4buM6B6g/lp5nEN4ppCirhAq4h1TVDkNASU= MIME-Version: 1.0 X-Received: by 2002:aca:d682:: with SMTP id n124-v6mr5918004oig.64.1529330993138; Mon, 18 Jun 2018 07:09:53 -0700 (PDT) Date: Mon, 18 Jun 2018 08:08:30 -0600 In-Reply-To: <20180618140835.195901-1-sjg@chromium.org> Message-Id: <20180618140835.195901-26-sjg@chromium.org> References: <20180618140835.195901-1-sjg@chromium.org> X-Mailer: git-send-email 2.18.0.rc1.244.gcf134e6275-goog From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Heinrich Schuchardt , Alexander Graf Subject: [U-Boot] [PATCH v8 25/30] efi: Add more debugging for memory allocations X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add some more verbose debugging when doing memory allocations. This might help to find bugs later. Signed-off-by: Simon Glass Reviewed-by: Alexander Graf --- Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v4: None Changes in v3: None Changes in v2: None lib/efi_loader/efi_boottime.c | 18 ++++++++++++++++++ lib/efi_loader/efi_memory.c | 22 +++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index aefafc3fba..2a41eb13aa 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -315,8 +315,12 @@ static efi_status_t EFIAPI efi_allocate_pages_ext(int type, int memory_type, map_to_sysmem((void *)(uintptr_t)*memory); else addr = 0; + debug(" input ptr %lx, addr %lx\n", (unsigned long)*memory, + (unsigned long)addr); r = efi_allocate_pages(type, memory_type, pages, &addr); *memory = (uintptr_t)map_sysmem(addr, pages << EFI_PAGE_SHIFT); + debug("* output addr %lx, ptr %lx\n", (unsigned long)addr, + (unsigned long)*memory); return EFI_EXIT(r); } @@ -364,11 +368,25 @@ static efi_status_t EFIAPI efi_get_memory_map_ext( uint32_t *descriptor_version) { efi_status_t r; + int i, entries; EFI_ENTRY("%p, %p, %p, %p, %p", memory_map_size, memory_map, map_key, descriptor_size, descriptor_version); r = efi_get_memory_map(memory_map_size, memory_map, map_key, descriptor_size, descriptor_version); + entries = *memory_map_size / sizeof(struct efi_mem_desc); + debug(" memory_map_size=%zx (%lx entries)\n", *memory_map_size, + (ulong)(*memory_map_size / sizeof(struct efi_mem_desc))); + if (memory_map) { + for (i = 0; i < entries; i++) { + struct efi_mem_desc *desc = &memory_map[i]; + + debug(" type %d, phys %lx, virt %lx, num_pages %lx, attribute %lx\n", + desc->type, (ulong)desc->physical_start, + (ulong)desc->virtual_start, + (ulong)desc->num_pages, (ulong)desc->attribute); + } + } return EFI_EXIT(r); } diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index ad61b723e6..856caa4a40 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -149,6 +149,24 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map, return EFI_CARVE_LOOP_AGAIN; } +static void efi_mem_print(const char *name) +{ + struct list_head *lhandle; + + debug(" %s: memory map\n", name); + list_for_each(lhandle, &efi_mem) { + struct efi_mem_list *lmem = list_entry(lhandle, + struct efi_mem_list, link); + struct efi_mem_desc *desc = &lmem->desc; + + debug(" type %d, phys %lx, virt %lx, num_pages %lx, attribute %lx\n", + desc->type, (ulong)desc->physical_start, + (ulong)desc->virtual_start, (ulong)desc->num_pages, + (ulong)desc->attribute); + } + debug("\n"); +} + uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, bool overlap_only_ram) { @@ -237,6 +255,7 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, /* And make sure memory is listed in descending order */ efi_mem_sort(); + efi_mem_print(__func__); return start; } @@ -453,7 +472,8 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size, map_entries++; map_size = map_entries * sizeof(struct efi_mem_desc); - + debug("%s: map_size %lx, provided_map_size %lx\n", __func__, + (ulong)map_size, (ulong)provided_map_size); *memory_map_size = map_size; if (provided_map_size < map_size)