[{"id":1769856,"web_url":"http://patchwork.ozlabs.org/comment/1769856/","msgid":"<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>","list_archive_url":null,"date":"2017-09-18T03:48:03","subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","submitter":{"id":61270,"url":"http://patchwork.ozlabs.org/api/people/61270/","name":"Heinrich Schuchardt","email":"xypron.glpk@gmx.de"},"content":"On 09/18/2017 12:59 AM, Simon Glass wrote:\n> A limitation of the EFI loader at present is that it does not build with\n> sandbox. This makes it hard to write tests, since sandbox is used for most\n> testing in U-Boot.\n> \n> This series enables the EFI loader feature. It allows sandbox to build and\n> run a trivial function which calls the EFI API to output a message.\n> \n> Much work remains but this should serve as a basis for adding tests more\n> easily for EFI loader.\n> \n> This series sits on top of Heinrich's recent EFI test series. It is\n> available at u-boot-dm/efi-working\n> \n> \n> Simon Glass (16):\n>   efi: Update efi_smbios_register() to return error code\n>   efi: Move the init check inside efi_init_obj_list()\n>   efi: Add error checking for efi_init_obj_list()\n>   efi: Add a TODO to efi_init_obj_list()\n>   efi: Correct header order in efi_memory\n>   efi: sandbox: Adjust memory setup for sandbox\n>   sandbox: smbios: Update to support sandbox\n>   sandbox: Add a setjmp() implementation\n>   efi: sandbox: Add required linker sections\n>   efi: sandbox: Add distroboot support\n>   Define board_quiesce_devices() in a shared location\n>   Add a comment for board_quiesce_devices()\n>   efi: sandbox: Add relocation constants\n>   efi: Add a comment about duplicated ELF constants\n>   efi: sandbox: Enable EFI loader builder for sandbox\n>   efi: sandbox: Add a simple 'bootefi test' command\n> \n>  arch/arm/include/asm/u-boot-arm.h |  1 -\n>  arch/sandbox/cpu/cpu.c            | 13 ++++++++++\n>  arch/sandbox/cpu/os.c             | 17 ++++++++++++\n>  arch/sandbox/cpu/u-boot.lds       | 29 +++++++++++++++++++++\n>  arch/sandbox/include/asm/setjmp.h | 21 +++++++++++++++\n>  arch/sandbox/lib/Makefile         |  2 +-\n>  arch/sandbox/lib/sections.c       | 12 +++++++++\n>  arch/x86/include/asm/u-boot-x86.h |  1 -\n>  arch/x86/lib/bootm.c              |  4 ---\n>  cmd/bootefi.c                     | 54 ++++++++++++++++++++++++++++++++++-----\n>  common/bootm.c                    |  4 +++\n>  configs/sandbox_defconfig         |  1 +\n>  include/bootm.h                   |  8 ++++++\n>  include/config_distro_bootcmd.h   |  2 +-\n>  include/efi_loader.h              | 13 ++++++++--\n>  include/os.h                      | 21 +++++++++++++++\n>  lib/efi_loader/Kconfig            | 12 ++++++++-\n>  lib/efi_loader/Makefile           |  1 +\n>  lib/efi_loader/efi_boottime.c     |  4 +++\n>  lib/efi_loader/efi_memory.c       | 33 +++++++++++++-----------\n>  lib/efi_loader/efi_runtime.c      |  7 +++++\n>  lib/efi_loader/efi_smbios.c       |  6 +++--\n>  lib/efi_loader/efi_test.c         | 17 ++++++++++++\n>  lib/smbios.c                      | 38 ++++++++++++++++++++-------\n>  24 files changed, 277 insertions(+), 44 deletions(-)\n>  create mode 100644 arch/sandbox/include/asm/setjmp.h\n>  create mode 100644 arch/sandbox/lib/sections.c\n>  create mode 100644 lib/efi_loader/efi_test.c\n> \nThanks for enabling efi_loader on sandbox. That will make many things\neasier.\n\nUnfortunately\nefi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,\n                                 struct efi_system_table *systab)\n{\n...\n        boottime = systable->boottime;\n...\n        ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,\n                                      (void **)&memory_map);\nleads to a segmentation fault:\n\n=> bootefi selftest\n\nTesting EFI API implementation\n\nNumber of tests to execute: 3\n<snip>\nSetting up 'ExitBootServices'\nSetting up 'ExitBootServices' succeeded\nSegmentation fault\nuser@workstation:~/workspace/u-boot-odroid-c2/denx$\n\nThe problem does not exist with qemu-x86_defconfig without your patches.\n\nqemu-x86_defconfig cannot be built with you patches:\n\n  UPD     include/generated/asm-offsets.h\nsh: echo: I/O error\nKbuild:47: recipe for target 'include/generated/generic-asm-offsets.h'\nfailed\nmake[1]: *** [include/generated/generic-asm-offsets.h] Error 1\nmake[1]: *** Waiting for unfinished jobs....\nMakefile:1332: recipe for target 'prepare0' failed\nmake: *** [prepare0] Error 2\n\nBest regards\n\nHeinrich","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwX8N5Dgsz9rxj\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 13:50:12 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 6FCEAC21EFC; Mon, 18 Sep 2017 03:49:57 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 4314EC21F1A;\n\tMon, 18 Sep 2017 03:49:55 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 59543C21F19; Mon, 18 Sep 2017 03:49:03 +0000 (UTC)","from mout.gmx.net (mout.gmx.net [212.227.15.19])\n\tby lists.denx.de (Postfix) with ESMTPS id 4E01BC21EFE\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 03:49:03 +0000 (UTC)","from [192.168.123.58] ([84.118.154.110]) by mail.gmx.com (mrgmx003\n\t[212.227.17.190]) with ESMTPSA (Nemesis) id\n\t0Lb5GD-1d9V4t29RB-00kfxq; Mon, 18 Sep 2017 05:48:42 +0200"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.7 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_LOW,\n\tRCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no\n\tversion=3.4.0","To":"Simon Glass <sjg@chromium.org>,\n\tU-Boot Mailing List <u-boot@lists.denx.de>","References":"<20170917225927.117917-1-sjg@chromium.org>","From":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Message-ID":"<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>","Date":"Mon, 18 Sep 2017 05:48:03 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101\n\tThunderbird/52.3.0","MIME-Version":"1.0","In-Reply-To":"<20170917225927.117917-1-sjg@chromium.org>","Content-Language":"en-US","X-Provags-ID":"V03:K0:sEzw7Ee1vg1VrI7Uk1zQyMx2Fmbwaleast8XsepMSi/9U4Ess1b\n\tlz0l0OUsGNrXU+ZWTW+ve6HBV/tcoedoU1avqEmkX+uF9wjeKzD4udd/Zrd96yXrkxU5k3w\n\t0uwexpaPYmNwpF5WeeoA4Cz/YvYNIxlCQPzvoC25t+oKTyFMm8PRgNwn3hyTC74VPB0CSL8\n\tRXiFH/cy+9bwVE2vk3acg==","X-UI-Out-Filterresults":"notjunk:1; V01:K0:UGFyNTwykJ4=:LsL2ZkRc2NbY/6OtiT3GCi\n\tgp2yboOh1meVxX8TxoZJGc9kKVcELjiO8g8jDuYib3a4h8pFfDcZLReoHd4de959S2b8mEH21\n\tv6MxR3rWJvk0SHf3C/apW4UAVkJ9x8qKSvgv1B7krXSPnBB+s9BgA52YkeIttxo7fF9Kot0Fx\n\tD9DyS9jls0DsLU8ZDQ91qan6FoQrnY6piEzINM2SzzaJer1P2uuo/SmEzZ3VnMO7Q958+QbAg\n\tgBcOTMNRRYL8ZiHCpQYpiMQSfQGCXTPoRShPAGjp6xxBoeip6RjY8hjVJlcRywguz1OjGhQeD\n\tmFxeClNLPeINxNM+eZqqgXZjpNqHPB6p7B2wvx0gw80LTeeJiB7zPj6y3vTvZ62CRtD9Zxynx\n\tlqjGca/So+8z6oVn72LrG5iNlwScukGzkBt82CZDjfXmJNVyLXrx2kewOVvIJU9oOkYYlsW2M\n\tB0ML/ZxgVgpcf+kzBgYFTpaz2/oq83/uF+9w80wwP28juHqTMzOe7ir2dAxDvG3BbK8F7Xg//\n\t21Pw+7u9OXmm4MNPqy3zDVaeBjGR9JgAX8J50BIAMRuhChq8O+vSBDA7+EJ+Nan6Sgm1AUsXi\n\t9Yz2sk2rpLE4X/ZNK+K8kJiH3oLCLBnaMjs1tgm5DxjOjJKq/wufWwJ2Eu+ieHXQCrPmmgm4e\n\tNM5XFoLqyp9DOwKlnQXqDlOW8n3czKMX3+wxKDsnWSKC9wmPvy9sCcgVejA3eIX1lUY9rSm4J\n\tYmICqYE9CysXt0K6J++gRKoFmeBzB2MK9cIa6pKvrDfkqIIqD4hBBdzww7mSESVViwEPakkqw\n\tvShmQ2nm1DwZe5Wo5VYGxDLSsx0ysoy7rj83GtR1TTdp3frj9s=","Cc":"Heinrich Schuchardt <xypron.glpk@gmx.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>","Subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1769859,"web_url":"http://patchwork.ozlabs.org/comment/1769859/","msgid":"<CAPnjgZ0mQ437s4XkP-yHAZ2cRrgbd7WXk+AFWgUFbqwadHouuQ@mail.gmail.com>","list_archive_url":null,"date":"2017-09-18T03:59:28","subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/","name":"Simon Glass","email":"sjg@chromium.org"},"content":"Hi Heinrich,\n\nOn 17 September 2017 at 21:48, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:\n> On 09/18/2017 12:59 AM, Simon Glass wrote:\n>> A limitation of the EFI loader at present is that it does not build with\n>> sandbox. This makes it hard to write tests, since sandbox is used for most\n>> testing in U-Boot.\n>>\n>> This series enables the EFI loader feature. It allows sandbox to build and\n>> run a trivial function which calls the EFI API to output a message.\n>>\n>> Much work remains but this should serve as a basis for adding tests more\n>> easily for EFI loader.\n>>\n>> This series sits on top of Heinrich's recent EFI test series. It is\n>> available at u-boot-dm/efi-working\n>>\n>>\n>> Simon Glass (16):\n>>   efi: Update efi_smbios_register() to return error code\n>>   efi: Move the init check inside efi_init_obj_list()\n>>   efi: Add error checking for efi_init_obj_list()\n>>   efi: Add a TODO to efi_init_obj_list()\n>>   efi: Correct header order in efi_memory\n>>   efi: sandbox: Adjust memory setup for sandbox\n>>   sandbox: smbios: Update to support sandbox\n>>   sandbox: Add a setjmp() implementation\n>>   efi: sandbox: Add required linker sections\n>>   efi: sandbox: Add distroboot support\n>>   Define board_quiesce_devices() in a shared location\n>>   Add a comment for board_quiesce_devices()\n>>   efi: sandbox: Add relocation constants\n>>   efi: Add a comment about duplicated ELF constants\n>>   efi: sandbox: Enable EFI loader builder for sandbox\n>>   efi: sandbox: Add a simple 'bootefi test' command\n>>\n>>  arch/arm/include/asm/u-boot-arm.h |  1 -\n>>  arch/sandbox/cpu/cpu.c            | 13 ++++++++++\n>>  arch/sandbox/cpu/os.c             | 17 ++++++++++++\n>>  arch/sandbox/cpu/u-boot.lds       | 29 +++++++++++++++++++++\n>>  arch/sandbox/include/asm/setjmp.h | 21 +++++++++++++++\n>>  arch/sandbox/lib/Makefile         |  2 +-\n>>  arch/sandbox/lib/sections.c       | 12 +++++++++\n>>  arch/x86/include/asm/u-boot-x86.h |  1 -\n>>  arch/x86/lib/bootm.c              |  4 ---\n>>  cmd/bootefi.c                     | 54 ++++++++++++++++++++++++++++++++++-----\n>>  common/bootm.c                    |  4 +++\n>>  configs/sandbox_defconfig         |  1 +\n>>  include/bootm.h                   |  8 ++++++\n>>  include/config_distro_bootcmd.h   |  2 +-\n>>  include/efi_loader.h              | 13 ++++++++--\n>>  include/os.h                      | 21 +++++++++++++++\n>>  lib/efi_loader/Kconfig            | 12 ++++++++-\n>>  lib/efi_loader/Makefile           |  1 +\n>>  lib/efi_loader/efi_boottime.c     |  4 +++\n>>  lib/efi_loader/efi_memory.c       | 33 +++++++++++++-----------\n>>  lib/efi_loader/efi_runtime.c      |  7 +++++\n>>  lib/efi_loader/efi_smbios.c       |  6 +++--\n>>  lib/efi_loader/efi_test.c         | 17 ++++++++++++\n>>  lib/smbios.c                      | 38 ++++++++++++++++++++-------\n>>  24 files changed, 277 insertions(+), 44 deletions(-)\n>>  create mode 100644 arch/sandbox/include/asm/setjmp.h\n>>  create mode 100644 arch/sandbox/lib/sections.c\n>>  create mode 100644 lib/efi_loader/efi_test.c\n>>\n> Thanks for enabling efi_loader on sandbox. That will make many things\n> easier.\n>\n> Unfortunately\n> efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,\n>                                  struct efi_system_table *systab)\n> {\n> ...\n>         boottime = systable->boottime;\n> ...\n>         ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,\n>                                       (void **)&memory_map);\n> leads to a segmentation fault:\n>\n> => bootefi selftest\n>\n> Testing EFI API implementation\n>\n> Number of tests to execute: 3\n> <snip>\n> Setting up 'ExitBootServices'\n> Setting up 'ExitBootServices' succeeded\n> Segmentation fault\n> user@workstation:~/workspace/u-boot-odroid-c2/denx$\n>\n> The problem does not exist with qemu-x86_defconfig without your patches.\n>\n> qemu-x86_defconfig cannot be built with you patches:\n>\n>   UPD     include/generated/asm-offsets.h\n> sh: echo: I/O error\n> Kbuild:47: recipe for target 'include/generated/generic-asm-offsets.h'\n> failed\n> make[1]: *** [include/generated/generic-asm-offsets.h] Error 1\n> make[1]: *** Waiting for unfinished jobs....\n> Makefile:1332: recipe for target 'prepare0' failed\n> make: *** [prepare0] Error 2\n\nAre you able to bisect this to the commit which causes the problem.\nI've had a look through and cannot figure it out my inspection.\nOtherwise I should be able to look at it on Tuesday.\n\nRegards,\nSimon","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"Jd+tAuDH\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"O+SPHGgo\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwXMl2jhZz9s7F\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 14:00:01 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid CC388C21EF4; Mon, 18 Sep 2017 03:59:54 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 33910C21D57;\n\tMon, 18 Sep 2017 03:59:52 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 195C1C21D57; Mon, 18 Sep 2017 03:59:51 +0000 (UTC)","from mail-qk0-f173.google.com (mail-qk0-f173.google.com\n\t[209.85.220.173])\n\tby lists.denx.de (Postfix) with ESMTPS id 80786C21D19\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 03:59:50 +0000 (UTC)","by mail-qk0-f173.google.com with SMTP id t184so6176170qke.10\n\tfor <u-boot@lists.denx.de>; Sun, 17 Sep 2017 20:59:50 -0700 (PDT)","by 10.200.37.200 with HTTP; Sun, 17 Sep 2017 20:59:28 -0700 (PDT)"],"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=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=20161025; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=OqkjxeHYDfAFBC9ohRrn4NuGRWPSkbrpJ7S6ovMh904=;\n\tb=Jd+tAuDHQ5ijWh5E7AntGxcIi+XAlDXPvzmmQJ8s0ZrLsXEe81y+ESGvHAUUNuI9Jm\n\t9b40D0EnXCnUGJhxANg8NjjiDt9t3O5Qg5qOft7FgVMAfKaos4Rzf2yW/5V6DbHcbT2H\n\t+qVEZY0VxqD0zxGYQASdMpdsSb8tcSulJ5Ui7A+d+vm3BSbs/OgJHaZBtuFghkFeREds\n\tduXI8AqLti3cnPw9hlW9LL7vTKw9+LsmgnoeccQvy9azU2we3Wxza0CKZQBhnpdKj8T3\n\tXdOh7ib9SVk/4ETlU87+amgntA2iBgoESaRzZI89Jbvm0GfW1jrEQSTvWjgXeZiFD+kG\n\tvT6Q==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=OqkjxeHYDfAFBC9ohRrn4NuGRWPSkbrpJ7S6ovMh904=;\n\tb=O+SPHGgohoNhOTzyP5NBZvHgIfgC67omzQEa2sBmWJTcw3Oqqz4oM74dyMPdcZAQ5v\n\tuxsE61Q6AlhCleoO5FaeTvhSZwf1NFIcZl2wI7RU7kHRXoRwrp/mmH4tRezGxFl9OlvX\n\tHgViUTJEcgMhUhyiYHrR3PpCk4d2rZvGOl64c="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:sender:in-reply-to:references:from\n\t:date:message-id:subject:to:cc;\n\tbh=OqkjxeHYDfAFBC9ohRrn4NuGRWPSkbrpJ7S6ovMh904=;\n\tb=Y1XWmnaGsjWzrB49AdKbiA9VLxCgNWzVHWX2o+4hg2ttZ3jgUR22qEDuVonU2JBBGX\n\tV0CT4ChauXf5kd2JTVeNX9OjSNJ9iyJfGm6L7Ld2tRvOpF6RvOX4IfEYdU/QIzIEp1MC\n\t8ett2lLJJxTSpA5fdFVCckIGjQak37baTkZiWYPzLIsFk2MNZYKhWOfR/NrSMkeCH196\n\tT07riw+HYjNeXIv6VG4AUXC4MF9NnoDTpNZJ4583SFVLR30jpRdDCbahHipSYXz+UARA\n\t7FMXsgumKc8HyO/JtpTHpxMbLe6gk7el3VaulyAJCY1FiX0oozI5vVVMMZ6tNVHcSg6G\n\tq4Tw==","X-Gm-Message-State":"AHPjjUhApo2DHZmx8qHokkdCe+u+JOovzH5o0BPsDtp8CDPqZaRpFrPy\n\tZbgmw/kRALtfMFftzbsl0Dw0AJ6CJR0LiyI6DR1ZRg==","X-Google-Smtp-Source":"AOwi7QAIfA3cgBRG4nVRelMVDImft131jyn70J2tW+evN7nLNtDA7MK29s434aufaCGpa90s0BCh+kYUFKrNKLNmV7s=","X-Received":"by 10.55.17.207 with SMTP id 76mr17622996qkr.178.1505707188925; \n\tSun, 17 Sep 2017 20:59:48 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>","References":"<20170917225927.117917-1-sjg@chromium.org>\n\t<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>","From":"Simon Glass <sjg@chromium.org>","Date":"Sun, 17 Sep 2017 21:59:28 -0600","X-Google-Sender-Auth":"q6dKSjUgEOnUdOisVXOCnsUvzxc","Message-ID":"<CAPnjgZ0mQ437s4XkP-yHAZ2cRrgbd7WXk+AFWgUFbqwadHouuQ@mail.gmail.com>","To":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>","Subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1770148,"web_url":"http://patchwork.ozlabs.org/comment/1770148/","msgid":"<CAF6AEGu3D40KYmsNpHr3XsihOieD_8myOVv+2kBrKxrMvKGXXQ@mail.gmail.com>","list_archive_url":null,"date":"2017-09-18T13:18:46","subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","submitter":{"id":18760,"url":"http://patchwork.ozlabs.org/api/people/18760/","name":"Rob Clark","email":"robdclark@gmail.com"},"content":"On Sun, Sep 17, 2017 at 11:48 PM, Heinrich Schuchardt\n<xypron.glpk@gmx.de> wrote:\n> On 09/18/2017 12:59 AM, Simon Glass wrote:\n>> A limitation of the EFI loader at present is that it does not build with\n>> sandbox. This makes it hard to write tests, since sandbox is used for most\n>> testing in U-Boot.\n>>\n>> This series enables the EFI loader feature. It allows sandbox to build and\n>> run a trivial function which calls the EFI API to output a message.\n>>\n>> Much work remains but this should serve as a basis for adding tests more\n>> easily for EFI loader.\n>>\n>> This series sits on top of Heinrich's recent EFI test series. It is\n>> available at u-boot-dm/efi-working\n>>\n>>\n>> Simon Glass (16):\n>>   efi: Update efi_smbios_register() to return error code\n>>   efi: Move the init check inside efi_init_obj_list()\n>>   efi: Add error checking for efi_init_obj_list()\n>>   efi: Add a TODO to efi_init_obj_list()\n>>   efi: Correct header order in efi_memory\n>>   efi: sandbox: Adjust memory setup for sandbox\n>>   sandbox: smbios: Update to support sandbox\n>>   sandbox: Add a setjmp() implementation\n>>   efi: sandbox: Add required linker sections\n>>   efi: sandbox: Add distroboot support\n>>   Define board_quiesce_devices() in a shared location\n>>   Add a comment for board_quiesce_devices()\n>>   efi: sandbox: Add relocation constants\n>>   efi: Add a comment about duplicated ELF constants\n>>   efi: sandbox: Enable EFI loader builder for sandbox\n>>   efi: sandbox: Add a simple 'bootefi test' command\n>>\n>>  arch/arm/include/asm/u-boot-arm.h |  1 -\n>>  arch/sandbox/cpu/cpu.c            | 13 ++++++++++\n>>  arch/sandbox/cpu/os.c             | 17 ++++++++++++\n>>  arch/sandbox/cpu/u-boot.lds       | 29 +++++++++++++++++++++\n>>  arch/sandbox/include/asm/setjmp.h | 21 +++++++++++++++\n>>  arch/sandbox/lib/Makefile         |  2 +-\n>>  arch/sandbox/lib/sections.c       | 12 +++++++++\n>>  arch/x86/include/asm/u-boot-x86.h |  1 -\n>>  arch/x86/lib/bootm.c              |  4 ---\n>>  cmd/bootefi.c                     | 54 ++++++++++++++++++++++++++++++++++-----\n>>  common/bootm.c                    |  4 +++\n>>  configs/sandbox_defconfig         |  1 +\n>>  include/bootm.h                   |  8 ++++++\n>>  include/config_distro_bootcmd.h   |  2 +-\n>>  include/efi_loader.h              | 13 ++++++++--\n>>  include/os.h                      | 21 +++++++++++++++\n>>  lib/efi_loader/Kconfig            | 12 ++++++++-\n>>  lib/efi_loader/Makefile           |  1 +\n>>  lib/efi_loader/efi_boottime.c     |  4 +++\n>>  lib/efi_loader/efi_memory.c       | 33 +++++++++++++-----------\n>>  lib/efi_loader/efi_runtime.c      |  7 +++++\n>>  lib/efi_loader/efi_smbios.c       |  6 +++--\n>>  lib/efi_loader/efi_test.c         | 17 ++++++++++++\n>>  lib/smbios.c                      | 38 ++++++++++++++++++++-------\n>>  24 files changed, 277 insertions(+), 44 deletions(-)\n>>  create mode 100644 arch/sandbox/include/asm/setjmp.h\n>>  create mode 100644 arch/sandbox/lib/sections.c\n>>  create mode 100644 lib/efi_loader/efi_test.c\n>>\n> Thanks for enabling efi_loader on sandbox. That will make many things\n> easier.\n>\n> Unfortunately\n> efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,\n>                                  struct efi_system_table *systab)\n> {\n> ...\n>         boottime = systable->boottime;\n> ...\n>         ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,\n>                                       (void **)&memory_map);\n> leads to a segmentation fault:\n\nI'm seeing something similar, because:\n\n(gdb) print gd->bd->bi_dram[0]\n$2 = {start = 0, size = 134217728}\n\nu-boot expects 1:1 phys:virt mapping, so that probably won't work.\n\n> => bootefi selftest\n>\n> Testing EFI API implementation\n>\n> Number of tests to execute: 3\n> <snip>\n> Setting up 'ExitBootServices'\n> Setting up 'ExitBootServices' succeeded\n> Segmentation fault\n> user@workstation:~/workspace/u-boot-odroid-c2/denx$\n>\n> The problem does not exist with qemu-x86_defconfig without your patches.\n\nfwiw, qemu-x86 still works for me (I can still load Shell.efi) with\nthese patches..\n\nBR,\n-R\n\n> qemu-x86_defconfig cannot be built with you patches:\n>\n>   UPD     include/generated/asm-offsets.h\n> sh: echo: I/O error\n> Kbuild:47: recipe for target 'include/generated/generic-asm-offsets.h'\n> failed\n> make[1]: *** [include/generated/generic-asm-offsets.h] Error 1\n> make[1]: *** Waiting for unfinished jobs....\n> Makefile:1332: recipe for target 'prepare0' failed\n> make: *** [prepare0] Error 2\n>\n> Best regards\n>\n> Heinrich","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"I8h7gbKs\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwmmj31fjz9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 23:19:00 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 304F9C21E68; Mon, 18 Sep 2017 13:18:52 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id D2BEEC21DA2;\n\tMon, 18 Sep 2017 13:18:49 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid DF336C21DA2; Mon, 18 Sep 2017 13:18:47 +0000 (UTC)","from mail-lf0-f66.google.com (mail-lf0-f66.google.com\n\t[209.85.215.66])\n\tby lists.denx.de (Postfix) with ESMTPS id 84917C21C5C\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 13:18:47 +0000 (UTC)","by mail-lf0-f66.google.com with SMTP id h80so294102lfe.1\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 06:18:47 -0700 (PDT)","by 10.46.41.75 with HTTP; Mon, 18 Sep 2017 06:18:46 -0700 (PDT)"],"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=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=6tB2NzU9agx4iW76Bsb+XKS7095fYXltS1TgLN8tjQ0=;\n\tb=I8h7gbKsDpNppLL8EF3/fz28yoj1NIZt8DRLllGAMUZQ77cmUf49FGkN47t9OJfNPD\n\tpVl0ebx7sOedaibN/cLDWcGWfkxH/hG7aoZBS7GnbyZSm27txDsj3r8AQThgxYYYfqbV\n\tursKv0xAJhM1tZ9YZBw5zOZHQPi3p3guhOahAreEVH00qcKvRtHAkRKbj32n3c9LuwDw\n\tnpVu2oDKP34aBwl17p4eKkidWU1IL8EFXW1+q9cwxAIsPwBCOtH4foyVhF9HiGkr2gGF\n\tUM0oo7Jm3mIQEIWlF+VpjOXYJUyF5F+Uk+7eVG4k2RVqKPdQTTl/ndORWJ/J6tADvyVu\n\trZEg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=6tB2NzU9agx4iW76Bsb+XKS7095fYXltS1TgLN8tjQ0=;\n\tb=VVNcwL7v329cuQQjwW6y5ugdhW0Js4261Lx8BFQnsHLTvEJ+vg/u5SgcGZjiMSxkZ/\n\t8iFQKRU68BXqQrnsaPPw73xES74l4bWZR6T6yXgjf/GbRe/zpfS8zRR+jrE4RstPtRDV\n\tQe4pLyZQjoviUVgCehfq9//OG+K9pr/xjhL+dE9bAILoa45lDi2pUgywyf2FEk5tYhQl\n\tomW6vZYLa20FZ5tTxEFKsX5maMoIMvgDs9R8JyshKxdJ11g/FyncNjbhJaEJ6eBXwQNj\n\tDuf45SVMxVvm+rcjOiFhaAgUADza89XQOUxjQrr4eu1aplofW63qrWL0uK8BXiJU+rG0\n\tzs0A==","X-Gm-Message-State":"AHPjjUhdEiyk1mD7pVzncYt5/aUGdBhWI+2RacyiPAPXsh47VCqMrR4x\n\tVoHMPo1baLC9QZ7D1177LOI1IXvQ6VyLaGbj8ys=","X-Google-Smtp-Source":"AOwi7QAp31X4RFO3WjUTGDx4uUYoAEKDHm806aS1jGO5G63ZOMdvBcoRAJriKdpVb8zzqer3GXGTZYWWtDn3hxPn+TE=","X-Received":"by 10.46.19.26 with SMTP id 26mr12933969ljt.20.1505740726836;\n\tMon, 18 Sep 2017 06:18:46 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>","References":"<20170917225927.117917-1-sjg@chromium.org>\n\t<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>","From":"Rob Clark <robdclark@gmail.com>","Date":"Mon, 18 Sep 2017 09:18:46 -0400","Message-ID":"<CAF6AEGu3D40KYmsNpHr3XsihOieD_8myOVv+2kBrKxrMvKGXXQ@mail.gmail.com>","To":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>","Subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1770160,"web_url":"http://patchwork.ozlabs.org/comment/1770160/","msgid":"<CAF6AEGvj9V5AsW=xZkAfhy51LxpgWvxHr1DMQDhiFYTDtyCMCg@mail.gmail.com>","list_archive_url":null,"date":"2017-09-18T13:31:05","subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","submitter":{"id":18760,"url":"http://patchwork.ozlabs.org/api/people/18760/","name":"Rob Clark","email":"robdclark@gmail.com"},"content":"On Mon, Sep 18, 2017 at 9:18 AM, Rob Clark <robdclark@gmail.com> wrote:\n> On Sun, Sep 17, 2017 at 11:48 PM, Heinrich Schuchardt\n> <xypron.glpk@gmx.de> wrote:\n>> On 09/18/2017 12:59 AM, Simon Glass wrote:\n>>> A limitation of the EFI loader at present is that it does not build with\n>>> sandbox. This makes it hard to write tests, since sandbox is used for most\n>>> testing in U-Boot.\n>>>\n>>> This series enables the EFI loader feature. It allows sandbox to build and\n>>> run a trivial function which calls the EFI API to output a message.\n>>>\n>>> Much work remains but this should serve as a basis for adding tests more\n>>> easily for EFI loader.\n>>>\n>>> This series sits on top of Heinrich's recent EFI test series. It is\n>>> available at u-boot-dm/efi-working\n>>>\n>>>\n>>> Simon Glass (16):\n>>>   efi: Update efi_smbios_register() to return error code\n>>>   efi: Move the init check inside efi_init_obj_list()\n>>>   efi: Add error checking for efi_init_obj_list()\n>>>   efi: Add a TODO to efi_init_obj_list()\n>>>   efi: Correct header order in efi_memory\n>>>   efi: sandbox: Adjust memory setup for sandbox\n>>>   sandbox: smbios: Update to support sandbox\n>>>   sandbox: Add a setjmp() implementation\n>>>   efi: sandbox: Add required linker sections\n>>>   efi: sandbox: Add distroboot support\n>>>   Define board_quiesce_devices() in a shared location\n>>>   Add a comment for board_quiesce_devices()\n>>>   efi: sandbox: Add relocation constants\n>>>   efi: Add a comment about duplicated ELF constants\n>>>   efi: sandbox: Enable EFI loader builder for sandbox\n>>>   efi: sandbox: Add a simple 'bootefi test' command\n>>>\n>>>  arch/arm/include/asm/u-boot-arm.h |  1 -\n>>>  arch/sandbox/cpu/cpu.c            | 13 ++++++++++\n>>>  arch/sandbox/cpu/os.c             | 17 ++++++++++++\n>>>  arch/sandbox/cpu/u-boot.lds       | 29 +++++++++++++++++++++\n>>>  arch/sandbox/include/asm/setjmp.h | 21 +++++++++++++++\n>>>  arch/sandbox/lib/Makefile         |  2 +-\n>>>  arch/sandbox/lib/sections.c       | 12 +++++++++\n>>>  arch/x86/include/asm/u-boot-x86.h |  1 -\n>>>  arch/x86/lib/bootm.c              |  4 ---\n>>>  cmd/bootefi.c                     | 54 ++++++++++++++++++++++++++++++++++-----\n>>>  common/bootm.c                    |  4 +++\n>>>  configs/sandbox_defconfig         |  1 +\n>>>  include/bootm.h                   |  8 ++++++\n>>>  include/config_distro_bootcmd.h   |  2 +-\n>>>  include/efi_loader.h              | 13 ++++++++--\n>>>  include/os.h                      | 21 +++++++++++++++\n>>>  lib/efi_loader/Kconfig            | 12 ++++++++-\n>>>  lib/efi_loader/Makefile           |  1 +\n>>>  lib/efi_loader/efi_boottime.c     |  4 +++\n>>>  lib/efi_loader/efi_memory.c       | 33 +++++++++++++-----------\n>>>  lib/efi_loader/efi_runtime.c      |  7 +++++\n>>>  lib/efi_loader/efi_smbios.c       |  6 +++--\n>>>  lib/efi_loader/efi_test.c         | 17 ++++++++++++\n>>>  lib/smbios.c                      | 38 ++++++++++++++++++++-------\n>>>  24 files changed, 277 insertions(+), 44 deletions(-)\n>>>  create mode 100644 arch/sandbox/include/asm/setjmp.h\n>>>  create mode 100644 arch/sandbox/lib/sections.c\n>>>  create mode 100644 lib/efi_loader/efi_test.c\n>>>\n>> Thanks for enabling efi_loader on sandbox. That will make many things\n>> easier.\n>>\n>> Unfortunately\n>> efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,\n>>                                  struct efi_system_table *systab)\n>> {\n>> ...\n>>         boottime = systable->boottime;\n>> ...\n>>         ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,\n>>                                       (void **)&memory_map);\n>> leads to a segmentation fault:\n>\n> I'm seeing something similar, because:\n>\n> (gdb) print gd->bd->bi_dram[0]\n> $2 = {start = 0, size = 134217728}\n>\n> u-boot expects 1:1 phys:virt mapping, so that probably won't work.\n\nThe following quick hack works.. something similar could probably be\nsmashed in to \"\"\n\n--------\ndiff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\nindex cddafe2d43..da2079a4b1 100644\n--- a/lib/efi_loader/efi_memory.c\n+++ b/lib/efi_loader/efi_memory.c\n@@ -459,9 +459,10 @@ int efi_memory_init(void)\n     unsigned long uboot_start, uboot_pages;\n     unsigned long uboot_stack_size = 16 * 1024 * 1024;\n\n-    efi_add_known_memory();\n\n     if (!IS_ENABLED(CONFIG_SANDBOX)) {\n+        efi_add_known_memory();\n+\n         /* Add U-Boot */\n         uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n                 ~EFI_PAGE_MASK;\n@@ -476,6 +477,12 @@ int efi_memory_init(void)\n         runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n         efi_add_memory_map(runtime_start, runtime_pages,\n                    EFI_RUNTIME_SERVICES_CODE, false);\n+    } else {\n+#define SZ_256M    0x10000000\n+        size_t sz = SZ_256M;\n+        void *ram = os_malloc(sz);\n+        efi_add_memory_map((uintptr_t)ram, sz >> EFI_PAGE_SHIFT,\n+                   EFI_CONVENTIONAL_MEMORY, false);\n     }\n\n #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n--------\n\nWith that I'm at least getting further..  efi_allocate_pool()\neventually fails, possibly making every small memory allocation page\naligned means that 256m isn't enough..\n\nBR,\n-R\n\n>> => bootefi selftest\n>>\n>> Testing EFI API implementation\n>>\n>> Number of tests to execute: 3\n>> <snip>\n>> Setting up 'ExitBootServices'\n>> Setting up 'ExitBootServices' succeeded\n>> Segmentation fault\n>> user@workstation:~/workspace/u-boot-odroid-c2/denx$\n>>\n>> The problem does not exist with qemu-x86_defconfig without your patches.\n>\n> fwiw, qemu-x86 still works for me (I can still load Shell.efi) with\n> these patches..\n>\n> BR,\n> -R\n>\n>> qemu-x86_defconfig cannot be built with you patches:\n>>\n>>   UPD     include/generated/asm-offsets.h\n>> sh: echo: I/O error\n>> Kbuild:47: recipe for target 'include/generated/generic-asm-offsets.h'\n>> failed\n>> make[1]: *** [include/generated/generic-asm-offsets.h] Error 1\n>> make[1]: *** Waiting for unfinished jobs....\n>> Makefile:1332: recipe for target 'prepare0' failed\n>> make: *** [prepare0] Error 2\n>>\n>> Best regards\n>>\n>> Heinrich","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"utKvO1/1\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwn2n2xpcz9s3w\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 18 Sep 2017 23:31:13 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 24D2BC21E66; Mon, 18 Sep 2017 13:31:11 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 5FA8BC21DA4;\n\tMon, 18 Sep 2017 13:31:08 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 486ADC21DA4; Mon, 18 Sep 2017 13:31:07 +0000 (UTC)","from mail-lf0-f65.google.com (mail-lf0-f65.google.com\n\t[209.85.215.65])\n\tby lists.denx.de (Postfix) with ESMTPS id D52DCC21DA2\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 13:31:06 +0000 (UTC)","by mail-lf0-f65.google.com with SMTP id y15so316592lfd.0\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 06:31:06 -0700 (PDT)","by 10.46.41.75 with HTTP; Mon, 18 Sep 2017 06:31:05 -0700 (PDT)"],"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=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=SQcgIO4/5YUjy/jHqexO6Rn/6ozaj2V78l6tHTPc6Os=;\n\tb=utKvO1/1jSAABoeXIIe1k+SAd04kAqDQALEDU29kljsSn0CjaFhMD/Uym4BlAkRJyv\n\t9mCoFSlX7QFl5vf+Af7Hmses9wSkKk7ftTmPVTrGSvsbvbCv6a350L9l4i2MAVknZIst\n\tfBAaeWV1JKze6Mrfh+iNxDBkUKIo6otZLrc3nTZLJECpEt0Xe3lFl/mWJLnxwf8dfPP1\n\tcTW3JxvR7XJVNKnsDYWVXoFijtp0fTULy2PgABRHpwOvWomuuxukfp+XTsfVB/mcl2KO\n\tijvc4WvXTVWsxGcmeJoDFwBczI3P8Can0ev6BaQB33x4r0AHmOA7M3x4CXkKKPTJqrFo\n\tZy7A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=SQcgIO4/5YUjy/jHqexO6Rn/6ozaj2V78l6tHTPc6Os=;\n\tb=skRlBFDIc+4e9N6kiDSWTJfv/brY0syU1IDZICbvolEwnqWO976QLsC40nOrH/vrqA\n\tlg0mehpamDjKbL1HVB7+JjqmiipiCQbIYShQcLixACQjh95wabImupjPq09KSI4tSCvo\n\tX544+aDmpu5m/0Df3x1Q7lugr/6IwwYEyN8/7NDctg7FeSLoBlNc3NEoKzxD901Yru+H\n\tSlZQiRmXS9dqh72M875L2iof+b976pkY6wk6RQE7yoa5E0PuiKx8FXnu5B8wP+0nsmsz\n\tlAgaq4JxTO5SWK2At0hifpmhGIimPfV7TKRAKB10wHUJnkQ6VjYkQ502lz3asBvWWTaq\n\td1lw==","X-Gm-Message-State":"AHPjjUi5neKaZcJKKzBmNWFZka4vHPR63wtoTKPGpb7PJmzZNss82viL\n\tAX+fiz6D/3AMlDKsQBUPBBl9Kr+E8v6GpraY/mWmGenY","X-Google-Smtp-Source":"ADKCNb7mzn43o1bF8gC/Z+rtHuq5I1E2LrjgEmauI8porw8Fj/AsoPMtQ3F9Ex5iVla4x4HNose7RwAJF4Jhz7bMhTA=","X-Received":"by 10.46.16.71 with SMTP id j68mr10581581lje.110.1505741466359; \n\tMon, 18 Sep 2017 06:31:06 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<CAF6AEGu3D40KYmsNpHr3XsihOieD_8myOVv+2kBrKxrMvKGXXQ@mail.gmail.com>","References":"<20170917225927.117917-1-sjg@chromium.org>\n\t<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>\n\t<CAF6AEGu3D40KYmsNpHr3XsihOieD_8myOVv+2kBrKxrMvKGXXQ@mail.gmail.com>","From":"Rob Clark <robdclark@gmail.com>","Date":"Mon, 18 Sep 2017 09:31:05 -0400","Message-ID":"<CAF6AEGvj9V5AsW=xZkAfhy51LxpgWvxHr1DMQDhiFYTDtyCMCg@mail.gmail.com>","To":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>","Subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1770204,"web_url":"http://patchwork.ozlabs.org/comment/1770204/","msgid":"<CAF6AEGtUbdU3=NUYZg1_VRwn81u9nAPMrvb+WQq7REpFnnvRvg@mail.gmail.com>","list_archive_url":null,"date":"2017-09-18T14:30:39","subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","submitter":{"id":18760,"url":"http://patchwork.ozlabs.org/api/people/18760/","name":"Rob Clark","email":"robdclark@gmail.com"},"content":"On Mon, Sep 18, 2017 at 9:31 AM, Rob Clark <robdclark@gmail.com> wrote:\n> On Mon, Sep 18, 2017 at 9:18 AM, Rob Clark <robdclark@gmail.com> wrote:\n>> On Sun, Sep 17, 2017 at 11:48 PM, Heinrich Schuchardt\n>> <xypron.glpk@gmx.de> wrote:\n>>> On 09/18/2017 12:59 AM, Simon Glass wrote:\n>>>> A limitation of the EFI loader at present is that it does not build with\n>>>> sandbox. This makes it hard to write tests, since sandbox is used for most\n>>>> testing in U-Boot.\n>>>>\n>>>> This series enables the EFI loader feature. It allows sandbox to build and\n>>>> run a trivial function which calls the EFI API to output a message.\n>>>>\n>>>> Much work remains but this should serve as a basis for adding tests more\n>>>> easily for EFI loader.\n>>>>\n>>>> This series sits on top of Heinrich's recent EFI test series. It is\n>>>> available at u-boot-dm/efi-working\n>>>>\n>>>>\n>>>> Simon Glass (16):\n>>>>   efi: Update efi_smbios_register() to return error code\n>>>>   efi: Move the init check inside efi_init_obj_list()\n>>>>   efi: Add error checking for efi_init_obj_list()\n>>>>   efi: Add a TODO to efi_init_obj_list()\n>>>>   efi: Correct header order in efi_memory\n>>>>   efi: sandbox: Adjust memory setup for sandbox\n>>>>   sandbox: smbios: Update to support sandbox\n>>>>   sandbox: Add a setjmp() implementation\n>>>>   efi: sandbox: Add required linker sections\n>>>>   efi: sandbox: Add distroboot support\n>>>>   Define board_quiesce_devices() in a shared location\n>>>>   Add a comment for board_quiesce_devices()\n>>>>   efi: sandbox: Add relocation constants\n>>>>   efi: Add a comment about duplicated ELF constants\n>>>>   efi: sandbox: Enable EFI loader builder for sandbox\n>>>>   efi: sandbox: Add a simple 'bootefi test' command\n>>>>\n>>>>  arch/arm/include/asm/u-boot-arm.h |  1 -\n>>>>  arch/sandbox/cpu/cpu.c            | 13 ++++++++++\n>>>>  arch/sandbox/cpu/os.c             | 17 ++++++++++++\n>>>>  arch/sandbox/cpu/u-boot.lds       | 29 +++++++++++++++++++++\n>>>>  arch/sandbox/include/asm/setjmp.h | 21 +++++++++++++++\n>>>>  arch/sandbox/lib/Makefile         |  2 +-\n>>>>  arch/sandbox/lib/sections.c       | 12 +++++++++\n>>>>  arch/x86/include/asm/u-boot-x86.h |  1 -\n>>>>  arch/x86/lib/bootm.c              |  4 ---\n>>>>  cmd/bootefi.c                     | 54 ++++++++++++++++++++++++++++++++++-----\n>>>>  common/bootm.c                    |  4 +++\n>>>>  configs/sandbox_defconfig         |  1 +\n>>>>  include/bootm.h                   |  8 ++++++\n>>>>  include/config_distro_bootcmd.h   |  2 +-\n>>>>  include/efi_loader.h              | 13 ++++++++--\n>>>>  include/os.h                      | 21 +++++++++++++++\n>>>>  lib/efi_loader/Kconfig            | 12 ++++++++-\n>>>>  lib/efi_loader/Makefile           |  1 +\n>>>>  lib/efi_loader/efi_boottime.c     |  4 +++\n>>>>  lib/efi_loader/efi_memory.c       | 33 +++++++++++++-----------\n>>>>  lib/efi_loader/efi_runtime.c      |  7 +++++\n>>>>  lib/efi_loader/efi_smbios.c       |  6 +++--\n>>>>  lib/efi_loader/efi_test.c         | 17 ++++++++++++\n>>>>  lib/smbios.c                      | 38 ++++++++++++++++++++-------\n>>>>  24 files changed, 277 insertions(+), 44 deletions(-)\n>>>>  create mode 100644 arch/sandbox/include/asm/setjmp.h\n>>>>  create mode 100644 arch/sandbox/lib/sections.c\n>>>>  create mode 100644 lib/efi_loader/efi_test.c\n>>>>\n>>> Thanks for enabling efi_loader on sandbox. That will make many things\n>>> easier.\n>>>\n>>> Unfortunately\n>>> efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,\n>>>                                  struct efi_system_table *systab)\n>>> {\n>>> ...\n>>>         boottime = systable->boottime;\n>>> ...\n>>>         ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,\n>>>                                       (void **)&memory_map);\n>>> leads to a segmentation fault:\n>>\n>> I'm seeing something similar, because:\n>>\n>> (gdb) print gd->bd->bi_dram[0]\n>> $2 = {start = 0, size = 134217728}\n>>\n>> u-boot expects 1:1 phys:virt mapping, so that probably won't work.\n>\n> The following quick hack works.. something similar could probably be\n> smashed in to \"\"\n>\n> --------\n> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\n> index cddafe2d43..da2079a4b1 100644\n> --- a/lib/efi_loader/efi_memory.c\n> +++ b/lib/efi_loader/efi_memory.c\n> @@ -459,9 +459,10 @@ int efi_memory_init(void)\n>      unsigned long uboot_start, uboot_pages;\n>      unsigned long uboot_stack_size = 16 * 1024 * 1024;\n>\n> -    efi_add_known_memory();\n>\n>      if (!IS_ENABLED(CONFIG_SANDBOX)) {\n> +        efi_add_known_memory();\n> +\n>          /* Add U-Boot */\n>          uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n>                  ~EFI_PAGE_MASK;\n> @@ -476,6 +477,12 @@ int efi_memory_init(void)\n>          runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n>          efi_add_memory_map(runtime_start, runtime_pages,\n>                     EFI_RUNTIME_SERVICES_CODE, false);\n> +    } else {\n> +#define SZ_256M    0x10000000\n> +        size_t sz = SZ_256M;\n> +        void *ram = os_malloc(sz);\n> +        efi_add_memory_map((uintptr_t)ram, sz >> EFI_PAGE_SHIFT,\n> +                   EFI_CONVENTIONAL_MEMORY, false);\n>      }\n>\n>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n> --------\n>\n> With that I'm at least getting further..  efi_allocate_pool()\n> eventually fails, possibly making every small memory allocation page\n> aligned means that 256m isn't enough..\n\nOk, still just as hacky, but works a bit better:\n\n---------\ndiff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\nindex cddafe2d43..b546b5e35d 100644\n--- a/lib/efi_loader/efi_memory.c\n+++ b/lib/efi_loader/efi_memory.c\n@@ -14,6 +14,7 @@\n #include <linux/list_sort.h>\n #include <inttypes.h>\n #include <watchdog.h>\n+#include <os.h>\n\n DECLARE_GLOBAL_DATA_PTR;\n\n@@ -459,9 +460,9 @@ int efi_memory_init(void)\n     unsigned long uboot_start, uboot_pages;\n     unsigned long uboot_stack_size = 16 * 1024 * 1024;\n\n-    efi_add_known_memory();\n-\n     if (!IS_ENABLED(CONFIG_SANDBOX)) {\n+        efi_add_known_memory();\n+\n         /* Add U-Boot */\n         uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n                 ~EFI_PAGE_MASK;\n@@ -476,6 +477,14 @@ int efi_memory_init(void)\n         runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n         efi_add_memory_map(runtime_start, runtime_pages,\n                    EFI_RUNTIME_SERVICES_CODE, false);\n+    } else {\n+#define SZ_4K    0x00001000\n+#define SZ_256M    0x10000000\n+        size_t sz = SZ_256M;\n+        uintptr_t ram = (uintptr_t)os_malloc(sz + SZ_4K) + SZ_4K;\n+        efi_add_memory_map(ram & ~EFI_PAGE_MASK, sz >> EFI_PAGE_SHIFT,\n+                   EFI_CONVENTIONAL_MEMORY, false);\n+        gd->start_addr_sp = ~0;\n     }\n\n #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n---------\n\nAt this point it crashes in efi_load_pe() when it first tries to\ndereference the address of the image passed in, ie. I'm running:\n\n  host bind 0 x86_64-sct.img\n  load host 0:1 0x01000000 /efi/boot/shell.efi\n  bootefi 0x01000000\n\nNot sure if there is a better way to pick an address to load into.  Or\nmaybe just assuming that PA==VA isn't a good idea in sandbox?\n\n(Maybe being able to do 'bootefi host 0:1 /efi/boot/shell.efi' and\nhave bootefi take care or memory allocation for the loaded image would\nbe convenient)\n\nBR,\n-R\n\n\n> BR,\n> -R\n>\n>>> => bootefi selftest\n>>>\n>>> Testing EFI API implementation\n>>>\n>>> Number of tests to execute: 3\n>>> <snip>\n>>> Setting up 'ExitBootServices'\n>>> Setting up 'ExitBootServices' succeeded\n>>> Segmentation fault\n>>> user@workstation:~/workspace/u-boot-odroid-c2/denx$\n>>>\n>>> The problem does not exist with qemu-x86_defconfig without your patches.\n>>\n>> fwiw, qemu-x86 still works for me (I can still load Shell.efi) with\n>> these patches..\n>>\n>> BR,\n>> -R\n>>\n>>> qemu-x86_defconfig cannot be built with you patches:\n>>>\n>>>   UPD     include/generated/asm-offsets.h\n>>> sh: echo: I/O error\n>>> Kbuild:47: recipe for target 'include/generated/generic-asm-offsets.h'\n>>> failed\n>>> make[1]: *** [include/generated/generic-asm-offsets.h] Error 1\n>>> make[1]: *** Waiting for unfinished jobs....\n>>> Makefile:1332: recipe for target 'prepare0' failed\n>>> make: *** [prepare0] Error 2\n>>>\n>>> Best regards\n>>>\n>>> Heinrich","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"dqhBgdZL\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwpMl128fz9s7F\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 00:30:57 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 0F45AC21DAE; Mon, 18 Sep 2017 14:30:46 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 37B70C21D09;\n\tMon, 18 Sep 2017 14:30:42 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 67C8FC21D09; Mon, 18 Sep 2017 14:30:41 +0000 (UTC)","from mail-lf0-f66.google.com (mail-lf0-f66.google.com\n\t[209.85.215.66])\n\tby lists.denx.de (Postfix) with ESMTPS id 00976C21C4C\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 14:30:41 +0000 (UTC)","by mail-lf0-f66.google.com with SMTP id m199so402312lfe.5\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 07:30:40 -0700 (PDT)","by 10.46.41.75 with HTTP; Mon, 18 Sep 2017 07:30:39 -0700 (PDT)"],"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=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=H85+wWBZCYzyt1kNg1+jrFpVMINzrH2Xy6V6aAAEqwM=;\n\tb=dqhBgdZLLLdukqRh6hiZhIXfjgz7/UR5YIE/FdWm/nfyqBoMnEct9iM7Yky4dxB2wp\n\tYW+rFo7cDu6lhkyj3mC9fcenZv1cKnZlOHAFHMly8U4vH3IiEa2GqOhajV09+3Dl7kMK\n\tjGN3ROLN9/glxGwyNLapVSzNNtTOulvCwYfHBSZHQupHQizlyd9nex+0qVaIyOkbJP0k\n\tO4uf4tfSxRRRrXktr+0FOa9I9zhTQbWHBRB3bd5bBwvVy57maxc0kq/sBUUzNP7EMjaw\n\tYtCup4DoJh5ZCPZo1ElYixynctYSuRVgAn3JgXAPhiazczfcNJrWwGgnMnXNWkK43ABk\n\tbnRg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=H85+wWBZCYzyt1kNg1+jrFpVMINzrH2Xy6V6aAAEqwM=;\n\tb=pp4IDoDq5VzsdjLm17I6KkiQPLzAzvBRjFGbQ7iTrozQyiaimGTFLYwyV+XJb2NCrN\n\tLXOU8HsYvYLHMajkdkooT6Sb2QCXEh+IRs/w/397MitiApp2UKV8C/qodTlLkuEmiJ1z\n\tJYtHs0YzNRJD9pay9HvFa40pyhbzOcfexf2Qw7oCX1S7FeHPrrxt7Y32VFWXRP/cHn5J\n\tuKP+B2peMe2iw/skfGI5OR2G6XFlNR4mMnLLPzoVo7h36Hf2aJ4F5OK4p14Jgi8WVvtJ\n\tqCb7noTXgeoFkKjSBAL7tehL/9nKOSCMfpjV6BreNu6e8bQu2rsM6TZHowqnbLKrkf1j\n\tDjvw==","X-Gm-Message-State":"AHPjjUgl6pqT5BOtsFgigBJNQL/xz5sKwwm+gwVAg69Bqb6gPB9oMeQg\n\tRV5Qgdogfrp+0GOuH1hiQVc/J7lX+RCB8/XLch4=","X-Google-Smtp-Source":"AOwi7QBzBruz0sp3IiSnk8+dXaQRAhDih7nX3WoodZ/eQaEnzg4eCNm12PLkei/R835qsv83Zq/POOapmceCOuTpKHc=","X-Received":"by 10.25.213.71 with SMTP id m68mr3616679lfg.214.1505745040192; \n\tMon, 18 Sep 2017 07:30:40 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<CAF6AEGvj9V5AsW=xZkAfhy51LxpgWvxHr1DMQDhiFYTDtyCMCg@mail.gmail.com>","References":"<20170917225927.117917-1-sjg@chromium.org>\n\t<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>\n\t<CAF6AEGu3D40KYmsNpHr3XsihOieD_8myOVv+2kBrKxrMvKGXXQ@mail.gmail.com>\n\t<CAF6AEGvj9V5AsW=xZkAfhy51LxpgWvxHr1DMQDhiFYTDtyCMCg@mail.gmail.com>","From":"Rob Clark <robdclark@gmail.com>","Date":"Mon, 18 Sep 2017 10:30:39 -0400","Message-ID":"<CAF6AEGtUbdU3=NUYZg1_VRwn81u9nAPMrvb+WQq7REpFnnvRvg@mail.gmail.com>","To":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>","Subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1770234,"web_url":"http://patchwork.ozlabs.org/comment/1770234/","msgid":"<CAF6AEGsLgp7aBYNUVnQjnbygXa5QNjFiD8TAuyJiiEFyr66ZZg@mail.gmail.com>","list_archive_url":null,"date":"2017-09-18T15:07:28","subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","submitter":{"id":18760,"url":"http://patchwork.ozlabs.org/api/people/18760/","name":"Rob Clark","email":"robdclark@gmail.com"},"content":"On Mon, Sep 18, 2017 at 10:30 AM, Rob Clark <robdclark@gmail.com> wrote:\n> On Mon, Sep 18, 2017 at 9:31 AM, Rob Clark <robdclark@gmail.com> wrote:\n>> On Mon, Sep 18, 2017 at 9:18 AM, Rob Clark <robdclark@gmail.com> wrote:\n>>> On Sun, Sep 17, 2017 at 11:48 PM, Heinrich Schuchardt\n>>> <xypron.glpk@gmx.de> wrote:\n>>>> On 09/18/2017 12:59 AM, Simon Glass wrote:\n>>>>> A limitation of the EFI loader at present is that it does not build with\n>>>>> sandbox. This makes it hard to write tests, since sandbox is used for most\n>>>>> testing in U-Boot.\n>>>>>\n>>>>> This series enables the EFI loader feature. It allows sandbox to build and\n>>>>> run a trivial function which calls the EFI API to output a message.\n>>>>>\n>>>>> Much work remains but this should serve as a basis for adding tests more\n>>>>> easily for EFI loader.\n>>>>>\n>>>>> This series sits on top of Heinrich's recent EFI test series. It is\n>>>>> available at u-boot-dm/efi-working\n>>>>>\n>>>>>\n>>>>> Simon Glass (16):\n>>>>>   efi: Update efi_smbios_register() to return error code\n>>>>>   efi: Move the init check inside efi_init_obj_list()\n>>>>>   efi: Add error checking for efi_init_obj_list()\n>>>>>   efi: Add a TODO to efi_init_obj_list()\n>>>>>   efi: Correct header order in efi_memory\n>>>>>   efi: sandbox: Adjust memory setup for sandbox\n>>>>>   sandbox: smbios: Update to support sandbox\n>>>>>   sandbox: Add a setjmp() implementation\n>>>>>   efi: sandbox: Add required linker sections\n>>>>>   efi: sandbox: Add distroboot support\n>>>>>   Define board_quiesce_devices() in a shared location\n>>>>>   Add a comment for board_quiesce_devices()\n>>>>>   efi: sandbox: Add relocation constants\n>>>>>   efi: Add a comment about duplicated ELF constants\n>>>>>   efi: sandbox: Enable EFI loader builder for sandbox\n>>>>>   efi: sandbox: Add a simple 'bootefi test' command\n>>>>>\n>>>>>  arch/arm/include/asm/u-boot-arm.h |  1 -\n>>>>>  arch/sandbox/cpu/cpu.c            | 13 ++++++++++\n>>>>>  arch/sandbox/cpu/os.c             | 17 ++++++++++++\n>>>>>  arch/sandbox/cpu/u-boot.lds       | 29 +++++++++++++++++++++\n>>>>>  arch/sandbox/include/asm/setjmp.h | 21 +++++++++++++++\n>>>>>  arch/sandbox/lib/Makefile         |  2 +-\n>>>>>  arch/sandbox/lib/sections.c       | 12 +++++++++\n>>>>>  arch/x86/include/asm/u-boot-x86.h |  1 -\n>>>>>  arch/x86/lib/bootm.c              |  4 ---\n>>>>>  cmd/bootefi.c                     | 54 ++++++++++++++++++++++++++++++++++-----\n>>>>>  common/bootm.c                    |  4 +++\n>>>>>  configs/sandbox_defconfig         |  1 +\n>>>>>  include/bootm.h                   |  8 ++++++\n>>>>>  include/config_distro_bootcmd.h   |  2 +-\n>>>>>  include/efi_loader.h              | 13 ++++++++--\n>>>>>  include/os.h                      | 21 +++++++++++++++\n>>>>>  lib/efi_loader/Kconfig            | 12 ++++++++-\n>>>>>  lib/efi_loader/Makefile           |  1 +\n>>>>>  lib/efi_loader/efi_boottime.c     |  4 +++\n>>>>>  lib/efi_loader/efi_memory.c       | 33 +++++++++++++-----------\n>>>>>  lib/efi_loader/efi_runtime.c      |  7 +++++\n>>>>>  lib/efi_loader/efi_smbios.c       |  6 +++--\n>>>>>  lib/efi_loader/efi_test.c         | 17 ++++++++++++\n>>>>>  lib/smbios.c                      | 38 ++++++++++++++++++++-------\n>>>>>  24 files changed, 277 insertions(+), 44 deletions(-)\n>>>>>  create mode 100644 arch/sandbox/include/asm/setjmp.h\n>>>>>  create mode 100644 arch/sandbox/lib/sections.c\n>>>>>  create mode 100644 lib/efi_loader/efi_test.c\n>>>>>\n>>>> Thanks for enabling efi_loader on sandbox. That will make many things\n>>>> easier.\n>>>>\n>>>> Unfortunately\n>>>> efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,\n>>>>                                  struct efi_system_table *systab)\n>>>> {\n>>>> ...\n>>>>         boottime = systable->boottime;\n>>>> ...\n>>>>         ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,\n>>>>                                       (void **)&memory_map);\n>>>> leads to a segmentation fault:\n>>>\n>>> I'm seeing something similar, because:\n>>>\n>>> (gdb) print gd->bd->bi_dram[0]\n>>> $2 = {start = 0, size = 134217728}\n>>>\n>>> u-boot expects 1:1 phys:virt mapping, so that probably won't work.\n>>\n>> The following quick hack works.. something similar could probably be\n>> smashed in to \"\"\n>>\n>> --------\n>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\n>> index cddafe2d43..da2079a4b1 100644\n>> --- a/lib/efi_loader/efi_memory.c\n>> +++ b/lib/efi_loader/efi_memory.c\n>> @@ -459,9 +459,10 @@ int efi_memory_init(void)\n>>      unsigned long uboot_start, uboot_pages;\n>>      unsigned long uboot_stack_size = 16 * 1024 * 1024;\n>>\n>> -    efi_add_known_memory();\n>>\n>>      if (!IS_ENABLED(CONFIG_SANDBOX)) {\n>> +        efi_add_known_memory();\n>> +\n>>          /* Add U-Boot */\n>>          uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n>>                  ~EFI_PAGE_MASK;\n>> @@ -476,6 +477,12 @@ int efi_memory_init(void)\n>>          runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n>>          efi_add_memory_map(runtime_start, runtime_pages,\n>>                     EFI_RUNTIME_SERVICES_CODE, false);\n>> +    } else {\n>> +#define SZ_256M    0x10000000\n>> +        size_t sz = SZ_256M;\n>> +        void *ram = os_malloc(sz);\n>> +        efi_add_memory_map((uintptr_t)ram, sz >> EFI_PAGE_SHIFT,\n>> +                   EFI_CONVENTIONAL_MEMORY, false);\n>>      }\n>>\n>>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n>> --------\n>>\n>> With that I'm at least getting further..  efi_allocate_pool()\n>> eventually fails, possibly making every small memory allocation page\n>> aligned means that 256m isn't enough..\n>\n> Ok, still just as hacky, but works a bit better:\n>\n> ---------\n> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\n> index cddafe2d43..b546b5e35d 100644\n> --- a/lib/efi_loader/efi_memory.c\n> +++ b/lib/efi_loader/efi_memory.c\n> @@ -14,6 +14,7 @@\n>  #include <linux/list_sort.h>\n>  #include <inttypes.h>\n>  #include <watchdog.h>\n> +#include <os.h>\n>\n>  DECLARE_GLOBAL_DATA_PTR;\n>\n> @@ -459,9 +460,9 @@ int efi_memory_init(void)\n>      unsigned long uboot_start, uboot_pages;\n>      unsigned long uboot_stack_size = 16 * 1024 * 1024;\n>\n> -    efi_add_known_memory();\n> -\n>      if (!IS_ENABLED(CONFIG_SANDBOX)) {\n> +        efi_add_known_memory();\n> +\n>          /* Add U-Boot */\n>          uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n>                  ~EFI_PAGE_MASK;\n> @@ -476,6 +477,14 @@ int efi_memory_init(void)\n>          runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n>          efi_add_memory_map(runtime_start, runtime_pages,\n>                     EFI_RUNTIME_SERVICES_CODE, false);\n> +    } else {\n> +#define SZ_4K    0x00001000\n> +#define SZ_256M    0x10000000\n> +        size_t sz = SZ_256M;\n> +        uintptr_t ram = (uintptr_t)os_malloc(sz + SZ_4K) + SZ_4K;\n> +        efi_add_memory_map(ram & ~EFI_PAGE_MASK, sz >> EFI_PAGE_SHIFT,\n> +                   EFI_CONVENTIONAL_MEMORY, false);\n> +        gd->start_addr_sp = ~0;\n>      }\n>\n>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n> ---------\n>\n> At this point it crashes in efi_load_pe() when it first tries to\n> dereference the address of the image passed in, ie. I'm running:\n>\n>   host bind 0 x86_64-sct.img\n>   load host 0:1 0x01000000 /efi/boot/shell.efi\n>   bootefi 0x01000000\n>\n> Not sure if there is a better way to pick an address to load into.  Or\n> maybe just assuming that PA==VA isn't a good idea in sandbox?\n>\n\nOk, I realized there is map_sysmem().. which gets me further..\nefi_loader really expects identity mapping (PA==VA), and iirc this is\nwhat UEFI spec expects too so I wouldn't necessarily call it a bug in\nefi_loader.\n\nBR,\n-R","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"URAO/nWd\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwqB334wQz9s78\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 01:07:39 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid DB3D3C21E76; Mon, 18 Sep 2017 15:07:35 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id DBB20C21D90;\n\tMon, 18 Sep 2017 15:07:32 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid CC3F3C21D90; Mon, 18 Sep 2017 15:07:30 +0000 (UTC)","from mail-lf0-f68.google.com (mail-lf0-f68.google.com\n\t[209.85.215.68])\n\tby lists.denx.de (Postfix) with ESMTPS id B13EEC21C4C\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 15:07:29 +0000 (UTC)","by mail-lf0-f68.google.com with SMTP id m199so462108lfe.5\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 08:07:29 -0700 (PDT)","by 10.46.41.75 with HTTP; Mon, 18 Sep 2017 08:07:28 -0700 (PDT)"],"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=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=XUgjBBAIkdZz+6gjRaHhfbN5fAq5P+FdflgZE3S6waI=;\n\tb=URAO/nWd97DBpt21pUlaMuvz1gTZR/mq13Xkz97bN8uU8F+J1VABCh4ELc+oER1RdM\n\tPEGlYdp15tjKCpmQ9FltI8fXRVtUpzh7CIjQoAMmwN0vNTjSiZI/NvuMsAMPF4clw2Vo\n\tr48YhamPzI5B6PkAES+EnaHTBAkbpzp5KqoS3A0H6aRcA8PG0snUyJ1SJDh46d0/UCl9\n\tfNyFE1KS4L9XUzgEN0KMMzgy9NayiABYesnNfuMVupVwCjiGq7/UitGHAmF2u+syTthE\n\tmSzjpHjFbsea897gatwKHjEnKE+24zJH+iEsMnpsnDMKGU32ipfliF18DT3MZ10Lp0lH\n\tLw0A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=XUgjBBAIkdZz+6gjRaHhfbN5fAq5P+FdflgZE3S6waI=;\n\tb=aTbpENPKJKxvMic9nneZg5hOh9RflBDnaOQjhgBSbxq/LYb8JIxtsb56LQ71Izmq1q\n\t81hHk3cbwRseu3qUw2nBNZ0HKs9tqSixiPaNk5h6WBZX5VeDmP21x7vuJH7P7mF7g8Sh\n\tj8BrV+JvENAfhLd+up7QTCbL/XXaFDImaJ9xKxA87PlzOMEq2Muw/bYhUSsPMHzkoGd8\n\tlA4LGm8HqafadfmJt+qhRTISgVyGA3kFoaZKmsVc4pKgb1//IHWYX8qIiKrqylVTAI0e\n\tje6Go/STYY5sWG3qz3j4nKBXe2DY0fa+CTHJRKozsQ6ZEY1ZBdR7VHHUSi1/0xnJkjTj\n\tuRZg==","X-Gm-Message-State":"AHPjjUjPbzTk4hR0kyroUmdg9KFGefG7dQS53kNIxOw6biT6qHwWoKd1\n\tVK25jBaIB3p1nGzWmM2AaD+mkOkk1YnP0SxmECQ=","X-Google-Smtp-Source":"AOwi7QBSnVd8HOKhE1wxktIgeQeIvn6J1w5O+IwLmlfUyBP6GRK2FiyIbHw7jWo/eZMfEPXGy04U/Mdb8YSLA3OvB8Q=","X-Received":"by 10.46.22.20 with SMTP id w20mr2179562ljd.90.1505747248969;\n\tMon, 18 Sep 2017 08:07:28 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<CAF6AEGtUbdU3=NUYZg1_VRwn81u9nAPMrvb+WQq7REpFnnvRvg@mail.gmail.com>","References":"<20170917225927.117917-1-sjg@chromium.org>\n\t<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>\n\t<CAF6AEGu3D40KYmsNpHr3XsihOieD_8myOVv+2kBrKxrMvKGXXQ@mail.gmail.com>\n\t<CAF6AEGvj9V5AsW=xZkAfhy51LxpgWvxHr1DMQDhiFYTDtyCMCg@mail.gmail.com>\n\t<CAF6AEGtUbdU3=NUYZg1_VRwn81u9nAPMrvb+WQq7REpFnnvRvg@mail.gmail.com>","From":"Rob Clark <robdclark@gmail.com>","Date":"Mon, 18 Sep 2017 11:07:28 -0400","Message-ID":"<CAF6AEGsLgp7aBYNUVnQjnbygXa5QNjFiD8TAuyJiiEFyr66ZZg@mail.gmail.com>","To":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>","Subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1770328,"web_url":"http://patchwork.ozlabs.org/comment/1770328/","msgid":"<CAF6AEGuR2zCkZT+D==ULJeXk6MTXmFk7F=7nVJOrY_B+AsW6Fg@mail.gmail.com>","list_archive_url":null,"date":"2017-09-18T17:03:51","subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","submitter":{"id":18760,"url":"http://patchwork.ozlabs.org/api/people/18760/","name":"Rob Clark","email":"robdclark@gmail.com"},"content":"On Mon, Sep 18, 2017 at 11:07 AM, Rob Clark <robdclark@gmail.com> wrote:\n> On Mon, Sep 18, 2017 at 10:30 AM, Rob Clark <robdclark@gmail.com> wrote:\n>> On Mon, Sep 18, 2017 at 9:31 AM, Rob Clark <robdclark@gmail.com> wrote:\n>>> On Mon, Sep 18, 2017 at 9:18 AM, Rob Clark <robdclark@gmail.com> wrote:\n>>>> On Sun, Sep 17, 2017 at 11:48 PM, Heinrich Schuchardt\n>>>> <xypron.glpk@gmx.de> wrote:\n>>>>> On 09/18/2017 12:59 AM, Simon Glass wrote:\n>>>>>> A limitation of the EFI loader at present is that it does not build with\n>>>>>> sandbox. This makes it hard to write tests, since sandbox is used for most\n>>>>>> testing in U-Boot.\n>>>>>>\n>>>>>> This series enables the EFI loader feature. It allows sandbox to build and\n>>>>>> run a trivial function which calls the EFI API to output a message.\n>>>>>>\n>>>>>> Much work remains but this should serve as a basis for adding tests more\n>>>>>> easily for EFI loader.\n>>>>>>\n>>>>>> This series sits on top of Heinrich's recent EFI test series. It is\n>>>>>> available at u-boot-dm/efi-working\n>>>>>>\n>>>>>>\n>>>>>> Simon Glass (16):\n>>>>>>   efi: Update efi_smbios_register() to return error code\n>>>>>>   efi: Move the init check inside efi_init_obj_list()\n>>>>>>   efi: Add error checking for efi_init_obj_list()\n>>>>>>   efi: Add a TODO to efi_init_obj_list()\n>>>>>>   efi: Correct header order in efi_memory\n>>>>>>   efi: sandbox: Adjust memory setup for sandbox\n>>>>>>   sandbox: smbios: Update to support sandbox\n>>>>>>   sandbox: Add a setjmp() implementation\n>>>>>>   efi: sandbox: Add required linker sections\n>>>>>>   efi: sandbox: Add distroboot support\n>>>>>>   Define board_quiesce_devices() in a shared location\n>>>>>>   Add a comment for board_quiesce_devices()\n>>>>>>   efi: sandbox: Add relocation constants\n>>>>>>   efi: Add a comment about duplicated ELF constants\n>>>>>>   efi: sandbox: Enable EFI loader builder for sandbox\n>>>>>>   efi: sandbox: Add a simple 'bootefi test' command\n>>>>>>\n>>>>>>  arch/arm/include/asm/u-boot-arm.h |  1 -\n>>>>>>  arch/sandbox/cpu/cpu.c            | 13 ++++++++++\n>>>>>>  arch/sandbox/cpu/os.c             | 17 ++++++++++++\n>>>>>>  arch/sandbox/cpu/u-boot.lds       | 29 +++++++++++++++++++++\n>>>>>>  arch/sandbox/include/asm/setjmp.h | 21 +++++++++++++++\n>>>>>>  arch/sandbox/lib/Makefile         |  2 +-\n>>>>>>  arch/sandbox/lib/sections.c       | 12 +++++++++\n>>>>>>  arch/x86/include/asm/u-boot-x86.h |  1 -\n>>>>>>  arch/x86/lib/bootm.c              |  4 ---\n>>>>>>  cmd/bootefi.c                     | 54 ++++++++++++++++++++++++++++++++++-----\n>>>>>>  common/bootm.c                    |  4 +++\n>>>>>>  configs/sandbox_defconfig         |  1 +\n>>>>>>  include/bootm.h                   |  8 ++++++\n>>>>>>  include/config_distro_bootcmd.h   |  2 +-\n>>>>>>  include/efi_loader.h              | 13 ++++++++--\n>>>>>>  include/os.h                      | 21 +++++++++++++++\n>>>>>>  lib/efi_loader/Kconfig            | 12 ++++++++-\n>>>>>>  lib/efi_loader/Makefile           |  1 +\n>>>>>>  lib/efi_loader/efi_boottime.c     |  4 +++\n>>>>>>  lib/efi_loader/efi_memory.c       | 33 +++++++++++++-----------\n>>>>>>  lib/efi_loader/efi_runtime.c      |  7 +++++\n>>>>>>  lib/efi_loader/efi_smbios.c       |  6 +++--\n>>>>>>  lib/efi_loader/efi_test.c         | 17 ++++++++++++\n>>>>>>  lib/smbios.c                      | 38 ++++++++++++++++++++-------\n>>>>>>  24 files changed, 277 insertions(+), 44 deletions(-)\n>>>>>>  create mode 100644 arch/sandbox/include/asm/setjmp.h\n>>>>>>  create mode 100644 arch/sandbox/lib/sections.c\n>>>>>>  create mode 100644 lib/efi_loader/efi_test.c\n>>>>>>\n>>>>> Thanks for enabling efi_loader on sandbox. That will make many things\n>>>>> easier.\n>>>>>\n>>>>> Unfortunately\n>>>>> efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,\n>>>>>                                  struct efi_system_table *systab)\n>>>>> {\n>>>>> ...\n>>>>>         boottime = systable->boottime;\n>>>>> ...\n>>>>>         ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,\n>>>>>                                       (void **)&memory_map);\n>>>>> leads to a segmentation fault:\n>>>>\n>>>> I'm seeing something similar, because:\n>>>>\n>>>> (gdb) print gd->bd->bi_dram[0]\n>>>> $2 = {start = 0, size = 134217728}\n>>>>\n>>>> u-boot expects 1:1 phys:virt mapping, so that probably won't work.\n>>>\n>>> The following quick hack works.. something similar could probably be\n>>> smashed in to \"\"\n>>>\n>>> --------\n>>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\n>>> index cddafe2d43..da2079a4b1 100644\n>>> --- a/lib/efi_loader/efi_memory.c\n>>> +++ b/lib/efi_loader/efi_memory.c\n>>> @@ -459,9 +459,10 @@ int efi_memory_init(void)\n>>>      unsigned long uboot_start, uboot_pages;\n>>>      unsigned long uboot_stack_size = 16 * 1024 * 1024;\n>>>\n>>> -    efi_add_known_memory();\n>>>\n>>>      if (!IS_ENABLED(CONFIG_SANDBOX)) {\n>>> +        efi_add_known_memory();\n>>> +\n>>>          /* Add U-Boot */\n>>>          uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n>>>                  ~EFI_PAGE_MASK;\n>>> @@ -476,6 +477,12 @@ int efi_memory_init(void)\n>>>          runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n>>>          efi_add_memory_map(runtime_start, runtime_pages,\n>>>                     EFI_RUNTIME_SERVICES_CODE, false);\n>>> +    } else {\n>>> +#define SZ_256M    0x10000000\n>>> +        size_t sz = SZ_256M;\n>>> +        void *ram = os_malloc(sz);\n>>> +        efi_add_memory_map((uintptr_t)ram, sz >> EFI_PAGE_SHIFT,\n>>> +                   EFI_CONVENTIONAL_MEMORY, false);\n>>>      }\n>>>\n>>>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n>>> --------\n>>>\n>>> With that I'm at least getting further..  efi_allocate_pool()\n>>> eventually fails, possibly making every small memory allocation page\n>>> aligned means that 256m isn't enough..\n>>\n>> Ok, still just as hacky, but works a bit better:\n>>\n>> ---------\n>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\n>> index cddafe2d43..b546b5e35d 100644\n>> --- a/lib/efi_loader/efi_memory.c\n>> +++ b/lib/efi_loader/efi_memory.c\n>> @@ -14,6 +14,7 @@\n>>  #include <linux/list_sort.h>\n>>  #include <inttypes.h>\n>>  #include <watchdog.h>\n>> +#include <os.h>\n>>\n>>  DECLARE_GLOBAL_DATA_PTR;\n>>\n>> @@ -459,9 +460,9 @@ int efi_memory_init(void)\n>>      unsigned long uboot_start, uboot_pages;\n>>      unsigned long uboot_stack_size = 16 * 1024 * 1024;\n>>\n>> -    efi_add_known_memory();\n>> -\n>>      if (!IS_ENABLED(CONFIG_SANDBOX)) {\n>> +        efi_add_known_memory();\n>> +\n>>          /* Add U-Boot */\n>>          uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n>>                  ~EFI_PAGE_MASK;\n>> @@ -476,6 +477,14 @@ int efi_memory_init(void)\n>>          runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n>>          efi_add_memory_map(runtime_start, runtime_pages,\n>>                     EFI_RUNTIME_SERVICES_CODE, false);\n>> +    } else {\n>> +#define SZ_4K    0x00001000\n>> +#define SZ_256M    0x10000000\n>> +        size_t sz = SZ_256M;\n>> +        uintptr_t ram = (uintptr_t)os_malloc(sz + SZ_4K) + SZ_4K;\n>> +        efi_add_memory_map(ram & ~EFI_PAGE_MASK, sz >> EFI_PAGE_SHIFT,\n>> +                   EFI_CONVENTIONAL_MEMORY, false);\n>> +        gd->start_addr_sp = ~0;\n>>      }\n>>\n>>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n>> ---------\n>>\n>> At this point it crashes in efi_load_pe() when it first tries to\n>> dereference the address of the image passed in, ie. I'm running:\n>>\n>>   host bind 0 x86_64-sct.img\n>>   load host 0:1 0x01000000 /efi/boot/shell.efi\n>>   bootefi 0x01000000\n>>\n>> Not sure if there is a better way to pick an address to load into.  Or\n>> maybe just assuming that PA==VA isn't a good idea in sandbox?\n>>\n>\n> Ok, I realized there is map_sysmem().. which gets me further..\n> efi_loader really expects identity mapping (PA==VA), and iirc this is\n> what UEFI spec expects too so I wouldn't necessarily call it a bug in\n> efi_loader.\n>\n\nSo, I don't know x86(_64) asm or calling conventions as well as arm..\nbut I wonder if we are screwing up something long those lines:\n\n\n0000000000000280 <.text>:\n     280:       48 89 5c 24 08          mov    %rbx,0x8(%rsp)\n     285:       57                      push   %rdi\n     286:       48 83 ec 20             sub    $0x20,%rsp\n     28a:       48 8b f9                mov    %rcx,%rdi\n>>   28d:       e8 1e 00 00 00          callq  0x2b0\nthis jump is taken to 0x2b0\n\n     292:       e8 2d 06 00 00          callq  0x8c4\n     297:       48 8b cf                mov    %rdi,%rcx\n     29a:       48 8b d8                mov    %rax,%rbx\n     29d:       e8 ea 01 00 00          callq  0x48c\n     2a2:       48 8b c3                mov    %rbx,%rax\n     2a5:       48 8b 5c 24 30          mov    0x30(%rsp),%rbx\n     2aa:       48 83 c4 20             add    $0x20,%rsp\n     2ae:       5f                      pop    %rdi\n     2af:       c3                      retq\n>>   2b0:       40 53                   rex push %rbx\n     2b2:       48 83 ec 20             sub    $0x20,%rsp\n     2b6:       48 89 0d e3 b9 05 00    mov    %rcx,0x5b9e3(%rip)\n  # 0x5bca0\n     2bd:       4c 8d 05 f4 b9 05 00    lea    0x5b9f4(%rip),%r8\n # 0x5bcb8\n>>   2c4:       48 8b 42 60             mov    0x60(%rdx),%rax\n\nand at 0x2c4 %rdx is 0x2..  I always thought x86 asm syntax strange,\nbut I assume that is trying to write to value of %rdx + offset of\n0x60??  But this is a register never written, so I assume it is\nexpected to be passed from efi_loader?\n\nFrom https://en.wikipedia.org/wiki/X86_calling_conventions it seems\nthat MS calling convention expects 2nd arg in %rdx, but linux/gcc\ncalling convention expects 3rd arg in %rdx (there is no 3rd arg)..\n\nBR,\n-","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"HcYXsuuF\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xwsmQ4rYMz9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 03:04:05 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 5C1FDC21D19; Mon, 18 Sep 2017 17:03:58 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id E8C83C21C41;\n\tMon, 18 Sep 2017 17:03:54 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 94907C21C41; Mon, 18 Sep 2017 17:03:53 +0000 (UTC)","from mail-lf0-f66.google.com (mail-lf0-f66.google.com\n\t[209.85.215.66])\n\tby lists.denx.de (Postfix) with ESMTPS id 0867FC21C2B\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 17:03:53 +0000 (UTC)","by mail-lf0-f66.google.com with SMTP id m199so627619lfe.5\n\tfor <u-boot@lists.denx.de>; Mon, 18 Sep 2017 10:03:53 -0700 (PDT)","by 10.46.41.75 with HTTP; Mon, 18 Sep 2017 10:03:51 -0700 (PDT)"],"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=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=0deexAiwyh9ma39rTk1XyCH+9bza8wPXFP05okdQ5Jw=;\n\tb=HcYXsuuFdFoCh3bId+m2fWTy4kNEed7Tw2Z977F2rL2tMClWtLXbszCn+Ag4toY5RY\n\tpht7y3NANaGf7p+ecV+a1VYFudva7nP+kN9STRP6TJUiN2nuReNGlTj58cNX+ee+K85p\n\tcd4VzjsZXhokYW0q/h6rdzwfGtvCjZjPo4vElDuxoYMtnDkDSw7PAkKmTcLL1/jlHegR\n\tCnEfNB4HHcrDeavrvGhL8qBxxz4FANB1YJQJLvE6mLMITKC9XHxJZFr6pVjhf2a2nMZT\n\t2SUO9hut9VdoagjHRyBTABcFl3pNtIymFd2NneX3erLXKxtckl3F17EIASrYF38DYZwo\n\tQbdA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=0deexAiwyh9ma39rTk1XyCH+9bza8wPXFP05okdQ5Jw=;\n\tb=DtrphMNmktgL6tWQ+GPlVDpxKDjF2K8uJvBCSDoMjRBh532PRmBmzQFHqLk67so10q\n\tdF12q+VYbc8IBse0OF0ILSkFvWKJcjm5xpgbh/lxpdV/1qsTXxOhdmpQuvLA+0qye153\n\tIZ1OwGnJDhoM6EbT4yj/u3NWe6rp3DHjLMIH9yEOLsCi3r2Xa4Cyr5Nm4F7AktfNs9p5\n\tRfXCGNSBZHbaDIpXTC49lkJ8I284E9NRToBJww9hhdu+aOFtLT9KMwFKcy/WNRS0FYes\n\t/HKZgFtjuUHSDYCJU1NVJtjdPfHSmqo+LxEC5uSmcbg2a0xRi+cdOw3EttafM8JyZ5ua\n\tQaSg==","X-Gm-Message-State":"AHPjjUgvAEyaNXthdbltNcJHDy+GAxI+g74ynzIdLZyp5EGoE9JpD6jh\n\tDXs0G9/dZvKV0ZsmUUDVp05v8Z1VEHf6IApKFxU=","X-Google-Smtp-Source":"AOwi7QAhNNbwq+8Bxaf9PsaeVJsIzNXvFNWVRWykWs/cdI7q/60RRHNx4USXJE1RRQAcYBvj1r4fOkJhKDXJS8J+cOQ=","X-Received":"by 10.25.166.69 with SMTP id p66mr3565494lfe.190.1505754232246; \n\tMon, 18 Sep 2017 10:03:52 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<CAF6AEGsLgp7aBYNUVnQjnbygXa5QNjFiD8TAuyJiiEFyr66ZZg@mail.gmail.com>","References":"<20170917225927.117917-1-sjg@chromium.org>\n\t<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>\n\t<CAF6AEGu3D40KYmsNpHr3XsihOieD_8myOVv+2kBrKxrMvKGXXQ@mail.gmail.com>\n\t<CAF6AEGvj9V5AsW=xZkAfhy51LxpgWvxHr1DMQDhiFYTDtyCMCg@mail.gmail.com>\n\t<CAF6AEGtUbdU3=NUYZg1_VRwn81u9nAPMrvb+WQq7REpFnnvRvg@mail.gmail.com>\n\t<CAF6AEGsLgp7aBYNUVnQjnbygXa5QNjFiD8TAuyJiiEFyr66ZZg@mail.gmail.com>","From":"Rob Clark <robdclark@gmail.com>","Date":"Mon, 18 Sep 2017 13:03:51 -0400","Message-ID":"<CAF6AEGuR2zCkZT+D==ULJeXk6MTXmFk7F=7nVJOrY_B+AsW6Fg@mail.gmail.com>","To":"Heinrich Schuchardt <xypron.glpk@gmx.de>","Cc":"U-Boot Mailing List <u-boot@lists.denx.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>","Subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1774347,"web_url":"http://patchwork.ozlabs.org/comment/1774347/","msgid":"<CAPnjgZ1HinjqHYRG19G16-pMk4JUKHkae12G-dbN0UDytg_ebg@mail.gmail.com>","list_archive_url":null,"date":"2017-09-25T02:12:43","subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/","name":"Simon Glass","email":"sjg@chromium.org"},"content":"Hi Rob,\n\nOn 18 September 2017 at 11:03, Rob Clark <robdclark@gmail.com> wrote:\n> On Mon, Sep 18, 2017 at 11:07 AM, Rob Clark <robdclark@gmail.com> wrote:\n>> On Mon, Sep 18, 2017 at 10:30 AM, Rob Clark <robdclark@gmail.com> wrote:\n>>> On Mon, Sep 18, 2017 at 9:31 AM, Rob Clark <robdclark@gmail.com> wrote:\n>>>> On Mon, Sep 18, 2017 at 9:18 AM, Rob Clark <robdclark@gmail.com> wrote:\n>>>>> On Sun, Sep 17, 2017 at 11:48 PM, Heinrich Schuchardt\n>>>>> <xypron.glpk@gmx.de> wrote:\n>>>>>> On 09/18/2017 12:59 AM, Simon Glass wrote:\n>>>>>>> A limitation of the EFI loader at present is that it does not build with\n>>>>>>> sandbox. This makes it hard to write tests, since sandbox is used for most\n>>>>>>> testing in U-Boot.\n>>>>>>>\n>>>>>>> This series enables the EFI loader feature. It allows sandbox to build and\n>>>>>>> run a trivial function which calls the EFI API to output a message.\n>>>>>>>\n>>>>>>> Much work remains but this should serve as a basis for adding tests more\n>>>>>>> easily for EFI loader.\n>>>>>>>\n>>>>>>> This series sits on top of Heinrich's recent EFI test series. It is\n>>>>>>> available at u-boot-dm/efi-working\n>>>>>>>\n>>>>>>>\n>>>>>>> Simon Glass (16):\n>>>>>>>   efi: Update efi_smbios_register() to return error code\n>>>>>>>   efi: Move the init check inside efi_init_obj_list()\n>>>>>>>   efi: Add error checking for efi_init_obj_list()\n>>>>>>>   efi: Add a TODO to efi_init_obj_list()\n>>>>>>>   efi: Correct header order in efi_memory\n>>>>>>>   efi: sandbox: Adjust memory setup for sandbox\n>>>>>>>   sandbox: smbios: Update to support sandbox\n>>>>>>>   sandbox: Add a setjmp() implementation\n>>>>>>>   efi: sandbox: Add required linker sections\n>>>>>>>   efi: sandbox: Add distroboot support\n>>>>>>>   Define board_quiesce_devices() in a shared location\n>>>>>>>   Add a comment for board_quiesce_devices()\n>>>>>>>   efi: sandbox: Add relocation constants\n>>>>>>>   efi: Add a comment about duplicated ELF constants\n>>>>>>>   efi: sandbox: Enable EFI loader builder for sandbox\n>>>>>>>   efi: sandbox: Add a simple 'bootefi test' command\n>>>>>>>\n>>>>>>>  arch/arm/include/asm/u-boot-arm.h |  1 -\n>>>>>>>  arch/sandbox/cpu/cpu.c            | 13 ++++++++++\n>>>>>>>  arch/sandbox/cpu/os.c             | 17 ++++++++++++\n>>>>>>>  arch/sandbox/cpu/u-boot.lds       | 29 +++++++++++++++++++++\n>>>>>>>  arch/sandbox/include/asm/setjmp.h | 21 +++++++++++++++\n>>>>>>>  arch/sandbox/lib/Makefile         |  2 +-\n>>>>>>>  arch/sandbox/lib/sections.c       | 12 +++++++++\n>>>>>>>  arch/x86/include/asm/u-boot-x86.h |  1 -\n>>>>>>>  arch/x86/lib/bootm.c              |  4 ---\n>>>>>>>  cmd/bootefi.c                     | 54 ++++++++++++++++++++++++++++++++++-----\n>>>>>>>  common/bootm.c                    |  4 +++\n>>>>>>>  configs/sandbox_defconfig         |  1 +\n>>>>>>>  include/bootm.h                   |  8 ++++++\n>>>>>>>  include/config_distro_bootcmd.h   |  2 +-\n>>>>>>>  include/efi_loader.h              | 13 ++++++++--\n>>>>>>>  include/os.h                      | 21 +++++++++++++++\n>>>>>>>  lib/efi_loader/Kconfig            | 12 ++++++++-\n>>>>>>>  lib/efi_loader/Makefile           |  1 +\n>>>>>>>  lib/efi_loader/efi_boottime.c     |  4 +++\n>>>>>>>  lib/efi_loader/efi_memory.c       | 33 +++++++++++++-----------\n>>>>>>>  lib/efi_loader/efi_runtime.c      |  7 +++++\n>>>>>>>  lib/efi_loader/efi_smbios.c       |  6 +++--\n>>>>>>>  lib/efi_loader/efi_test.c         | 17 ++++++++++++\n>>>>>>>  lib/smbios.c                      | 38 ++++++++++++++++++++-------\n>>>>>>>  24 files changed, 277 insertions(+), 44 deletions(-)\n>>>>>>>  create mode 100644 arch/sandbox/include/asm/setjmp.h\n>>>>>>>  create mode 100644 arch/sandbox/lib/sections.c\n>>>>>>>  create mode 100644 lib/efi_loader/efi_test.c\n>>>>>>>\n>>>>>> Thanks for enabling efi_loader on sandbox. That will make many things\n>>>>>> easier.\n>>>>>>\n>>>>>> Unfortunately\n>>>>>> efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,\n>>>>>>                                  struct efi_system_table *systab)\n>>>>>> {\n>>>>>> ...\n>>>>>>         boottime = systable->boottime;\n>>>>>> ...\n>>>>>>         ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,\n>>>>>>                                       (void **)&memory_map);\n>>>>>> leads to a segmentation fault:\n>>>>>\n>>>>> I'm seeing something similar, because:\n>>>>>\n>>>>> (gdb) print gd->bd->bi_dram[0]\n>>>>> $2 = {start = 0, size = 134217728}\n>>>>>\n>>>>> u-boot expects 1:1 phys:virt mapping, so that probably won't work.\n>>>>\n>>>> The following quick hack works.. something similar could probably be\n>>>> smashed in to \"\"\n>>>>\n>>>> --------\n>>>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\n>>>> index cddafe2d43..da2079a4b1 100644\n>>>> --- a/lib/efi_loader/efi_memory.c\n>>>> +++ b/lib/efi_loader/efi_memory.c\n>>>> @@ -459,9 +459,10 @@ int efi_memory_init(void)\n>>>>      unsigned long uboot_start, uboot_pages;\n>>>>      unsigned long uboot_stack_size = 16 * 1024 * 1024;\n>>>>\n>>>> -    efi_add_known_memory();\n>>>>\n>>>>      if (!IS_ENABLED(CONFIG_SANDBOX)) {\n>>>> +        efi_add_known_memory();\n>>>> +\n>>>>          /* Add U-Boot */\n>>>>          uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n>>>>                  ~EFI_PAGE_MASK;\n>>>> @@ -476,6 +477,12 @@ int efi_memory_init(void)\n>>>>          runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n>>>>          efi_add_memory_map(runtime_start, runtime_pages,\n>>>>                     EFI_RUNTIME_SERVICES_CODE, false);\n>>>> +    } else {\n>>>> +#define SZ_256M    0x10000000\n>>>> +        size_t sz = SZ_256M;\n>>>> +        void *ram = os_malloc(sz);\n>>>> +        efi_add_memory_map((uintptr_t)ram, sz >> EFI_PAGE_SHIFT,\n>>>> +                   EFI_CONVENTIONAL_MEMORY, false);\n>>>>      }\n>>>>\n>>>>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n>>>> --------\n>>>>\n>>>> With that I'm at least getting further..  efi_allocate_pool()\n>>>> eventually fails, possibly making every small memory allocation page\n>>>> aligned means that 256m isn't enough..\n>>>\n>>> Ok, still just as hacky, but works a bit better:\n>>>\n>>> ---------\n>>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\n>>> index cddafe2d43..b546b5e35d 100644\n>>> --- a/lib/efi_loader/efi_memory.c\n>>> +++ b/lib/efi_loader/efi_memory.c\n>>> @@ -14,6 +14,7 @@\n>>>  #include <linux/list_sort.h>\n>>>  #include <inttypes.h>\n>>>  #include <watchdog.h>\n>>> +#include <os.h>\n>>>\n>>>  DECLARE_GLOBAL_DATA_PTR;\n>>>\n>>> @@ -459,9 +460,9 @@ int efi_memory_init(void)\n>>>      unsigned long uboot_start, uboot_pages;\n>>>      unsigned long uboot_stack_size = 16 * 1024 * 1024;\n>>>\n>>> -    efi_add_known_memory();\n>>> -\n>>>      if (!IS_ENABLED(CONFIG_SANDBOX)) {\n>>> +        efi_add_known_memory();\n>>> +\n>>>          /* Add U-Boot */\n>>>          uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n>>>                  ~EFI_PAGE_MASK;\n>>> @@ -476,6 +477,14 @@ int efi_memory_init(void)\n>>>          runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n>>>          efi_add_memory_map(runtime_start, runtime_pages,\n>>>                     EFI_RUNTIME_SERVICES_CODE, false);\n>>> +    } else {\n>>> +#define SZ_4K    0x00001000\n>>> +#define SZ_256M    0x10000000\n>>> +        size_t sz = SZ_256M;\n>>> +        uintptr_t ram = (uintptr_t)os_malloc(sz + SZ_4K) + SZ_4K;\n>>> +        efi_add_memory_map(ram & ~EFI_PAGE_MASK, sz >> EFI_PAGE_SHIFT,\n>>> +                   EFI_CONVENTIONAL_MEMORY, false);\n>>> +        gd->start_addr_sp = ~0;\n>>>      }\n>>>\n>>>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n>>> ---------\n>>>\n>>> At this point it crashes in efi_load_pe() when it first tries to\n>>> dereference the address of the image passed in, ie. I'm running:\n>>>\n>>>   host bind 0 x86_64-sct.img\n>>>   load host 0:1 0x01000000 /efi/boot/shell.efi\n>>>   bootefi 0x01000000\n>>>\n>>> Not sure if there is a better way to pick an address to load into.  Or\n>>> maybe just assuming that PA==VA isn't a good idea in sandbox?\n>>>\n>>\n>> Ok, I realized there is map_sysmem().. which gets me further..\n>> efi_loader really expects identity mapping (PA==VA), and iirc this is\n>> what UEFI spec expects too so I wouldn't necessarily call it a bug in\n>> efi_loader.\n>>\n>\n> So, I don't know x86(_64) asm or calling conventions as well as arm..\n> but I wonder if we are screwing up something long those lines:\n>\n>\n> 0000000000000280 <.text>:\n>      280:       48 89 5c 24 08          mov    %rbx,0x8(%rsp)\n>      285:       57                      push   %rdi\n>      286:       48 83 ec 20             sub    $0x20,%rsp\n>      28a:       48 8b f9                mov    %rcx,%rdi\n>>>   28d:       e8 1e 00 00 00          callq  0x2b0\n> this jump is taken to 0x2b0\n>\n>      292:       e8 2d 06 00 00          callq  0x8c4\n>      297:       48 8b cf                mov    %rdi,%rcx\n>      29a:       48 8b d8                mov    %rax,%rbx\n>      29d:       e8 ea 01 00 00          callq  0x48c\n>      2a2:       48 8b c3                mov    %rbx,%rax\n>      2a5:       48 8b 5c 24 30          mov    0x30(%rsp),%rbx\n>      2aa:       48 83 c4 20             add    $0x20,%rsp\n>      2ae:       5f                      pop    %rdi\n>      2af:       c3                      retq\n>>>   2b0:       40 53                   rex push %rbx\n>      2b2:       48 83 ec 20             sub    $0x20,%rsp\n>      2b6:       48 89 0d e3 b9 05 00    mov    %rcx,0x5b9e3(%rip)\n>   # 0x5bca0\n>      2bd:       4c 8d 05 f4 b9 05 00    lea    0x5b9f4(%rip),%r8\n>  # 0x5bcb8\n>>>   2c4:       48 8b 42 60             mov    0x60(%rdx),%rax\n>\n> and at 0x2c4 %rdx is 0x2..  I always thought x86 asm syntax strange,\n> but I assume that is trying to write to value of %rdx + offset of\n> 0x60??  But this is a register never written, so I assume it is\n> expected to be passed from efi_loader?\n>\n> From https://en.wikipedia.org/wiki/X86_calling_conventions it seems\n> that MS calling convention expects 2nd arg in %rdx, but linux/gcc\n> calling convention expects 3rd arg in %rdx (there is no 3rd arg)..\n\nI don't know it well either. But so long as functions are properly\ndeclared in header files I don't really understand how we can have a\nmismatch.\n\nRegards,\nSimon","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"i9o9U/R2\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Ex/rMsL+\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3y0nt61tgfz9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 25 Sep 2017 12:22:38 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid EB922C221A4; Mon, 25 Sep 2017 02:17:23 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 9FAA7C22195;\n\tMon, 25 Sep 2017 02:16:26 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 877E7C22185; Mon, 25 Sep 2017 02:13:08 +0000 (UTC)","from mail-qt0-f181.google.com (mail-qt0-f181.google.com\n\t[209.85.216.181])\n\tby lists.denx.de (Postfix) with ESMTPS id 426B3C22187\n\tfor <u-boot@lists.denx.de>; Mon, 25 Sep 2017 02:13:05 +0000 (UTC)","by mail-qt0-f181.google.com with SMTP id o52so5533415qtc.9\n\tfor <u-boot@lists.denx.de>; Sun, 24 Sep 2017 19:13:05 -0700 (PDT)","by 10.200.37.200 with HTTP; Sun, 24 Sep 2017 19:12:43 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,\n\tRCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=20161025; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=jexiDiu/JEudCjpDgW7U5UvYcPXqWdLclEZO0q1qWbk=;\n\tb=i9o9U/R2yLPvbDyFBHmgIRXsm9SC54biSZGeAIy/3KTjlfJVNS+6df+ClcjdDBohmj\n\tQYiTedejlpP8d77oZ63YlqYvRcq4VaTKsXqCwrvK0rZJDpb532dP8gpNoagTk7fe5dpK\n\tSusUCNUArXanIBiVnH3GnoyXnypHfo9l5IRlc0Edy45Wr5g/uaKxJtuYgGx9YUVh5mt9\n\tXngE7Xcz+Mbrdbdwv464txqbna517zQzG1slF2ohC4NSLmxsmp4deFNbuPop7fp9v5Ub\n\tmfC03O5grJknxcdpP+2g5Vu91VoYtBD3FmvsB95V6fZ/gFb9BpKQceqUyP1cnfML/ymx\n\tYdYg==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=jexiDiu/JEudCjpDgW7U5UvYcPXqWdLclEZO0q1qWbk=;\n\tb=Ex/rMsL+rmCK/mS2i2r06qI2Z73o+6HNYcZ83Vk3LUtyYCU4orTwAl9geM1E0YqvZO\n\t3NudKO63Nw+8/GhDtZIrkuVEv1cmOZh1jCiFNq04SUsZxasdFaQgtbMfDGPE/Y6nVRIi\n\tI+7WU4pYv+H8Pvhoe2Rdhn4sTaymt55mKPODk="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:sender:in-reply-to:references:from\n\t:date:message-id:subject:to:cc;\n\tbh=jexiDiu/JEudCjpDgW7U5UvYcPXqWdLclEZO0q1qWbk=;\n\tb=Vx6j+yefZz70+1eA4bDNFX3PuoJX69SqGGuMPh56tLwBJUy0XdPvJOk7mcOZAmdoy2\n\twU3dNiXUFoDn1ovAp2Dh/o5HlJJ0JM0jjiXvrqHhUnLVzId+EVgrcXtESeaywoGZ1Lk/\n\tMo/E5HiyTxBe64XgaEFLRVvGSV1zKQIVQ1s87hobU2a6G0mmmfxL7GMO9td9xn1XmG35\n\tUN2GBk1TR8NQiLkPGkLGH3RSMWJxSlW5aR5eDIHjVeCiT9xod+iYJsd/jOWwiW/d7XuJ\n\t1FdFk7XvsS9nYFui4qtr2wnbQxdl70P6iQlnY9dJ6txWYU3dA6Os2tENRWKQAFQTMXFS\n\tWIFg==","X-Gm-Message-State":"AHPjjUhFZez+SHDaXBW4zC2COkdY3KNGQMYN1HZNkKjfaWGZcRdZU5Pu\n\tE5FMzug0WZnKTsW8cx/RdLunt1rGbcpxXQu0HJ3bFw==","X-Google-Smtp-Source":"AOwi7QDVBCe94q5xEHw2shIP2BhkL4Gw3+qQh2o+ZzIviHq2VP9Rd8NWH3geyA8buSH/ivuYD/yl9LRneGIoJ6Eia6M=","X-Received":"by 10.237.37.182 with SMTP id x51mr8840819qtc.5.1506305583790;\n\tSun, 24 Sep 2017 19:13:03 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<CAF6AEGuR2zCkZT+D==ULJeXk6MTXmFk7F=7nVJOrY_B+AsW6Fg@mail.gmail.com>","References":"<20170917225927.117917-1-sjg@chromium.org>\n\t<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>\n\t<CAF6AEGu3D40KYmsNpHr3XsihOieD_8myOVv+2kBrKxrMvKGXXQ@mail.gmail.com>\n\t<CAF6AEGvj9V5AsW=xZkAfhy51LxpgWvxHr1DMQDhiFYTDtyCMCg@mail.gmail.com>\n\t<CAF6AEGtUbdU3=NUYZg1_VRwn81u9nAPMrvb+WQq7REpFnnvRvg@mail.gmail.com>\n\t<CAF6AEGsLgp7aBYNUVnQjnbygXa5QNjFiD8TAuyJiiEFyr66ZZg@mail.gmail.com>\n\t<CAF6AEGuR2zCkZT+D==ULJeXk6MTXmFk7F=7nVJOrY_B+AsW6Fg@mail.gmail.com>","From":"Simon Glass <sjg@chromium.org>","Date":"Sun, 24 Sep 2017 22:12:43 -0400","X-Google-Sender-Auth":"XL_WWoYD3lTV9MrUrmBnpTTZyQc","Message-ID":"<CAPnjgZ1HinjqHYRG19G16-pMk4JUKHkae12G-dbN0UDytg_ebg@mail.gmail.com>","To":"Rob Clark <robdclark@gmail.com>","Cc":"Heinrich Schuchardt <xypron.glpk@gmx.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tU-Boot Mailing List <u-boot@lists.denx.de>","Subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}},{"id":1774371,"web_url":"http://patchwork.ozlabs.org/comment/1774371/","msgid":"<CAPnjgZ348UTB13UpHxGP5H_qaNrkCtWE-YFPPthcd2NJGmHAkA@mail.gmail.com>","list_archive_url":null,"date":"2017-09-25T02:15:57","subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","submitter":{"id":6170,"url":"http://patchwork.ozlabs.org/api/people/6170/","name":"Simon Glass","email":"sjg@chromium.org"},"content":"Hi Rob,\n\nOn 18 September 2017 at 09:07, Rob Clark <robdclark@gmail.com> wrote:\n> On Mon, Sep 18, 2017 at 10:30 AM, Rob Clark <robdclark@gmail.com> wrote:\n>> On Mon, Sep 18, 2017 at 9:31 AM, Rob Clark <robdclark@gmail.com> wrote:\n>>> On Mon, Sep 18, 2017 at 9:18 AM, Rob Clark <robdclark@gmail.com> wrote:\n>>>> On Sun, Sep 17, 2017 at 11:48 PM, Heinrich Schuchardt\n>>>> <xypron.glpk@gmx.de> wrote:\n>>>>> On 09/18/2017 12:59 AM, Simon Glass wrote:\n>>>>>> A limitation of the EFI loader at present is that it does not build with\n>>>>>> sandbox. This makes it hard to write tests, since sandbox is used for most\n>>>>>> testing in U-Boot.\n>>>>>>\n>>>>>> This series enables the EFI loader feature. It allows sandbox to build and\n>>>>>> run a trivial function which calls the EFI API to output a message.\n>>>>>>\n>>>>>> Much work remains but this should serve as a basis for adding tests more\n>>>>>> easily for EFI loader.\n>>>>>>\n>>>>>> This series sits on top of Heinrich's recent EFI test series. It is\n>>>>>> available at u-boot-dm/efi-working\n>>>>>>\n>>>>>>\n>>>>>> Simon Glass (16):\n>>>>>>   efi: Update efi_smbios_register() to return error code\n>>>>>>   efi: Move the init check inside efi_init_obj_list()\n>>>>>>   efi: Add error checking for efi_init_obj_list()\n>>>>>>   efi: Add a TODO to efi_init_obj_list()\n>>>>>>   efi: Correct header order in efi_memory\n>>>>>>   efi: sandbox: Adjust memory setup for sandbox\n>>>>>>   sandbox: smbios: Update to support sandbox\n>>>>>>   sandbox: Add a setjmp() implementation\n>>>>>>   efi: sandbox: Add required linker sections\n>>>>>>   efi: sandbox: Add distroboot support\n>>>>>>   Define board_quiesce_devices() in a shared location\n>>>>>>   Add a comment for board_quiesce_devices()\n>>>>>>   efi: sandbox: Add relocation constants\n>>>>>>   efi: Add a comment about duplicated ELF constants\n>>>>>>   efi: sandbox: Enable EFI loader builder for sandbox\n>>>>>>   efi: sandbox: Add a simple 'bootefi test' command\n>>>>>>\n>>>>>>  arch/arm/include/asm/u-boot-arm.h |  1 -\n>>>>>>  arch/sandbox/cpu/cpu.c            | 13 ++++++++++\n>>>>>>  arch/sandbox/cpu/os.c             | 17 ++++++++++++\n>>>>>>  arch/sandbox/cpu/u-boot.lds       | 29 +++++++++++++++++++++\n>>>>>>  arch/sandbox/include/asm/setjmp.h | 21 +++++++++++++++\n>>>>>>  arch/sandbox/lib/Makefile         |  2 +-\n>>>>>>  arch/sandbox/lib/sections.c       | 12 +++++++++\n>>>>>>  arch/x86/include/asm/u-boot-x86.h |  1 -\n>>>>>>  arch/x86/lib/bootm.c              |  4 ---\n>>>>>>  cmd/bootefi.c                     | 54 ++++++++++++++++++++++++++++++++++-----\n>>>>>>  common/bootm.c                    |  4 +++\n>>>>>>  configs/sandbox_defconfig         |  1 +\n>>>>>>  include/bootm.h                   |  8 ++++++\n>>>>>>  include/config_distro_bootcmd.h   |  2 +-\n>>>>>>  include/efi_loader.h              | 13 ++++++++--\n>>>>>>  include/os.h                      | 21 +++++++++++++++\n>>>>>>  lib/efi_loader/Kconfig            | 12 ++++++++-\n>>>>>>  lib/efi_loader/Makefile           |  1 +\n>>>>>>  lib/efi_loader/efi_boottime.c     |  4 +++\n>>>>>>  lib/efi_loader/efi_memory.c       | 33 +++++++++++++-----------\n>>>>>>  lib/efi_loader/efi_runtime.c      |  7 +++++\n>>>>>>  lib/efi_loader/efi_smbios.c       |  6 +++--\n>>>>>>  lib/efi_loader/efi_test.c         | 17 ++++++++++++\n>>>>>>  lib/smbios.c                      | 38 ++++++++++++++++++++-------\n>>>>>>  24 files changed, 277 insertions(+), 44 deletions(-)\n>>>>>>  create mode 100644 arch/sandbox/include/asm/setjmp.h\n>>>>>>  create mode 100644 arch/sandbox/lib/sections.c\n>>>>>>  create mode 100644 lib/efi_loader/efi_test.c\n>>>>>>\n>>>>> Thanks for enabling efi_loader on sandbox. That will make many things\n>>>>> easier.\n>>>>>\n>>>>> Unfortunately\n>>>>> efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,\n>>>>>                                  struct efi_system_table *systab)\n>>>>> {\n>>>>> ...\n>>>>>         boottime = systable->boottime;\n>>>>> ...\n>>>>>         ret = boottime->allocate_pool(EFI_BOOT_SERVICES_DATA, map_size,\n>>>>>                                       (void **)&memory_map);\n>>>>> leads to a segmentation fault:\n>>>>\n>>>> I'm seeing something similar, because:\n>>>>\n>>>> (gdb) print gd->bd->bi_dram[0]\n>>>> $2 = {start = 0, size = 134217728}\n>>>>\n>>>> u-boot expects 1:1 phys:virt mapping, so that probably won't work.\n>>>\n>>> The following quick hack works.. something similar could probably be\n>>> smashed in to \"\"\n>>>\n>>> --------\n>>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\n>>> index cddafe2d43..da2079a4b1 100644\n>>> --- a/lib/efi_loader/efi_memory.c\n>>> +++ b/lib/efi_loader/efi_memory.c\n>>> @@ -459,9 +459,10 @@ int efi_memory_init(void)\n>>>      unsigned long uboot_start, uboot_pages;\n>>>      unsigned long uboot_stack_size = 16 * 1024 * 1024;\n>>>\n>>> -    efi_add_known_memory();\n>>>\n>>>      if (!IS_ENABLED(CONFIG_SANDBOX)) {\n>>> +        efi_add_known_memory();\n>>> +\n>>>          /* Add U-Boot */\n>>>          uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n>>>                  ~EFI_PAGE_MASK;\n>>> @@ -476,6 +477,12 @@ int efi_memory_init(void)\n>>>          runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n>>>          efi_add_memory_map(runtime_start, runtime_pages,\n>>>                     EFI_RUNTIME_SERVICES_CODE, false);\n>>> +    } else {\n>>> +#define SZ_256M    0x10000000\n>>> +        size_t sz = SZ_256M;\n>>> +        void *ram = os_malloc(sz);\n>>> +        efi_add_memory_map((uintptr_t)ram, sz >> EFI_PAGE_SHIFT,\n>>> +                   EFI_CONVENTIONAL_MEMORY, false);\n>>>      }\n>>>\n>>>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n>>> --------\n>>>\n>>> With that I'm at least getting further..  efi_allocate_pool()\n>>> eventually fails, possibly making every small memory allocation page\n>>> aligned means that 256m isn't enough..\n>>\n>> Ok, still just as hacky, but works a bit better:\n>>\n>> ---------\n>> diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c\n>> index cddafe2d43..b546b5e35d 100644\n>> --- a/lib/efi_loader/efi_memory.c\n>> +++ b/lib/efi_loader/efi_memory.c\n>> @@ -14,6 +14,7 @@\n>>  #include <linux/list_sort.h>\n>>  #include <inttypes.h>\n>>  #include <watchdog.h>\n>> +#include <os.h>\n>>\n>>  DECLARE_GLOBAL_DATA_PTR;\n>>\n>> @@ -459,9 +460,9 @@ int efi_memory_init(void)\n>>      unsigned long uboot_start, uboot_pages;\n>>      unsigned long uboot_stack_size = 16 * 1024 * 1024;\n>>\n>> -    efi_add_known_memory();\n>> -\n>>      if (!IS_ENABLED(CONFIG_SANDBOX)) {\n>> +        efi_add_known_memory();\n>> +\n>>          /* Add U-Boot */\n>>          uboot_start = (gd->start_addr_sp - uboot_stack_size) &\n>>                  ~EFI_PAGE_MASK;\n>> @@ -476,6 +477,14 @@ int efi_memory_init(void)\n>>          runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;\n>>          efi_add_memory_map(runtime_start, runtime_pages,\n>>                     EFI_RUNTIME_SERVICES_CODE, false);\n>> +    } else {\n>> +#define SZ_4K    0x00001000\n>> +#define SZ_256M    0x10000000\n>> +        size_t sz = SZ_256M;\n>> +        uintptr_t ram = (uintptr_t)os_malloc(sz + SZ_4K) + SZ_4K;\n>> +        efi_add_memory_map(ram & ~EFI_PAGE_MASK, sz >> EFI_PAGE_SHIFT,\n>> +                   EFI_CONVENTIONAL_MEMORY, false);\n>> +        gd->start_addr_sp = ~0;\n>>      }\n>>\n>>  #ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER\n>> ---------\n>>\n>> At this point it crashes in efi_load_pe() when it first tries to\n>> dereference the address of the image passed in, ie. I'm running:\n>>\n>>   host bind 0 x86_64-sct.img\n>>   load host 0:1 0x01000000 /efi/boot/shell.efi\n>>   bootefi 0x01000000\n>>\n>> Not sure if there is a better way to pick an address to load into.  Or\n>> maybe just assuming that PA==VA isn't a good idea in sandbox?\n>>\n>\n> Ok, I realized there is map_sysmem().. which gets me further..\n> efi_loader really expects identity mapping (PA==VA), and iirc this is\n> what UEFI spec expects too so I wouldn't necessarily call it a bug in\n> efi_loader.\n\nWell we need to make it work :-)\n\nIn general casting an address to a pointer (or vice versa) should be\navoided in U-Boot now that we have map_sysmem(). It is incompatible\nwith sandbox.\n\nRegards,\nSimon","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=google.com header.i=@google.com\n\theader.b=\"Kt27isJE\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"U+rxQtPf\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3y0pHQ1glcz9t30\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 25 Sep 2017 12:41:06 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid D7F08C221E6; Mon, 25 Sep 2017 02:20:08 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 8A127C22007;\n\tMon, 25 Sep 2017 02:20:04 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 282EFC2215F; Mon, 25 Sep 2017 02:16:23 +0000 (UTC)","from mail-qt0-f169.google.com (mail-qt0-f169.google.com\n\t[209.85.216.169])\n\tby lists.denx.de (Postfix) with ESMTPS id 663C3C22187\n\tfor <u-boot@lists.denx.de>; Mon, 25 Sep 2017 02:16:19 +0000 (UTC)","by mail-qt0-f169.google.com with SMTP id f15so5542942qtf.7\n\tfor <u-boot@lists.denx.de>; Sun, 24 Sep 2017 19:16:19 -0700 (PDT)","by 10.200.37.200 with HTTP; Sun, 24 Sep 2017 19:15:57 -0700 (PDT)"],"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=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID autolearn=unavailable\n\tautolearn_force=no version=3.4.0","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com;\n\ts=20161025; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=C4aUh/9mrZxaKUQ7VhR6ERUB9GQfdGJ/li7wGq7kCEo=;\n\tb=Kt27isJEnaQv/WgQ/kkPkElcfRMdhCJHKJPgZFZHpq02BBrm/unNSZqRjum+KQ42E3\n\tRHoztkdbHBHnR5F8cj5wyrM52Q54FVtxN4uJWBFhon1Aq1cUduVUXDIWNjZ1Mywy9M0f\n\tZHcfSz/QId1RaEYCWmcAlQNiBGYvnc7BMNkTVrMh7o5cxflPGYu2xFuPtazIbK3ONqym\n\tBZpjsUz/u2filagnq5bSB+yDSIB4MNztpEQkbQgKPBxk6Dcj1flPUT1ZSgDEGPyyKTHj\n\t5z3CbyPGSs2/5Jl1VB+fQIorf1cCqDrefOJKPIRtAPtmfnf8JNHxMWzLxEfGKgfyYlL7\n\tsbVA==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:sender:in-reply-to:references:from:date:message-id\n\t:subject:to:cc;\n\tbh=C4aUh/9mrZxaKUQ7VhR6ERUB9GQfdGJ/li7wGq7kCEo=;\n\tb=U+rxQtPf/YlWv1NwHEHQRi2OCZARRAw2e9yAD/xPmawrP+kA85m0koTnEE1L3FTOB9\n\tz2+jWmyohzaX7u6NtRLX0zFvtQZ93QZaKfK/NKmQHsKhVc1sM6mWihfjiW9UukT0e/pV\n\tY8albbhEqQqLX8wRFQJotVv93DSBLxVt/imBM="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:sender:in-reply-to:references:from\n\t:date:message-id:subject:to:cc;\n\tbh=C4aUh/9mrZxaKUQ7VhR6ERUB9GQfdGJ/li7wGq7kCEo=;\n\tb=CdxUnMgb+5cwnvNAInJgBw7bq9YlZMILlsmzSSARwWwXELA1Nc1z4+oSkwRNJSGnTg\n\tZAGMIliiizZ0cLjk+7r3sdqzsDkJwd4u/NhRSZhvx3MboPsDCYcqwaVTIGqDFdLR6nvs\n\txnfaa5WTJvEzhyaGtpoHQQTywv6gBj47bwINn3QbIgXUdDQDbvS/D+8phohctnjJNegM\n\tD8foATkndTM2Z2/89Kn4qeehPqgkN2wHBMgl5PtrcePEgve20yEPQec1ceF4K9QNS3Zs\n\tyroF64C/2UuPZH7evjdfszjXryEUMReiXF4Osx50mIPZPnedO93MbvMeF9TdDh6Ty5vN\n\tAdVQ==","X-Gm-Message-State":"AHPjjUg1yxtFdJ7DgWPhIklj+RQRW54iey6PPSSpNtfqXqOxoblIG8aA\n\txMezM9jiAtsDmIYORDTKw35zKCl+2QsNf0tRgGJA6w==","X-Google-Smtp-Source":"AOwi7QDuiJ+q+nYxLWM7juBuAANpT0MVcyUeRwPnNuhc62+rXfJ6U3vdoiMs4h0LkuYRZJUlq7Dl8heprIX2BP89MOI=","X-Received":"by 10.200.52.241 with SMTP id x46mr9278226qtb.38.1506305778052; \n\tSun, 24 Sep 2017 19:16:18 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<CAF6AEGsLgp7aBYNUVnQjnbygXa5QNjFiD8TAuyJiiEFyr66ZZg@mail.gmail.com>","References":"<20170917225927.117917-1-sjg@chromium.org>\n\t<24005e02-b4de-222f-3aa9-b072e03c51ee@gmx.de>\n\t<CAF6AEGu3D40KYmsNpHr3XsihOieD_8myOVv+2kBrKxrMvKGXXQ@mail.gmail.com>\n\t<CAF6AEGvj9V5AsW=xZkAfhy51LxpgWvxHr1DMQDhiFYTDtyCMCg@mail.gmail.com>\n\t<CAF6AEGtUbdU3=NUYZg1_VRwn81u9nAPMrvb+WQq7REpFnnvRvg@mail.gmail.com>\n\t<CAF6AEGsLgp7aBYNUVnQjnbygXa5QNjFiD8TAuyJiiEFyr66ZZg@mail.gmail.com>","From":"Simon Glass <sjg@chromium.org>","Date":"Sun, 24 Sep 2017 22:15:57 -0400","X-Google-Sender-Auth":"wv66Q7KdVU1cfaI4hqjGBsat0S4","Message-ID":"<CAPnjgZ348UTB13UpHxGP5H_qaNrkCtWE-YFPPthcd2NJGmHAkA@mail.gmail.com>","To":"Rob Clark <robdclark@gmail.com>","Cc":"Heinrich Schuchardt <xypron.glpk@gmx.de>,\n\tAndy Shevchenko <andriy.shevchenko@linux.intel.com>,\n\tU-Boot Mailing List <u-boot@lists.denx.de>","Subject":"Re: [U-Boot] [PATCH 00/16] efi: Enable basic sandbox support for\n\tEFI loader","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}}]